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

Some tag related queries (blog) should specify both itemtype and itemid

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9
    • Component/s: Blog
    • Labels:
      None
    • Environment:
      any
    • Database:
      Any
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      Since some hours ago tags (blog and user) have been unified. Cool.

      While I was writting MDL-11015 and MDL-11016, I've take a look to latest changes in blog code and it seems that there are a bunch of queries to tag_instance where only tag_instance->itemid is specified in the WHERE clauses. For example:

      if ($ptags = get_records_sql_menu("SELECT t.id, t.name FROM
      {$CFG->prefix}tag t,
      {$CFG->prefix}tag_instance ti
      WHERE t.id = ti.tagid
      AND t.tagtype = 'default'
      AND ti.itemid = {$post->id}")) {

      Although it's difficult to cause collisions by itemid (because the tagtype is different , I would suggest to ALWAYS to add the condition to as by itemtype and itemid...

      Also, although I don't know the API very well... perhaps something like get_item_tags() should be used instead of raw queries....

      Just one idea, ciao

        Attachments

          Activity

            People

            • Assignee:
              lazyfish Yu Zhang
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Tester:
              Nobody
              Participants:
              Component watchers:
              Adrian Greeve, Mihail Geshoski, Peter Dias
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

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