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

Issue Type: Bug Created: 2009-10-14T08:50:45.000+0000 Last Updated: 2009-10-16T14:32:21.000+0000 Status: Resolved Fix version(s): Reporter: Anton Stöckl (flytony) Assignee: Alexander Veremyev (alexander) Tags: - Zend_Search_Lucene

Related issues: Attachments:


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


Posted by Alexander Veremyev (alexander) on 2009-10-16T14:32:21.000+0000

Fixed. Thanks for the report and solution!

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.