summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2008-11-15 11:45:04 (GMT)
committerDries Buytaert2008-11-15 11:45:04 (GMT)
commit97fdc491917f6f12d734cb13bf2101cfc12096fd (patch)
tree6705139d65bdbbfd0c7ccb7c59f9442bd6a5cd7d
parent10104ba94ac7a70b2be3594cb769034582533e1f (diff)
- Patch #334030 by justinrandell: replace module_list with module_implements when calling a hook.
-rw-r--r--includes/menu.inc21
-rw-r--r--modules/comment/comment.module4
-rw-r--r--modules/filter/filter.module5
-rw-r--r--modules/node/node.module4
-rw-r--r--modules/search/search.admin.inc11
-rw-r--r--modules/search/search.module15
-rw-r--r--modules/user/user.module16
7 files changed, 38 insertions, 38 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index 2cd6207..bba9391 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -1220,17 +1220,16 @@ function menu_get_active_help() {
$arg = drupal_help_arg(arg(NULL));
$empty_arg = drupal_help_arg();
- foreach (module_list() as $name) {
- if (module_hook($name, 'help')) {
- // Lookup help for this path.
- if ($help = module_invoke($name, 'help', $router_path, $arg)) {
- $output .= $help . "\n";
- }
- // Add "more help" link on admin pages if the module provides a
- // standalone help page.
- if ($arg[0] == "admin" && module_exists('help') && module_invoke($name, 'help', 'admin/help#' . $arg[2], $empty_arg) && $help) {
- $output .= theme("more_help_link", url('admin/help/' . $arg[2]));
- }
+ foreach (module_implements('help') as $module) {
+ $function = $module . '_help';
+ // Lookup help for this path.
+ if ($help = $function($router_path, $arg)) {
+ $output .= $help . "\n";
+ }
+ // Add "more help" link on admin pages if the module provides a
+ // standalone help page.
+ if ($arg[0] == "admin" && module_exists('help') && $function('admin/help#' . $arg[2], $empty_arg) && $help) {
+ $output .= theme("more_help_link", url('admin/help/' . $arg[2]));
}
}
return $output;
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 055e30f..c8573d7 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -1945,8 +1945,8 @@ function _comment_update_node_statistics($nid) {
*/
function comment_invoke_comment(&$comment, $op) {
$return = array();
- foreach (module_implements('comment') as $name) {
- $function = $name . '_comment';
+ foreach (module_implements('comment') as $module) {
+ $function = $module . '_comment';
$result = $function($comment, $op);
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index e2e2a20..f77f539 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -326,8 +326,9 @@ function filter_formats($index = NULL) {
function filter_list_all() {
$filters = array();
- foreach (module_list() as $module) {
- $list = module_invoke($module, 'filter', 'list');
+ foreach (module_implements('filter') as $module) {
+ $function = $module . '_filter';
+ $list = $function('list');
if (isset($list) && is_array($list)) {
foreach ($list as $delta => $name) {
$filters[$module . '/' . $delta] = (object)array('module' => $module, 'delta' => $delta, 'name' => $name);
diff --git a/modules/node/node.module b/modules/node/node.module
index 8c8ecd4..b64dbde 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -716,8 +716,8 @@ function node_invoke(&$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
$return = array();
$hook = 'nodeapi_' . $op;
- foreach (module_implements($hook) as $name) {
- $function = $name . '_' . $hook;
+ foreach (module_implements($hook) as $module) {
+ $function = $module . '_' . $hook;
$result = $function($node, $a3, $a4);
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
diff --git a/modules/search/search.admin.inc b/modules/search/search.admin.inc
index f02ce7d..c1a8eb0 100644
--- a/modules/search/search.admin.inc
+++ b/modules/search/search.admin.inc
@@ -37,12 +37,11 @@ function search_admin_settings() {
// Collect some stats
$remaining = 0;
$total = 0;
- foreach (module_list() as $module) {
- if (module_hook($module, 'search')) {
- $status = module_invoke($module, 'search', 'status');
- $remaining += $status['remaining'];
- $total += $status['total'];
- }
+ foreach (module_implements('search') as $module) {
+ $function = $module . '_search';
+ $status = $function('status');
+ $remaining += $status['remaining'];
+ $total += $status['total'];
}
$count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
$percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) . '%';
diff --git a/modules/search/search.module b/modules/search/search.module
index 924795d..7972549 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -208,14 +208,14 @@ function search_menu() {
'file path' => drupal_get_path('module', 'dblog'),
);
- foreach (module_implements('search') as $name) {
- $items['search/' . $name . '/%menu_tail'] = array(
+ foreach (module_implements('search') as $module) {
+ $items['search/' . $module . '/%menu_tail'] = array(
'title callback' => 'module_invoke',
- 'title arguments' => array($name, 'search', 'name', TRUE),
+ 'title arguments' => array($module, 'search', 'name', TRUE),
'page callback' => 'search_view',
- 'page arguments' => array($name),
+ 'page arguments' => array($module),
'access callback' => '_search_menu',
- 'access arguments' => array($name),
+ 'access arguments' => array($module),
'type' => MENU_LOCAL_TASK,
'parent' => 'search',
);
@@ -277,8 +277,9 @@ function search_cron() {
register_shutdown_function('search_update_totals');
// Update word index
- foreach (module_list() as $module) {
- module_invoke($module, 'update_index');
+ foreach (module_implements('update_index') as $module) {
+ $function = $module . '_update_index';
+ $function();
}
}
diff --git a/modules/user/user.module b/modules/user/user.module
index 224d44d..f1a8593 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -23,11 +23,9 @@ define('EMAIL_MAX_LENGTH', 64);
* be passed by reference.
*/
function user_module_invoke($type, &$array, &$user, $category = NULL) {
- foreach (module_list() as $module) {
+ foreach (module_implements('user_' . $type) as $module) {
$function = $module . '_user_' . $type;
- if (function_exists($function)) {
- $function($array, $user, $category);
- }
+ $function($array, $user, $category);
}
}
@@ -1952,8 +1950,9 @@ function user_filters() {
}
$options = array();
- foreach (module_list() as $module) {
- if ($permissions = module_invoke($module, 'perm')) {
+ foreach (module_implements('perm') as $module) {
+ $function = $module . '_perm';
+ if ($permissions = $function('perm')) {
asort($permissions);
foreach ($permissions as $permission => $description) {
$options[t('@module module', array('@module' => $module))][$permission] = t($permission);
@@ -2437,8 +2436,9 @@ function user_register_validate($form, &$form_state) {
*/
function _user_forms(&$edit, $account, $category, $hook = 'form') {
$groups = array();
- foreach (module_list() as $module) {
- if ($data = module_invoke($module, 'user_' . $hook, $edit, $account, $category)) {
+ foreach (module_implements('user_' . $hook) as $module) {
+ $function = $module . '_user_' . $hook;
+ if ($data = $function($edit, $account, $category)) {
$groups = array_merge_recursive($data, $groups);
}
}