2

I'm new to PHP, how do I need to change the string data? looked through a lot of topics, but could not fix it, not enough knowledge

PHP Strict Standards: Only variables should be passed by reference in /var/www/html/lib/event.lib on line 309

    function event_conf() {
    global $session_user,$session;
    $event_artikul_ids = get_hash(event_area_list(array('area_id' => $session_user['area_id']),'','artikul_id'),'artikul_id','artikul_id');
    if (!$event_artikul_ids) return '';
    $event_artikul_ids = get_hash(event_artikul_list(array('id' => $event_artikul_ids),sql_pholder(" AND ((kind = 0) OR (kind = ?)) AND !(flags & ?)",$session_user['kind'], EVENT_FLAG_NO_NOTIFY),'id'),'id','id');
    if (!$event_artikul_ids) return '';
//Line 309
    $event = reset(event_list(array('artikul_id' => $event_artikul_ids), ' AND point_id > 0'));
    if (!$event) return '';
    if (event_track_user_list(array('user_id' => $session_user['id'],'event_id' => $event['artikul_id']), sql_pholder(' AND flags & ?', EVENT_TRACK_USERS_FLAG_HIDE))) return '';
    $event_artikul = event_artikul_get($event['artikul_id']);
    $event_point = event_point_get($event['point_id']);
    $event_point_tasks = make_hash(event_point_task_list(array('point_id' => $event['point_id']),' ORDER BY id'));
    if (!$event_point_tasks) return '';
    $event_point_task_user_hash = get_hash(event_point_task_user_list(array('artikul_id' => $event['artikul_id'], 'user_id' => $session_user['id'])),'task_id','value');
    $event_point_task_value_hash = get_hash(event_point_task_user_list(array('artikul_id' => $event['artikul_id']),' GROUP BY 1','task_id,SUM(value) as value'),'task_id','value');

    $params = array();

PHP Strict Standards: Only variables should be passed by reference in /var/www/html/tpl/rating.tpl on line 155

foreach ($rating_stat as $stat_type => $data_list) {
                    //Line 155
                    echo html_rating_div_str(array_slice($data_list, 0, 10), $users_data, " ID=\"$stat_type" . "_all\" style=\"$style_display\"");
                    $style_display = "display: none;"; // Only first div will be visible
                    $data_kind_list = make_hash($data_list, 'kind', true);

Strict Standards: Only variables should be passed by reference in /var/www/html/user.php on line 87

            if ($mode == 'personage') {
                $group = htmlspecialchars(strval($_REQUEST['group']));
 //Line 87 
                if (!$user_backpack_groups[$group]) $group = reset(array_keys($user_backpack_groups));
                $mode_url .= '&group='.$group;

Please help, tell me how to fix these errors. PHP 5.4.45

DancerS
  • 23
  • 1
  • 4

1 Answers1

4

This error happens because some functions not only return values but also (try to) change passed parameters (these params need to be passed by reference, because otherwise their value would be copied and there would be no effect outside function scope).

For example reset() returns first element, but also changes internal array pointer (current elemtent). If you pass an array not assigned to any variable (direct result of the function call) the pointer cannot be set, because this array in outer scope doesn't longer exist. To fix line 309 you need to split command into variable assignment and then pass it to reset function:

$event_list = event_list(array('artikul_id' => $event_artikul_ids), ' AND point_id > 0');
$event = reset($event_list);

Same error in line 87 (needs if with braces though).

The problem in line 155 is caused by html_rating_div_str() function. For some reason it also requires reference - its definition might look like:

function html_rating_div_str(&$array, $users_data, $string) {...}

...with & before one of the variables. The referenced parameter should be changed to variable first, and then passed to this function.

shudder
  • 2,076
  • 2
  • 20
  • 21