summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-15 11:45:04 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-15 11:45:04 +0000
commit97fdc491917f6f12d734cb13bf2101cfc12096fd (patch)
tree6705139d65bdbbfd0c7ccb7c59f9442bd6a5cd7d /modules
parent10104ba94ac7a70b2be3594cb769034582533e1f (diff)
downloadbrdo-97fdc491917f6f12d734cb13bf2101cfc12096fd.tar.gz
brdo-97fdc491917f6f12d734cb13bf2101cfc12096fd.tar.bz2
- Patch #334030 by justinrandell: replace module_list with module_implements when calling a hook.
Diffstat (limited to 'modules')
-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
6 files changed, 28 insertions, 27 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 055e30f92..c8573d7c0 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 e2e2a20f1..f77f5399c 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 8c8ecd48a..b64dbdebf 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 f02ce7dfc..c1a8eb0ef 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 924795dd3..797254982 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 224d44d41..f1a8593b7 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);
}
}