-
Notifications
You must be signed in to change notification settings - Fork 39
Bootstrap Drupal correctly from inside SimpleSAMLphp #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hi Dave, Thanks for this! I have a client with a similar symptoms where we suspected Memcached to be an issue, but I haven't had a chance to look at the problem in detail. I will try to test this sometime soon. Do you have a steps to reproduce this? As I'm missing reliable step on the mentioned project. |
Yeah, I don't have reliable steps to reproduce, but anecdotally it did happen more frequently when the I tracked it down by swapping out EntityFieldManager and logging a stack trace in I have since tried to reproduce locally by manually clearing caches at specific times but so far have had no luck. When discussing this in Drupal Slack I was previously pointed to https://www.drupal.org/project/drupal/issues/3207813 - this could also be considered a bug in Drupal as it should not try to build caches without checking all parts are fully loaded, but I think for the most robust fix we should bootstrap Drupal correctly from within this SimpleSAMLphp module as well. |
Further to this, this doesn't entirely solve the issue, there is a further bug in Drupal core: https://www.drupal.org/project/drupal/issues/3441833 |
Hi @longwave, thanks for your PR! I can reliably replicate this issue in a SAML setup with two Drupal sites: Environment:
Authentication flows are as follows:
Steps to reproduce the issue:
I figured it was an issue with Drupal not being completely bootstrapped and did some digging and then found your issue. Your PR fixes our problem. Would be great to try to get these PRs along - happy to help the maintainers if need be! I've also looked at the issues on d.o, and will see if I get more time to have a look soon. |
This was previously reported in #75 but closed as outdated, however it is still an issue.
When certain caches are cold or stale, it is possible for them to be rebuilt during a request that is wrapped by SimpleSAMLphp instead of Drupal's own index.php. However when this happens, the cache is not rebuilt correctly and are missing critical data. This then results in various errors related to missing fields on the Drupal site such as:
or errors with missing plugins:
This is because
DrupalHelper::bootDrupal()
does not fully bootstrap Drupal correctly before calling core services which may go on to initialise caches. In particular theDrupalKernel::preHandle()
method is not called which is responsible for loading all modules, which causes the rebuilt caches to skip items from those modules and cause the errors later down the line.As per the comment if you look at
FunctionalTestSetupTrait::initKernel()
or even/authorize.php
you will see the correct way of partially bootstrapping Drupal without callingDrupalKernel::handle()
is to callpreHandle()
(which callsloadLegacyIncludes()
but also does a bit more).