Commit 6122e84e authored by Dries's avatar Dries

Issue #1948702 by chx: module_hook() is broken for disabled modules and included hooks.

parent 44eda14f
......@@ -215,10 +215,12 @@ public function loadInclude($module, $type, $name = NULL) {
}
$name = $name ?: $module;
$file = DRUPAL_ROOT . '/' . dirname($this->moduleList[$module]) . "/$name.$type";
if (is_file($file)) {
require_once $file;
return $file;
if (isset($this->moduleList[$module])) {
$file = DRUPAL_ROOT . '/' . dirname($this->moduleList[$module]) . "/$name.$type";
if (is_file($file)) {
require_once $file;
return $file;
}
}
return FALSE;
......
<?php
/**
* @file
* Contains \Drupal\Core\Extension\ModuleHanderUnitTest.
*/
namespace Drupal\Tests\Core\Extension;
if (!defined('DRUPAL_ROOT')) {
define('DRUPAL_ROOT', dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))));
}
use Drupal\Core\Extension\ModuleHandler;
use Drupal\Tests\UnitTestCase;
/**
* Tests the ModuleHandler class.
*
* @group System
*/
class ModuleHandlerUnitTest extends UnitTestCase {
public static function getInfo() {
return array(
'name' => 'ModuleHandler functionality',
'description' => 'Tests the ModuleHandler class.',
'group' => 'System',
);
}
function setUp() {
parent::setUp();
$this->moduleHandler = new ModuleHandler;
}
function testloadInclude() {
// Make sure that load include does not throw notices on nonexisiting
// modules.
$this->moduleHandler->loadInclude('foo', 'inc');
}
}
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