Unknown named parameter $data in services_rules_component_callback

Created on 9 November 2024, 12 days ago

On a machine with php 8 I see an error:

Error: Unknown named parameter $data in services_rules_component_callback() (line 84 of .../sites/all/modules/services_rules/services_rules.module).

...had to modify the services_rules_component_callback to make it work - see below. I would create a patch, but drupalcode would not allow me to fork the repo, so here we go.

function services_rules_component_callback($component_info) {
    $args = isset($component_info['args']) ? $component_info['args'] : array();

    // Fix: Convert associative array to numeric array while preserving values
    if (!empty($args)) {
        $numeric_args = array();
        // First add any existing numeric keys
        foreach ($args as $key => $value) {
            if (is_numeric($key)) {
                $numeric_args[$key] = $value;
            }
        }
        // Then append associative elements as sequential values
        foreach ($args as $key => $value) {
            if (!is_numeric($key)) {
                $numeric_args[] = $value;
            }
        }
        $args = array_values($numeric_args); // Reset keys to be sequential
    }

    array_unshift($args, $component_info['name']);
    watchdog('module','services_rules ' . print_r($args,1));

    $result = call_user_func_array('rules_invoke_component', $args);

    if ($result === FALSE) {
        return FALSE;
    }

    $component = rules_get_cache('comp_' . $component_info['name']);
    $i = 0;
    foreach($component->providesVariables() as $name => $val) {
        $result[$name] = $result[$i];
        unset($result[$i]);
        $i++;
    }
    return $result;
}
πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia sano

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024