Commit f9ec71df authored by catch's avatar catch
Browse files

Issue #2045935 by benjy: Replace all module_hook() deprecated function calls.

parent dbcb65bd
......@@ -993,22 +993,20 @@ function drupal_requirements_severity(&$requirements) {
*/
function drupal_check_module($module) {
module_load_install($module);
if (module_hook($module, 'requirements')) {
// Check requirements
$requirements = module_invoke($module, 'requirements', 'install');
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
// Print any error messages
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$message = $requirement['description'];
if (isset($requirement['value']) && $requirement['value']) {
$message .= ' (' . t('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
}
drupal_set_message($message, 'error');
// Check requirements
$requirements = module_invoke($module, 'requirements', 'install');
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
// Print any error messages
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$message = $requirement['description'];
if (isset($requirement['value']) && $requirement['value']) {
$message .= ' (' . t('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
}
drupal_set_message($message, 'error');
}
return FALSE;
}
return FALSE;
}
return TRUE;
}
......
......@@ -99,8 +99,8 @@ public function resetImplementations() {
// $this->bootstrapCache->get() is more or less constant and reduced further when
// non-database caching backends are used, so there will be more significant
// gains when a large number of modules are installed or hooks invoked, since
// this can quickly lead to module_hook() being called several thousand times
// per request.
// this can quickly lead to Drupal::moduleHandler()->implementsHook() being
// called several thousand times per request.
parent::resetImplementations();
$this->bootstrapCache->set('module_implements', array());
$this->bootstrapCache->delete('hook_info');
......@@ -139,8 +139,8 @@ protected function getImplementationInfo($hook) {
// It is possible that a module removed a hook implementation without the
// implementations cache being rebuilt yet, so we check whether the
// function exists on each request to avoid undefined function errors.
// Since module_hook() may needlessly try to load the include file again,
// function_exists() is used directly here.
// Since Drupal::moduleHandler()->implementsHook() may needlessly try to
// load the include file again, function_exists() is used directly here.
if (!function_exists($module . '_' . $hook)) {
// Clear out the stale implementation from the cache and force a cache
// refresh to forget about no longer existing hook implementations.
......
......@@ -150,7 +150,7 @@ function field_help($path, $arg) {
sort($modules);
foreach ($modules as $module) {
$display = $info[$module]['name'];
if (module_hook($module, 'help')) {
if (Drupal::moduleHandler()->implementsHook($module, 'help')) {
$items['items'][] = l($display, 'admin/help/' . $module);
}
else {
......
......@@ -2521,7 +2521,7 @@ function node_modules_disabled($modules) {
// check whether a hook implementation function exists and do not invoke it.
// Node access also needs to be rebuilt if language module is disabled to
// remove any language-specific grants.
if (!node_access_needs_rebuild() && (module_hook($module, 'node_grants') || $module == 'language')) {
if (!node_access_needs_rebuild() && (Drupal::moduleHandler()->implementsHook($module, 'node_grants') || $module == 'language')) {
node_access_needs_rebuild(TRUE);
}
}
......
......@@ -1062,18 +1062,16 @@ function search_box_form_submit($form, &$form_state) {
* supplied or if the given search module is not active.
*/
function search_data($keys, $module, $conditions = NULL) {
if (module_hook($module, 'search_execute')) {
$results = module_invoke($module, 'search_execute', $keys, $conditions);
if (module_hook($module, 'search_page')) {
return module_invoke($module, 'search_page', $results);
}
else {
return array(
'#theme' => 'search_results',
'#results' => $results,
'#module' => $module,
);
}
$results = module_invoke($module, 'search_execute', $keys, $conditions);
if (Drupal::moduleHandler()->implementsHook($module, 'search_page')) {
return module_invoke($module, 'search_page', $results);
}
else {
return array(
'#theme' => 'search_results',
'#results' => $results,
'#module' => $module,
);
}
}
......
......@@ -3158,7 +3158,7 @@ function system_get_module_admin_tasks($module, $info) {
}
// Append link for permissions.
if (module_hook($module, 'permission')) {
if (Drupal::moduleHandler()->implementsHook($module, 'permission')) {
$item = menu_get_item('admin/people/permissions');
if (!empty($item['access'])) {
$item['link_path'] = $item['href'];
......
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