Mantis - Quercus
Viewing Issue Advanced Details
1459 major always 11-15-06 09:15 06-05-07 22:09
Anoop K Achuthan  
nam  
normal  
closed 3.0.21  
fixed  
none    
none 3.1.2  
0001459: php sort function doesn't work with objects as array elements
wordpress uses sort function to sort an array containing objects as elements.
Quercus throws the following exception :

-----------------------------------------------------------
java.lang.RuntimeException: not implemented
    at com.caucho.quercus.env.ObjectValue.cmpObject(ObjectValue.java:92)
    at com.caucho.quercus.env.Value.cmp(Value.java:213)
    at com.caucho.quercus.env.Value.lt(Value.java:239)
    at com.caucho.quercus.env.ArrayValue$ValueComparator.compare(ArrayValue.java:1276)
    at com.caucho.quercus.lib.ArrayModule$CompareNormal.compare(ArrayModule.java:3378)
    at com.caucho.quercus.lib.ArrayModule$CompareNormal.compare(ArrayModule.java:3353)
    at java.util.Arrays.mergeSort(Arrays.java:1284)
    at java.util.Arrays.sort(Arrays.java:1223)
    at com.caucho.quercus.env.ArrayValue.sort(ArrayValue.java:701)
    at com.caucho.quercus.lib.ArrayModule.sort(ArrayModule.java:1503)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.caucho.quercus.module.StaticFunction.invoke(StaticFunction.java:114)
    at com.caucho.quercus.env.JavaInvoker.call(JavaInvoker.java:529)
    at com.caucho.quercus.env.JavaInvoker.call(JavaInvoker.java:402)
    at com.caucho.quercus.env.JavaInvoker.call(JavaInvoker.java:388)
    at com.caucho.quercus.expr.FunctionExpr.evalImpl(FunctionExpr.java:181)
    at com.caucho.quercus.expr.FunctionExpr.eval(FunctionExpr.java:126)
    at com.caucho.quercus.program.ExprStatement.execute(ExprStatement.java:76)
    at com.caucho.quercus.program.BlockStatement.execute(BlockStatement.java:112)
    at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:246)
    at com.caucho.quercus.page.InterpretedPage.execute(InterpretedPage.java:71)
........
-----------------------------------------------------------------------
Sample program to reproduce the error:

<?php
$x1 = (object) "lemon";
$x2 = (object) "orange";
$fruits = array();
array_push($fruits,$x1,$x2);
sort($fruits);
foreach ($fruits as $key => $val) {
   echo "fruits[" . $key . "] = " . $val. "\n";
}
?>

Notes
(0002016)
nam   
06-05-07 22:09   
php/09n*