From a23669936799d3b42c63707fdd9933fbb1d54bcf Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 29 Apr 2015 10:52:49 +0800 Subject: [PATCH] MDL-25138 core_tag: fix correlated tags query unique error --- tag/lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tag/lib.php b/tag/lib.php index e5c4cccda0b..93023aae661 100644 --- a/tag/lib.php +++ b/tag/lib.php @@ -1384,10 +1384,11 @@ function tag_get_correlated($tag_id, $limitnum=null) { } // this is (and has to) return the same fields as the query in tag_get_tags - $sql = "SELECT DISTINCT tg.id, tg.tagtype, tg.name, tg.rawname, tg.flag, ti.ordering + $sql = "SELECT ti.id AS taginstanceid, tg.id, tg.tagtype, tg.name, tg.rawname, tg.flag, ti.ordering FROM {tag} tg INNER JOIN {tag_instance} ti ON tg.id = ti.tagid - WHERE tg.id IN ({$tag_correlation->correlatedtags})"; + WHERE tg.id IN ({$tag_correlation->correlatedtags}) + ORDER BY ti.ordering ASC"; $result = $DB->get_records_sql($sql); if (!$result) { return array();