0
votes

Strict Standards: Only variables should be passed by reference in /home/zumpu/public_html/cats/cats-0.8.0/lib/DataGrid.php on line 1519

Strict Standards: Only variables should be passed by reference in /home/zumpu/public_html/cats/cats-0.8.0/lib/DataGrid.php on line 1535

if ($sizable)
            {
                $formatString = '<th align="left" class="resizeableCell" '
                    . 'style="width:5px; border-collapse: collapse; '
                    . '-moz-user-select: none; -khtml-user-select: none;';

               if (end(array_keys($this->_currentColumns)) != $index) //line 1519
               {
                   //Uncomment for gray resize bars
                   $formatString .= 'border-right:1px solid gray;';
               }

                $formatString .=
                      'user-select: none;" onmouseover="style.cursor = '
                    . '\'e-resize\'" onmousedown="startResize(\'cell%s%s\', '
                    . '\'table%s\', \'cell%s%s\', %s, \'%s\', \'%s\', '
                    . '\'%s\', \'%s\', this.offsetWidth);">';

                echo sprintf(
                    $formatString,
                    $md5InstanceName, $index,
                    $md5InstanceName,
                    $md5InstanceName, end(array_keys($this->_currentColumns)),// line 1535
                    $this->_tableWidth,
                    urlencode($this->_instanceName),
                    $_SESSION['CATS']->getCookie(),
                    $data['name'],
                    implode(',', $cellIndexes)
                );

                echo '<div class="dataGridResizeAreaInnerDiv"></div></th>', "\n";
            }
        }

help me out i a stuck for 2 days

2
$indexes = array_keys($this->_currentColumns); if (end($indexes) != $index)...Mark Baker
from the docs php.net/end - end ( array &$array ) -> The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference. Must pass a variable to end(), not a function, ie. array_keys().Sean

2 Answers

0
votes

Strictly speaking you're not supposed to pass the return value of a function directly to another function that takes its arguments as a reference without first assigning it to a named variable.

It usually works anyway, and probably won't break, [until a PHP version change breaks it] but because of those reasons it generates an E_STRICT message.

This should remove the message, but preserve the current functionality:

            $keys = array_keys($this->_currentColumns);

            if (end($keys)) != $index) //line 1519

            /* ... */

            echo sprintf(
                $formatString,
                $md5InstanceName, $index,
                $md5InstanceName,
                $md5InstanceName, end($keys),// line 1535
                $this->_tableWidth,
                urlencode($this->_instanceName),
                $_SESSION['CATS']->getCookie(),
                $data['name'],
                implode(',', $cellIndexes)
            );
0
votes

Try -

$keys = array_keys($this->_currentColumns);
if (end($keys) != $index){

and

$md5InstanceName, end($keys),

from the docs http://php.net/end -
end ( array &$array ) -> The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference. Must pass a variable to end(), not a function, ie. array_keys().