Problem/Motivation

Version 3.9 introduced isDeprecatedConfigDirectorySettingUsed() for the UpgradeStatusForm, which includes settings.php.

However, if you use the $class_loader variable in settings.php it will cause a fatal error as $class_loader is not defined in this context.

Steps to reproduce

Any config in settings.php that uses $class_loader will do.

Proposed resolution

See patch attached.

CommentFileSizeAuthor
#3 3229107-2.patch410 bytesandreasderijcke

Comments

andreasderijcke created an issue. See original summary.

andreasderijcke’s picture

Issue summary: View changes
andreasderijcke’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new410 bytes

Added patch.

gábor hojtsy’s picture

Title: UpgrateStatusForm: $class_loader not set » isDeprecatedConfigDirectorySettingUsed() does not define $class_loader in case settings.php will need it
Status: Needs review » Postponed (maintainer needs more info)

Hm, core's Drupal\Core\Site\Settings class does not provide the class loader to settings.php either when it includes it for settings handling. Why would we need to?

andreasderijcke’s picture

Status: Postponed (maintainer needs more info) » Needs review

It does, see https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/lib/Drupal/C...
Also, default.settings.php contains an example using $class_loader: https://git.drupalcode.org/project/drupal/-/blob/8.9.x/sites/default/def...

I don't know the specific reason, as it is not mentioned in the Redis module docs, but some redis setups use it to register the redis namespace.
For example https://community.platform.sh/t/how-to-use-redis-for-caching-a-drupal-8-....

gábor hojtsy’s picture

Ah and its done intentionally.

   * @param \Composer\Autoload\ClassLoader $class_loader
   *   The class loader that is used for this request. Passed by reference and
   *   exposed to the local scope of settings.php, so as to allow it to be
   *   decorated with Symfony's ApcClassLoader, for example.

  • 7c6a8cb committed on 8.x-3.x
    Issue #3229107 by andreasderijcke:...
gábor hojtsy’s picture

Status: Needs review » Fixed

So the question is if this is the best way to get the class loader that is in the state normally passed into settings.php.

index.php has

$autoloader = require_once 'autoload.php';
$kernel = new DrupalKernel('prod', $autoloader);

which is then saved as classLoader in the kernel which is passed into the settings initializer.

Looks good, let's get in!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.