From c64e7ad2d7396bf1ad20753317db4e01e6103d34 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 20 May 2016 09:27:37 +1200 Subject: [PATCH] Consistent sorting for getDiffList() If changes were applied in the same second (e.g. through tests), the results will have an indeterminate order. This lead to stability issues in VersionFeedFunctionalTest::testContainsChangesForPageOnly. Sort by ID in addition to LastEdited. --- code/VersionFeed.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/VersionFeed.php b/code/VersionFeed.php index 995b1a1..63f52b1 100644 --- a/code/VersionFeed.php +++ b/code/VersionFeed.php @@ -61,7 +61,9 @@ class VersionFeed extends SiteTreeExtension { // Get just enough elements for diffing. We need one more than desired to have something to compare to. $qLimit = (int)$limit + 1; $versions = $this->owner->allVersions( - "\"WasPublished\"='1' AND \"CanViewType\" IN ('Anyone', 'Inherit') $offset", "\"LastEdited\" DESC", $qLimit + "\"WasPublished\"='1' AND \"CanViewType\" IN ('Anyone', 'Inherit') $offset", + "\"SiteTree\".\"LastEdited\" DESC, \"SiteTree\".\"ID\" DESC", + $qLimit ); // Process the list to add the comparisons.