Item12618: Search ordering is not predictable on Perl 5.18.1 and later
Priority: Urgent
Current State: Closed
Released In: 2.0.0
Target Release: major
The Fn_SEARCH::topicOrder tests give very inconsistent results on Perl 5.18.1.
It's specifically the following two tests:
#order=modified
$result =
$this->{test_topicObject}->expandMacros( $search . 'order="modified"}%' );
$this->assert_str_equals(
"QueryTopicThree,QueryTopicTwo,QueryTopic,WebPreferences,TestTopicSEARCH,OkTopic,OkATopic,OkBTopic",
$result
);
$result =
$this->{test_topicObject}->expandMacros(
$search . 'order="modified" reverse="on" format="$topic"}%' );
#be very careful with this test and the one above - the change in order between QueryTopicTwo,QueryTopic is due to them having the same date, so its sorting by topicname
$this->assert_str_equals(
"OkBTopic,OkATopic,OkTopic,TestTopicSEARCH,WebPreferences,QueryTopicTwo,QueryTopic,QueryTopicThree",
$result
);
The comment says it all. The order of the two topics with the same date seem to exchange position. The assumption that there is a secondary sort ordering of Topic name does not appear to be true. And there is nothing in the
Foswiki::Search::InfoCache
code that I can find that would apply a secondary sort order.
Debug statements in
InfoCache shows that the raw list of files returned by the
ListIterator changes order for every %SEARCH execution. And the sort of the results set seems to assume that the topics were in topic name order.
Running on 5.16.1, the topic list is exactly the same for each run, and the resulting searches are consistent and all tests pass.
I'm making this a blocker, %SEARCH should return the same results for each search if everything else remains constant.
--
GeorgeClark - 29 Oct 2013
I can't find where this apparent randomization happens. Store eachTopic returns a sorted list of topic names, So how it becomes un-sorted ... That's for another day.
--
GeorgeClark - 29 Oct 2013
Defer to Foswiki 1.2
--
GeorgeClark - 05 Nov 2013
I don't have anything to add beyond what I discussed with George on IRC, so taking myself off the
WaitingFor and deferring to 1.2
--
CrawfordCurrie - 07 Nov 2013
Perl has changed by design: see
here (Hash Order Randomization)
--
OliverKrueger - 13 Mar 2014