Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31806

Course tags block causes errors on oracle

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2, 2.3
    • Fix Version/s: 2.1.5, 2.2.2
    • Component/s: Tags
    • Labels:
    • Environment:
      Linux
    • Database:
      Oracle
    • Testing Instructions:
      Hide

      Steps to reproduce:
      1) Go to Admin > Plugins > Blocks > Tags and enable 'show course tags'
      2) Navigate to course home page
      4) Add tag block to course
      5) Refresh the page

      Expected result:
      Tag block displayed and no errors

      Actual result:
      DB Error ORA-00918 - column ambigiously defined

      Show
      Steps to reproduce: 1) Go to Admin > Plugins > Blocks > Tags and enable 'show course tags' 2) Navigate to course home page 4) Add tag block to course 5) Refresh the page Expected result: Tag block displayed and no errors Actual result: DB Error ORA-00918 - column ambigiously defined
    • Workaround:
      Hide

      Issue is to be in the following query

      File => /tag/coursetaglib.php
      Function => coursetag_get_all_tags()

      Query=>

      SELECT id, name, id, tagtype, rawname, f.timemodified, flag, count
      FROM e_tag t,
      (SELECT tagid, MAX(timemodified) as timemodified, COUNT(id) as count
      FROM e_tag_instance WHERE tagid NOT IN
      (SELECT tagid FROM e_tag_instance ti, e_course c
      WHERE c.visible = 0
      AND ti.itemtype = 'course'
      AND ti.itemid = c.id)
      GROUP BY tagid) f
      WHERE t.id = f.tagid
      ORDER BY count DESC, name ASC

      Oracle does not allow same name in select query (SELECT id, name, id) so place an alias for one of the id say

      SELECT id as t_id, name, id, tagtype, rawname, f.timemodified, flag, count
      FROM e_tag t,
      (SELECT tagid, MAX(timemodified) as timemodified, COUNT(id) as count
      FROM e_tag_instance WHERE tagid NOT IN
      (SELECT tagid FROM e_tag_instance ti, e_course c
      WHERE c.visible = 0
      AND ti.itemtype = 'course'
      AND ti.itemid = c.id)
      GROUP BY tagid) f
      WHERE t.id = f.tagid
      ORDER BY count DESC, name ASC

      Show
      Issue is to be in the following query File => /tag/coursetaglib.php Function => coursetag_get_all_tags() Query=> SELECT id, name, id, tagtype, rawname, f.timemodified, flag, count FROM e_tag t, (SELECT tagid, MAX(timemodified) as timemodified, COUNT(id) as count FROM e_tag_instance WHERE tagid NOT IN (SELECT tagid FROM e_tag_instance ti, e_course c WHERE c.visible = 0 AND ti.itemtype = 'course' AND ti.itemid = c.id) GROUP BY tagid) f WHERE t.id = f.tagid ORDER BY count DESC, name ASC Oracle does not allow same name in select query (SELECT id, name, id) so place an alias for one of the id say SELECT id as t_id, name, id, tagtype, rawname, f.timemodified, flag, count FROM e_tag t, (SELECT tagid, MAX(timemodified) as timemodified, COUNT(id) as count FROM e_tag_instance WHERE tagid NOT IN (SELECT tagid FROM e_tag_instance ti, e_course c WHERE c.visible = 0 AND ti.itemtype = 'course' AND ti.itemid = c.id) GROUP BY tagid) f WHERE t.id = f.tagid ORDER BY count DESC, name ASC
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-31806-master

      Description

      When a teacher tries to click "Enrolled users" link under course administration then the page displays "Error reading from database" if a tag block is added with course tags enabled.

      • line 125 of /tag/coursetagslib.php: call to oci_native_moodle_database->get_records_sql()
      • line 115 of /blocks/tags/block_tags.php: call to coursetag_get_all_tags()
      • line 280 of /blocks/moodleblock.class.php: call to block_tags->get_content()
      • line 232 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
      • line 926 of /lib/blocklib.php: call to block_base->get_content_for_output()
      • line 978 of /lib/blocklib.php: call to block_manager->create_block_contents()
      • line 349 of /lib/blocklib.php: call to block_manager->ensure_content_created()

      SELECT id, name, id, tagtype, rawname, f.timemodified, flag, count
      FROM e_tag t,
      (SELECT tagid, MAX(timemodified) as timemodified, COUNT(id) as count
      FROM e_tag_instance WHERE tagid NOT IN
      (SELECT tagid FROM e_tag_instance ti, e_course c
      WHERE c.visible = 0
      AND ti.itemtype = 'course'
      AND ti.itemid = c.id)
      GROUP BY tagid) f
      WHERE t.id = f.tagid
      ORDER BY count DESC, name ASC

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Mar/12