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

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9, 2.0
    • Fix Version/s: 1.9, 2.0
    • Component/s: Tags
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      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

            Assignee:
            scyrma Mathieu Petit-Clair
            Reporter:
            stronk7 Eloy Lafuente (stronk7)
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              3/Mar/08