summaryrefslogtreecommitdiff
path: root/modules/trigger
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-06-05 15:41:05 +0000
committerDries Buytaert <dries@buytaert.net>2009-06-05 15:41:05 +0000
commit41204a5a829d07a34305cf97a9a0bf3937b5ebb7 (patch)
tree0ca3e94db7cfbf964a6328b021662bdcf9c49dba /modules/trigger
parent5feda4e2a84a63353177629643393b8380f1fcb4 (diff)
downloadbrdo-41204a5a829d07a34305cf97a9a0bf3937b5ebb7.tar.gz
brdo-41204a5a829d07a34305cf97a9a0bf3937b5ebb7.tar.bz2
- Patch #476972 by andypost: optimizations for action_info array.
Diffstat (limited to 'modules/trigger')
-rw-r--r--modules/trigger/trigger.module44
1 files changed, 18 insertions, 26 deletions
diff --git a/modules/trigger/trigger.module b/modules/trigger/trigger.module
index 46d668ab2..68ef220c9 100644
--- a/modules/trigger/trigger.module
+++ b/modules/trigger/trigger.module
@@ -137,15 +137,10 @@ function trigger_access_check($module) {
* An array of action IDs.
*/
function _trigger_get_hook_aids($hook, $op = '') {
- $aids = array();
- $result = db_query("SELECT aa.aid, a.type FROM {trigger_assignments} aa LEFT JOIN {actions} a ON aa.aid = a.aid WHERE aa.hook = :hook AND aa.op = :op ORDER BY weight", array(
+ return db_query("SELECT ta.aid, a.type FROM {trigger_assignments} ta LEFT JOIN {actions} a ON ta.aid = a.aid WHERE ta.hook = :hook AND ta.op = :op ORDER BY ta.weight", array(
':hook' => $hook,
':op' => $op,
- ));
- foreach ($result as $action) {
- $aids[$action->aid]['type'] = $action->type;
- }
- return $aids;
+ ))->fetchAllKeyed();
}
/**
@@ -232,14 +227,14 @@ function _trigger_node($node, $op, $a3 = NULL, $a4 = NULL) {
// We need to get the expected object if the action's type is not 'node'.
// We keep the object in $objects so we can reuse it if we have multiple actions
// that make changes to an object.
- foreach ($aids as $aid => $action_info) {
- if ($action_info['type'] != 'node') {
- if (!isset($objects[$action_info['type']])) {
- $objects[$action_info['type']] = _trigger_normalize_node_context($action_info['type'], $node);
+ foreach ($aids as $aid => $type) {
+ if ($type != 'node') {
+ if (!isset($objects[$type])) {
+ $objects[$type] = _trigger_normalize_node_context($type, $node);
}
// Since we know about the node, we pass that info along to the action.
$context['node'] = $node;
- $result = actions_do($aid, $objects[$action_info['type']], $context, $a3, $a4);
+ $result = actions_do($aid, $objects[$type], $context, $a3, $a4);
}
else {
actions_do($aid, $node, $context, $a3, $a4);
@@ -356,15 +351,15 @@ function _trigger_comment($a1, $op) {
// We need to get the expected object if the action's type is not 'comment'.
// We keep the object in $objects so we can reuse it if we have multiple actions
// that make changes to an object.
- foreach ($aids as $aid => $action_info) {
- if ($action_info['type'] != 'comment') {
- if (!isset($objects[$action_info['type']])) {
- $objects[$action_info['type']] = _trigger_normalize_comment_context($action_info['type'], $a1);
+ foreach ($aids as $aid => $type) {
+ if ($type != 'comment') {
+ if (!isset($objects[$type])) {
+ $objects[$type] = _trigger_normalize_comment_context($type, $a1);
}
// Since we know about the comment, we pass it along to the action
// in case it wants to peek at it.
$context['comment'] = (object) $a1;
- actions_do($aid, $objects[$action_info['type']], $context);
+ actions_do($aid, $objects[$type], $context);
}
else {
$a1 = (object) $a1;
@@ -479,13 +474,13 @@ function _trigger_user($op, &$edit, &$account, $category = NULL) {
'op' => $op,
'form_values' => &$edit,
);
- foreach ($aids as $aid => $action_info) {
- if ($action_info['type'] != 'user') {
- if (!isset($objects[$action_info['type']])) {
- $objects[$action_info['type']] = _trigger_normalize_user_context($action_info['type'], $account);
+ foreach ($aids as $aid => $type) {
+ if ($type != 'user') {
+ if (!isset($objects[$type])) {
+ $objects[$type] = _trigger_normalize_user_context($type, $account);
}
$context['account'] = $account;
- actions_do($aid, $objects[$action_info['type']], $context);
+ actions_do($aid, $objects[$type], $context);
}
else {
actions_do($aid, $account, $context, $category);
@@ -505,10 +500,7 @@ function trigger_taxonomy($op, $type, $array) {
'hook' => 'taxonomy',
'op' => $op
);
- $_array = (object) $array;
- foreach ($aids as $aid => $action_info) {
- actions_do($aid, $_array, $context);
- }
+ actions_do(array_keys($aids), (object) $array, $context);
}
/**