summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2012-11-26 10:32:47 (GMT)
committercatch2012-11-26 10:32:47 (GMT)
commitcde72309be9984a165421af27cc77d42702ff2b9 (patch)
treed2f6165a5ec08804db348862952fd8b1cf5fa79f
parent130b8e3cba73d453de4847c93298ecd6afeb6e64 (diff)
Issue #1846376 by effulgentsia, amateescu | katbailey: Fixed Namespaces for disabled modules are registered during the first request after a module is disabled.
-rw-r--r--core/lib/Drupal/Core/DrupalKernel.php9
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php10
2 files changed, 9 insertions, 10 deletions
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index a5624d7..f07d081 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -192,7 +192,7 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface {
// When installing new modules, the modules in the list passed to
// updateModules() do not yet have their namespace registered.
$namespace = 'Drupal\\' . $module;
- if (!isset($namespaces[$namespace]) && $this->moduleData($module)) {
+ if (empty($namespaces[$namespace]) && $this->moduleData($module)) {
$path = dirname(DRUPAL_ROOT . '/' . $this->moduleData($module)->uri) . '/lib';
$this->modulePaths[$module] = $path;
$this->classLoader->registerNamespace($namespace, $path);
@@ -319,15 +319,20 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface {
// All namespaces must be registered before we attempt to use any service
// from the container.
$namespaces = $this->classLoader->getNamespaces();
+ $namespaces_revert = array();
foreach ($this->container->getParameter('container.modules') as $module => $path) {
$namespace = 'Drupal\\' . $module;
- if (!isset($namespaces[$namespace])) {
+ if (empty($namespaces[$namespace])) {
$this->classLoader->registerNamespace($namespace, $path);
+ $namespaces_revert[$namespace] = array();
}
}
$module_list = $this->moduleList ?: $this->container->get('config.factory')->get('system.module')->load()->get('enabled');
if (array_keys((array)$module_list) !== array_keys($this->container->getParameter('container.modules'))) {
unset($this->container);
+ // Since 'container.modules' was incorrect, revert the classloader
+ // registrations, and allow buildContainer() to get it right.
+ $this->classLoader->registerNamespaces($namespaces_revert);
}
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php
index ea2026d..df59ea0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php
@@ -37,16 +37,10 @@ class ClassLoaderTest extends WebTestBase {
module_disable(array('module_autoload_test'), FALSE);
$this->resetAll();
- // The first request after a module has been disabled will result in that
- // module's namespace getting registered because the kernel registers all
- // namespaces in the existing 'container.modules' parameter before checking
- // whether the list of modules has changed and rebuilding the container.
- // @todo Fix the behavior so that the namespace is not registered even on the
- // first request after disabling the module and revert this test to having
- // the assertion inside the loop. See http://drupal.org/node/1846376
+ // Check twice to test an unprimed and primed system_list() cache.
for ($i=0; $i<2; $i++) {
$this->drupalGet('module-test/class-loading');
+ $this->assertNoText($expected, 'Autoloader does not load classes from a disabled module.');
}
- $this->assertNoText($expected, 'Autoloader does not load classes from a disabled module.');
}
}