From 25430f75d1609b01859c247a9d20fc0c91ed7d31 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 14 Jan 2016 13:19:12 +0800 Subject: [PATCH] MDL-50851 core_tag: fix db query failure on oracle --- blog/locallib.php | 2 +- tag/classes/area.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/blog/locallib.php b/blog/locallib.php index 5e31f8e440152..af1b72e77a361 100644 --- a/blog/locallib.php +++ b/blog/locallib.php @@ -631,7 +631,7 @@ public function get_entry_fetch_sql($count=false, $sort='lastmodified DESC', $us $allnamefields = \user_picture::fields('u', null, 'useridalias'); // The query used to locate blog entries is complicated. It will be built from the following components: - $requiredfields = "p.*, $allnamefields, u.email"; // The SELECT clause. + $requiredfields = "p.*, $allnamefields"; // The SELECT clause. $tables = array('p' => 'post', 'u' => 'user'); // Components of the FROM clause (table_id => table_name). // Components of the WHERE clause (conjunction). $conditions = array('u.deleted = 0', 'p.userid = u.id', '(p.module = \'blog\' OR p.module = \'blog_external\')'); diff --git a/tag/classes/area.php b/tag/classes/area.php index 49ed67e2f920c..f0853937b90bf 100644 --- a/tag/classes/area.php +++ b/tag/classes/area.php @@ -401,13 +401,15 @@ public static function move_tags($component, $itemtype, $tagcollid) { $result->close(); // Find all tags that are used for this itemtype/component and are not present in the target tag collection. - $sql = "SELECT DISTINCT t.id, t.name, t.rawname, t.description, t.descriptionformat, - t.userid, t.tagtype, t.flag + // This query is a little complicated because Oracle does not allow to run SELECT DISTINCT on CLOB fields. + $sql = "SELECT id, name, rawname, description, descriptionformat, userid, tagtype, flag + FROM {tag} WHERE id IN + (SELECT t.id FROM {tag_instance} ti JOIN {tag} t ON t.id = ti.tagid AND t.tagcollid <> :tagcollid1 LEFT JOIN {tag} tt ON tt.name = t.name AND tt.tagcollid = :tagcollid2 WHERE ti.itemtype = :itemtype2 AND ti.component = :component2 - AND tt.id IS NULL"; + AND tt.id IS NULL)"; $todelete = array(); $result = $DB->get_records_sql($sql, $params); foreach ($result as $tag) {