From 0288333c0bc08aa70df4fff725bb59d2010a8603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Massart?= Date: Thu, 19 Apr 2018 16:05:12 +0800 Subject: [PATCH 1/2] MDL-61836 core_blog: Prevent randomness in comments order --- blog/classes/privacy/provider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/classes/privacy/provider.php b/blog/classes/privacy/provider.php index 7ec3696ea569b..6c585862a26b4 100644 --- a/blog/classes/privacy/provider.php +++ b/blog/classes/privacy/provider.php @@ -212,7 +212,7 @@ public static function export_user_data(approved_contextlist $contextlist) { // Loop over each blog entry in context. $sql = "userid = :userid AND module IN (:blog, :blogext) AND id $insql"; $params = array_merge($inparams, ['userid' => $contextuserid, 'blog' => 'blog', 'blogext' => 'blog_external']); - $recordset = $DB->get_recordset_select('post', $sql, $params); + $recordset = $DB->get_recordset_select('post', $sql, $params, 'id'); foreach ($recordset as $record) { $subject = format_string($record->subject); From 707200943177d10d6bcdf36134beb00f59ba0706 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 20 Apr 2018 08:49:00 +0800 Subject: [PATCH 2/2] MDL-61836 blog: Fix random order failures --- blog/tests/privacy_test.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/blog/tests/privacy_test.php b/blog/tests/privacy_test.php index 65f772ad36227..6ab6c686b04fc 100644 --- a/blog/tests/privacy_test.php +++ b/blog/tests/privacy_test.php @@ -594,8 +594,17 @@ public function test_export_data_for_user() { $comments = $writer->get_data($commentpath); $this->assertCount(2, $comments->comments); - $this->assertEquals('Hello, it\'s me!', strip_tags($comments->comments[0]->content)); - $this->assertEquals('I was wondering if after', strip_tags($comments->comments[1]->content)); + + $c0 = strip_tags($comments->comments[0]->content); + $c1 = strip_tags($comments->comments[1]->content); + $expectedcomments = [ + 'Hello, it\'s me!', + 'I was wondering if after', + ]; + + $this->assertNotFalse(array_search($c0, $expectedcomments)); + $this->assertNotFalse(array_search($c1, $expectedcomments)); + $this->assertNotEquals($c0, $c1); } else { $tagdata = $writer->get_related_data($path, 'tags');