Commit 93b4e1c4 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#203846 by pwolanin and jvandyk: PHP 4 does not allow omitting an object when...

#203846 by pwolanin and jvandyk: PHP 4 does not allow omitting an object when it is passed by reference, so we need to live with dummy object passing with actions for object-less actions to support PHP 4
parent af16eb80
......@@ -11,11 +11,9 @@
*
* Given the IDs of actions to perform, find out what the callbacks
* for the actions are by querying the database. Then call each callback
* using the function call $function('do', $object, $context, $a1, $2)
* using the function call $function($object, $context, $a1, $2)
* where $function is the name of a function written in compliance with
* the action specification; that is, foo($object, $context). The $params
* parameter is an array of stored parameters that have been previously
* configured through the web using actions.module.
* the action specification; that is, foo($object, $context).
*
* @param $action_ids
* The ID of the action to perform. Can be a single action ID or an array
......@@ -24,6 +22,8 @@
* @param $object
* Parameter that will be passed along to the callback. Typically the
* object that the action will act on; a node, user or comment object.
* If the action does not act on an object, pass a dummy object. This
* is necessary to support PHP 4 object referencing.
* @param $context
* Parameter that will be passed along to the callback. $context is a
* keyed array containing extra information about what is currently
......@@ -39,7 +39,7 @@
* An associative array containing the result of the function that
* performs the action, keyed on action ID.
*/
function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a2 = NULL) {
function actions_do($action_ids, &$object, $context = NULL, $a1 = NULL, $a2 = NULL) {
static $stack;
$stack++;
if ($stack > variable_get('actions_max_stack', 35)) {
......
......@@ -206,7 +206,7 @@ function _trigger_normalize_node_context($type, $node) {
/**
* Implementation of hook_nodeapi().
*/
function trigger_nodeapi($node, $op, $a3, $a4) {
function trigger_nodeapi(&$node, $op, $a3, $a4) {
// Keep objects for reuse so that changes actions make to objects can persist.
static $objects;
// Prevent recursion by tracking which operations have already been called.
......@@ -299,7 +299,8 @@ function trigger_comment($a1, $op) {
actions_do($aid, $objects[$action_info['type']], $context);
}
else {
actions_do($aid, (object) $a1, $context);
$comment = (object) $a1;
actions_do($aid, $comment, $context);
}
}
}
......@@ -392,7 +393,8 @@ function trigger_taxonomy($op, $type, $array) {
'op' => $op
);
foreach ($aids as $aid => $action_info) {
actions_do($aid, (object) $array, $context);
$taxonomy_object = (object) $array;
actions_do($aid, $taxonomy_object, $context);
}
}
......
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