Problem/Motivation

The class loader can be swapped out either manually (by editing settings.php) or since #2296009: Use APC Classloader by default (when available) automatically if APCu is present on the machine. However, the application kernel is constructed before settings.php is evaluated, and the classLoader property of the kernel gets out-of-sync if the class loader is subsequently swapped out.

Proposed resolution

Update DrupalKernel::classLoader if changed during createFromRequest().

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

znerol’s picture

This is expected to result in the same test-failures as #2389811-66: Move all the logic out of index.php (again) because the APCu class-loader should now be propagated into TestDiscovery where it causes an exception due to the type-hint against the composer class loader.

znerol’s picture

Status: Active » Needs review
znerol’s picture

Fix TestDiscovery.

The last submitted patch, 1: 2474817-synchronize-class-loader.diff, failed testing.

andypost’s picture

+++ b/core/modules/simpletest/src/TestDiscovery.php
@@ -54,12 +53,14 @@ class TestDiscovery {
-   *   The class loader.
+   * @param $class_loader
+   *   The class loader. Normally Composer's ClassLoader, as included by the
+   *   front controller, but may also be decorated; e.g.,
+   *   \Symfony\Component\ClassLoader\ApcClassLoader.

Is there a way to use some interface here for type-hint?
This will not pass docs gate

znerol’s picture

Is there a way to use some interface here for type-hint?

I do not think so. Neither composer class loader nor the APC one from Symfony implement an interface . This just replicates changes made to DrupalKernel constructor (#2325197-15: Remove drupal_classloader()). If there is a problem with the documentation, we need to fix that in DrupalKernel also.

znerol’s picture

Fabianx’s picture

Thanks for the patch, but does that work for the settings.php use case as well? (which can't change the kernel class loader obviously)

znerol’s picture

Oh, right.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC, thanks, just a normal bug.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 83d2660 and pushed to 8.0.x. Thanks!

  • alexpott committed 83d2660 on 8.0.x
    Issue #2474817 by znerol: DrupalKernel::classLoader not updated when...

Status: Fixed » Closed (fixed)

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