ZF-8071: error in function "find" with multiple sort fields


This are line 974 to 989 in Lucene.php, in function "find":

            $valuesArray = array();
            foreach ($hits as $hit) {
                try {
                    $value = $hit->getDocument()->getFieldValue($fieldName);
                } catch (Zend_Search_Lucene_Exception $e) {
                    if (strpos($e->getMessage(), 'not found') === false) {
                        throw $e;
                    } else {
                        $value = null;

                $valuesArray[] = $value;

$sortArgs[] = &$valuesArray;

If multiple sort fields are supplied, like this:

$index->find($query, 'title', SORT_STRING, SORT_DESC, 'offer_id', SORT_NUMERIC, SORT_ASC, 'language_id', SORT_NUMERIC, SORT_ASC);

the $sortArgs array ends up having the $valuesArray of the second sort field twice.

This is because the $valuesArray is not unset but just it's content changes. So the same reference get's assigned twice.


            $sortArgs[] = &$valuesArray;


Best regards, Anton


Fixed. Thanks for the report and solution!