From 2afd1ed4c48528a95fbb2e9a74a0901a067c5af3 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Wed, 21 Mar 2012 14:18:52 +0900 Subject: [PATCH] Issue #1467126 by effulgentsia, Rob Loach, sun, catch, amateescu, yched, EclipseGc: Fixed Provider based PSR-0 Classes that load more than once. --- core/includes/module.inc | 2 +- core/modules/simpletest/tests/module.test | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/includes/module.inc b/core/includes/module.inc index 60c403542917..df9c138c725c 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -176,7 +176,6 @@ function system_list($type) { } // Build a list of filenames so drupal_get_filename can use it. if ($record->status) { - drupal_classloader_register($record->name, dirname($record->filename)); $lists['filepaths'][] = array('type' => $record->type, 'name' => $record->name, 'filepath' => $record->filename); } } @@ -210,6 +209,7 @@ function system_list($type) { // drupal_get_filename() static cache with all enabled modules and themes. foreach ($lists['filepaths'] as $item) { drupal_get_filename($item['type'], $item['name'], $item['filepath']); + drupal_classloader_register($item['name'], dirname($item['filepath'])); } } diff --git a/core/modules/simpletest/tests/module.test b/core/modules/simpletest/tests/module.test index 81f4a6b3f2be..19acf608d898 100644 --- a/core/modules/simpletest/tests/module.test +++ b/core/modules/simpletest/tests/module.test @@ -260,13 +260,19 @@ class ModuleClassLoaderTestCase extends DrupalWebTestCase { module_enable(array('module_test', 'module_autoload_test'), FALSE); $this->resetAll(); - $this->drupalGet('module-test/class-loading'); - $this->assertText($expected, t('Autoloader loads classes from an enabled module.')); + // Check twice to test an unprimed and primed system_list() cache. + for ($i=0; $i<2; $i++) { + $this->drupalGet('module-test/class-loading'); + $this->assertText($expected, t('Autoloader loads classes from an enabled module.')); + } module_disable(array('module_autoload_test'), FALSE); $this->resetAll(); - $this->drupalGet('module-test/class-loading'); - $this->assertNoText($expected, t('Autoloader does not load classes from a disabled module.')); + // 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, t('Autoloader does not load classes from a disabled module.')); + } } } -- GitLab