Moodle

Correlation tags SQL is missing one condition....

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor 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

Activity

Hide
Mathieu Petit-Clair added a comment -

This is now fixed.

Show
Mathieu Petit-Clair added a comment - This is now fixed.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: