Commit 6d9fb62f authored by Dries's avatar Dries

- Patch #731606 by fago: module_implements() fails to find include.

parent 7d9c1dd7
......@@ -589,8 +589,8 @@ function module_implements($hook, $sort = FALSE, $reset = FALSE) {
$implementations[$hook] = array();
$list = module_list(FALSE, FALSE, $sort);
foreach ($list as $module) {
$include_file = FALSE;
if (module_hook($module, $hook) || (isset($hook_info[$hook]['group']) && $include_file = module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']) && module_hook($module, $hook))) {
$include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
if (module_hook($module, $hook)) {
$implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
// We added something to the cache, so write it when we are done.
$implementations['#write_cache'] = TRUE;
......
......@@ -98,6 +98,17 @@ class ModuleUnitTest extends DrupalWebTestCase {
cache_clear_all('module_implements', 'cache_bootstrap');
$this->drupalGet('');
$this->assertTrue(cache_get('module_implements', 'cache_bootstrap'), t('The module implements cache is populated after requesting a page.'));
// 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_load_include('inc', 'module_test', 'module_test.file');
$modules = module_implements('test_hook');
$static = drupal_static('module_implements');
$this->assertTrue(in_array('module_test', $modules), 'Hook found.');
$this->assertEqual($static['test_hook']['module_test'], 'file', 'Include file detected.');
}
/**
......
<?php
// $Id$
/**
* @file
* A file to test module_implements() loading includes.
*/
/**
* Implements hook_test_hook().
*/
function module_test_test_hook() {
}
\ No newline at end of file
......@@ -5,4 +5,5 @@ package = Testing
version = VERSION
core = 7.x
files[] = module_test.module
files[] = module_test.file.inc
hidden = TRUE
......@@ -37,3 +37,13 @@ function module_test_system_info_alter(&$info, $file, $type) {
}
}
}
/**
* Implements hook_hook_info().
*/
function module_test_hook_info() {
$hooks['test_hook'] = array(
'group' => 'file',
);
return $hooks;
}
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