How to limit access to a subsite of my Drupal 8 site?

I have a site I created with Drupal 8, lets say http://falzon.xyz/.
I have “embedded” a static site (a bunch of static pages linked to each other) as a “subsite” of falzon.xyz, i.e. accessible as http://falzon.xyz/whatever/, by ‘simply’ putting all its files in a subfolder of the D8 site, i.e. docroot/whatever.
I’d like to limit access to this “subsite” to the users that are registered to my D8 site.
How can I do that?

8 – Expiration date on product variation (Drupal Commerce)

What is the best approach to set an expiration date on a product variation?

I am building a webshop and my goal is to have an expiration date on a product variation, meaning the after a scheduled date, the product would no longer be available to sell, so it would automatically unpublish. Also, vice versa, the product variation might have a publishing date.

What would be the best approach for this? Currently I am looking at scheduler, but that is for nodes, not for products. Is there another way of doing this?

updating – How to solve this issue while Upgrading from Drupal 8.7.7 to 8.9.7 using docker compose?

I have already deploed drupal 8.7.7 using docker. now am trying to upgrade to 8.9.7. during the site installation i am facing below error

” In SiteInstallCommands.php line 335: Could not determine target sites directory for site to install. Use –sites -subdir to specify. “

migration – how to migrate dates of date time format to drupal 8 date only from drupal 7

in my drupal 7 site the date is formatted in the database as 2020-08-10 00:00:00
when i do the migration without any formatting (ie field_blog_post_date: field_blog_post_date, the date is migrated into the d8 table with the same exact formatting, however it does not show in the view of the content .
I tried to use a format date plugin as below, but it get the error DateTime::createFromFormat() expects parameter 2 to be string, array (warning)
given DateTimePlus.php:251

 field_blog_post_date: 
    plugin: format_date
    source: field_blog_post_date
    from_format: 'Y-m-d H:i:s'
    to_format: 'Y-m-d'

payment gateways – Drupal 8 Commerce Stripe Live Keys in settings.php

I am trying to set-up my Drupal 8 Commerce Stripe Live Keys in settings.php rather than using the UI. I am using the following code in settings.php:

if (getenv("MYPROJECT_STRIPE_LIVE_PUBLISHABLEKEY")) {
  $config('commerce_payment.commerce_payment_gateway.my_gateway_id')('configuration')('publishable_key') = getenv("MYPROJECT_STRIPE_LIVE_PUBLISHABLEKEY");
}
if (getenv("MYPROJECT_STRIPE_LIVE_SECRETKEY")) {
  $config('commerce_payment.commerce_payment_gateway.my_gateway_id')('configuration')('secret_key') = getenv("MYPROJECT_STRIPE_LIVE_SECRETKEY");
}

In the UI, I have left the Test Publishable Key and Test Secret Key in place but when I change the UI setting to ‘Live’, I get an error when I try to save the settings saying ‘The provided secret key is not for the selected mode (live).’ If I change the first bit of the Test Secret Key to ‘sk_live_’, I get another error saying the Secret key is invalid. The field is required, so I can’t leave it blank.

Anyone got any ideas?

Thanks

F

debugging – Drupal + XDebug + VSCode = can’t break on PHP notice or warning

Using Drupal (8.9), PHP (7.2.34) with xdebug, and VSCode (1.50.1) with PHP Debug (1.13.0), the debugger will no longer break on PHP notices and warnings, even if those option checkboxes are set.

The behavior starts as soon as Drupal installs its error handler in DrupalCoreDrupalKernal::bootEnvironment().

As an example, if I insert strlen();, a function call which triggers a PHP Warning (error type 4), immediately before set_error_handler('_drupal_error_handler');, execution will stop and the VSCode debugger will display the offending line. As soon as the error handler is installed, VSCode will no longer stop.

The same behavior is true of PHP Notices. Execeptions and regular breakpoints work as expected.

Turnning on logging shows that the debugger is sending the command to break on notice and warnings:

> setExceptionBreakpointsRequest
{
  command: 'setExceptionBreakpoints',
  arguments: { filters: ( 'Notice', 'Warning' ) },
  type: 'request',
  seq: 4
}

<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setExceptionBreakpoints',
  success: true
}

… but then there’s nothing further in the log about the notice or warning exceptions.

Now I can believe this is simply a limitation of xdebug — that the use of the drupal error handler (which does NOT return FALSE to trigger default error handling), except that I know that at some very distant time in the past, using different tools, I could break on notices and warnings. For example, using Drupal 6, PHP 5.3, KomodoEdit (unknown version), this used to work.

