Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.2.0dev1

Bug #18955 Error on sorting array
Submitted: 2011-11-04 21:01 UTC
From: mperrin Assigned:
Status: Verified Package: Structures_DataGrid_DataSource_Array (version 0.2.0dev1)
PHP Version: 5.3.1 OS: Linux Debian 6.0
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 14 - 14 = ?

 
 [2011-11-04 21:01 UTC] mperrin (Mathieu Perrin)
Description: ------------ When using Datagrid with Array renderer on PHP 5.3 o greater, we've got the following error. This error is due to a modifcation in array_multisort function in PHP 5.3 (http://au.php.net/manual/fr/function.array-multisort.php#95754). Fix it with the following code from line 222: $args[] =& $column; $d = (strtoupper($dir) == 'ASC') ? SORT_ASC : SORT_DESC; $args[] =& $d; Test script: --------------- $datagrid = new Structures_DataGrid(10); $datagrid->setDefaultSort(array('date' => 'DESC')); $datagrid->bind($data); $datagrid->addColumn(new Structures_DataGrid_Column('Id', 'id_entretien_courant', 'id_entretien_courant')); $datagrid->getOutput(); Actual result: -------------- Parameter 1 to array_multisort() expected to be a reference, value given in /usr/share/php/Structures/DataGrid/DataSource/Array.php on line 228

Comments

 [2011-12-27 11:35 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Verified
 [2013-01-18 17:22 UTC] cristiano_caruso (Cristiano Caruso)
A workaround could be replace call_user_function with direct call to array_multisor. This is how I do: file /usr/share/php/Structures/DataGrid/DataSource/Array.php on line 228 //call_user_func_array('array_multisort', $args); $keys = $args[0]; $sort_direction = $args[1]; $data_array = $args[2]; array_multisort(&$keys, $sort_direction, &$data_array); $args[0]=$keys; $args[1]=$sort_direction; $args[2]=$data_array; It's dirty but works.