Commit 17e71a44 authored by webchick's avatar webchick

Issue #1929656 by dawehner: Fixed ModuleHandler::setModuleList() should call...

Issue #1929656 by dawehner: Fixed ModuleHandler::setModuleList() should call resetImplementations() in order to avoid edge cases.
parent 057dd511
......@@ -432,7 +432,6 @@ function drupal_install_system() {
// Update the module list to include it.
drupal_container()->get('module_handler')->setModuleList(array('system' => $system_path . '/system.module'));
drupal_container()->get('module_handler')->resetImplementations();
config_install_default_config('module', 'system');
......
......@@ -339,9 +339,6 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
$module_handler->load($module);
module_load_install($module);
// Reset the the hook implementations cache.
$module_handler->resetImplementations();
// Flush theme info caches, since (testing) modules can implement
// hook_system_theme_info() to register additional themes.
system_list_reset();
......@@ -499,8 +496,6 @@ function module_disable($module_list, $disable_dependents = TRUE) {
if (!empty($invoke_modules)) {
// @todo Most of the following should happen in above loop already.
// Refresh the module list to exclude the disabled modules.
$module_handler->resetImplementations();
// Refresh the system list to exclude the disabled modules.
// @todo Only needed to rebuild theme info.
......
......@@ -152,6 +152,9 @@ public function getModuleList() {
*/
public function setModuleList(array $module_list = array()) {
$this->moduleList = $module_list;
// Reset the implementations, so a new call triggers a reloading of the
// available hooks.
$this->resetImplementations();
}
/**
......
......@@ -58,13 +58,13 @@ function testEnableDisable() {
// Enable the dblog module first, since we will be asserting the presence
// of log messages throughout the test.
if (isset($modules['dblog'])) {
$modules = array('dblog' => $modules['dblog']) + $modules;
}
if (isset($modules['dblog'])) {
$modules = array('dblog' => $modules['dblog']) + $modules;
}
// Set a variable so that the hook implementations in system_test.module
// will display messages via drupal_set_message().
state()->set('system_test.verbose_module_hooks', TRUE);
// Set a variable so that the hook implementations in system_test.module
// will display messages via drupal_set_message().
state()->set('system_test.verbose_module_hooks', TRUE);
// Go through each module in the list and try to enable it (unless it was
// already enabled automatically due to a dependency).
......@@ -192,7 +192,9 @@ function assertSuccessfulDisableAndUninstall($module, $package = 'Core') {
// Check that the appropriate hook was fired and the appropriate log
// message appears.
$this->assertText(t('hook_modules_disabled fired for @module', array('@module' => $module)));
$this->assertLogMessage('system', "%module module disabled.", array('%module' => $module), WATCHDOG_INFO);
if ($module != 'dblog') {
$this->assertLogMessage('system', "%module module disabled.", array('%module' => $module), WATCHDOG_INFO);
}
// Check that the module's database tables still exist.
$this->assertModuleTablesExist($module);
......
......@@ -97,11 +97,19 @@ function testModuleImplements() {
$this->drupalGet('');
$this->assertTrue(cache('bootstrap')->get('module_implements'), 'The module implements cache is populated after requesting a page.');
// Prime ModuleHandler's hook implementation cache by invoking a random hook
// name. The subsequent module_enable() below will only call into
// setModuleList(), but will not explicitly reset the hook implementation
// cache, as that is expected to happen implicitly by setting the module
// list. This verifies that the hook implementation cache is cleared
// whenever setModuleList() is called.
$module_handler = drupal_container()->get('module_handler');
$module_handler->invokeAll('test');
// Make sure group include files are detected properly even when the file is
// already loaded when the cache is rebuilt.
// For that activate the module_test which provides the file to load.
module_enable(array('module_test'));
$module_handler = drupal_container()->get('module_handler');
$module_handler->loadAll();
module_load_include('inc', 'module_test', 'module_test.file');
$modules = $module_handler->getImplementations('test_hook');
......
......@@ -444,10 +444,6 @@ function update_check_requirements($skip_warnings = FALSE) {
$module_handler->setModuleList($module_list);
$module_handler->load('system');
// Reset the module implementations cache so that any new hook implementations
// in updated code are picked up.
$module_handler->resetImplementations();
// Set up $language, since the installer components require it.
drupal_language_initialize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment