You are here: Foswiki>Tasks Web>Item12618 (08 Jul 2015, MichaelDaum)Edit Attach

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
Applies To: Engine
Component: PlatformPerl518, SEARCH
Branches: trunk
Reported By: GeorgeClark
Waiting For:
Last Change By: MichaelDaum
The Fn_SEARCH::topicOrder tests give very inconsistent results on Perl 5.18.1.

It's specifically the following two tests:

    $result =
      $this->{test_topicObject}->expandMacros( $search . 'order="modified"}%' );


    $result =
        $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

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

ItemTemplate edit

Summary Search ordering is not predictable on Perl 5.18.1 and later
ReportedBy GeorgeClark
Codebase 1.1.8
SVN Range
AppliesTo Engine
Component PlatformPerl518, SEARCH
Priority Urgent
CurrentState Closed
Checkins distro:930a5d3957d7
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches trunk
trunkCheckins distro:930a5d3957d7
Topic revision: r11 - 08 Jul 2015, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy