Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-13404 Improve tagging system
  3. MDL-12898

Correlation tags SQL is missing one condition....

    XMLWordPrintable

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9, 2.0
    • 1.9, 2.0
    • Tags
    • None
    • Any
    • MOODLE_19_STABLE, MOODLE_20_STABLE
    • MOODLE_19_STABLE, MOODLE_20_STABLE

    Description

      I was looking code due to MDL-12897 when, in cache_correlated_tags(), this query:

      $query = "SELECT tb.tagid , COUNT nr
      FROM {$CFG->prefix}tag_instance ta
      INNER JOIN {$CFG->prefix}tag_instance tb ON ta.itemid = tb.itemid
      WHERE ta.tagid = {$tag_id}
      GROUP BY tb.tagid
      ORDER BY nr DESC";

      seems to be missing one extra condition, in order to compare only same itemtype tags (or else we'll be counting unrelated items), so this join seems necessary:

      INNER JOIN {$CFG->prefix}tag_instance tb ON ta.itemid = tb.itemid AND ta.itemtype = tb.itemtype

      instead of the current one.

      Ciao

      Attachments

        Activity

          People

            scyrma Mathieu Petit-Clair
            stronk7 Eloy Lafuente (stronk7)
            David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              3/Mar/08