If anyone is successfully getting the debugger to stop on PHP notices and warnings using tools similar to what I’m using, I’d love some details. I’ve looked over the xdebug and php configuration settings and I don’t see anything that be relevant. Note: I’m not trying to display the warnings/notices — that is working according to the Drupal configuration. And I’m not trying to halt on warnings/notices. I’m trying to get xdebug to break execution.

postgres – How to install drupal 9 with PostgreSQL using Docksal?

I use docksal for developing on Drupal.

Recently I decided to install Drupal 9 with PostgreSQL as a database using Docksal.

Firstly, I cloned this git-repository.
https://github.com/docksal/boilerplate-drupal9

Secondly, I modified some files accordingly to this manual
https://github.com/docksal/docksal/issues/193#issuecomment-376343111

Lastly, I ran the “fin init” command and saw an error message

(warning) Failed to drop or create the database. Do it yourself before
installing. ERROR 2002 (HY000): Can’t connect to MySQL server on ‘db’
(115)

(notice) Starting Drupal installation. This takes a while.

In install.core.inc line 2298:
Database settings:
Array

Frankly speaking, I can’t understand what does MySQL has to do with it?
My DB driver should be PostgreSQL, my default database should be also PostgreSQL.

Has anybody encountered this problem?
Is it possible to install Drupal 9 + PostgreSQL via the docksal service?

8 – How to display default drupal search block in twig template

In twig_tweak module before version 2 (for Drupal 8) I could place the following code in my page twig template and it would work:

{{ drupal_block('exposedformsearch_contentpage_1') }}

This would display put the default site search box.

After upgrading to version 2, this doesn’t work anymore and see the following message on the page:

This block is broken or missing. You may be missing content or you might need to enable the original module. 

I tried using the command:

{{ drupal_block('search_form_block') }}

That displays the same error message.

Does anyone know what the the correct call is? I can’t seem to find any documentation anywhere as to what the replacement call should be.

Thanks.

hooks – SharePoint online search query from Drupal in logged in user context, which is connected through SIMPLESAML SSO (Azure AD IDP) with PHP application

Below is problem description – I have sharepoint online and its URL is like – https://abc.sharepoint.com

Above sharepoint is connected through SSO (Office 365 Azure AD IDP and SAML)

I have another Drupal 8 application like – https://drupalapp.something.com

It is also connected through same SSO (Office Azure AD and SAML) so that if user login through either of application through SSO then he is allowed to login in another application as well. It means application is Single sign on enabled. and its working fine.

Now as a user, i am able to login through drupalapp.something.com using SSO (office 365 azure AD and SAML ). Now after user login being developer, i need to show recent modified SharePoint document from SharePoint online using SharePoint REST query but condition is that, it should fetch only documents on which logged in user has permission to show.

Brief requirement –

The requirements is to be able to make REST queries to SharePoint online but when the REST query is made, the person the query is for must only see the results based on their security context.

So if user1 has access to a SharePoint folder but user2 has not, then when the REST call is made they will each see a different set of results.

Example: user1 has access to abc.sharepoint.com/abcfolder/afile.pdf. User2 does not have access to the folder abc.sharepoint.com/abcfolder/ and so he will not have access to abc.sharepoint.com/abcfolde/afile.pdf.

If some updates this document it becomes a “Latest Update”. User1 will see it in the Latest documents but User2 will not.

I tried using PHPSPO library (https://github.com/vgrem/phpSPO) and it giving me result but this library is giving me result based on admin credential which I pass to connect SharePoint. So this is giving me all the documents regardless of logged in user permission.

How can we achieve this in logged in user context. Considering user is already login through SSO in Drupal application through SSO.

I also tried to make AJAX request with credential query from Drupal app but it always giving me CORS and CORB error. I don’t know if this is right way of solution. Below is code –

var urlval = “https://abc.sharepoint.com/_api/search/query?querytext=’isdocument:1’&selectproperties=’Title,Size,Name,Path,FileExtension’&rowlimit=5&sortlist=’created:descending’&refiners=’fileextension'”;

    $.ajaxSetup({
      xhrFields: {
        withCredentials: true
      }
    });
    
    $.ajax({
      type: 'GET',
      crossDomain: true,
      dataType: 'jsonp',
      url: urlval,
      cache: false,
      headers: {
        "accept": "application/json",
        "Access-Control-Allow-Origin": "https://abc.sharepoint.com",
      },
     
      success: function( response ) {
        console.log( response ); // server response
      }
    });

Please help me to solve this problem.

Thanks