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

Missing colon in query placeholder causes performance issues.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3.5, 3.3.6
    • Fix Version/s: 3.4.5, 3.5.2
    • Component/s: Tags
    • Labels:
    • Testing Instructions:
      Hide

      Covered by a phpunit test.

       

      In case you're interested on testing it manually, you can follow these steps:

      1. Add several tags, for example in your Profile > Edit profile > Interests
      2. Create course within any category
      3. Create two book resources within the course and add tags to each of them in their create/edit chapter form page (the first page you see when you create a new book) > Tags section
      4. Backup the course
      5. Import the course, for example as a new course within the same category
      6. Access your instance database and read the table tag_instance, verify that the ordering column starts from 1 when the component, itemtype, itemid columns change (this is if you have a fresh installation; otherwise, check that after installing the patch, the ordering field is increasing the value depending on the itemid). For example: the user tags have to have an ordering 1, 2, 3... The first book tags with ordering 1, 2, 3... and the other book tags with ordering 1, 2, 3... and so on.
      Show
      Covered by a phpunit test.   In case you're interested on testing it manually, you can follow these steps: Add several tags, for example in your Profile > Edit profile > Interests Create course within any category Create two book resources within the course and add tags to each of them in their create/edit chapter form page (the first page you see when you create a new book) > Tags section Backup the course Import the course, for example as a new course within the same category Access your instance database and read the table tag_instance, verify that the ordering column starts from 1 when the component, itemtype, itemid columns change (this is if you have a fresh installation; otherwise, check that after installing the patch, the ordering field is increasing the value depending on the itemid). For example: the user tags have to have an ordering 1, 2, 3... The first book tags with ordering 1, 2, 3... and the other book tags with ordering 1, 2, 3... and so on.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
      MDL-62867-35-missing_colon_in_query
    • Pull Master Branch:
      MDL-62867-missing_colon_in_query

      Description

      A missing colon in query placeholder in the function "add_item_tag" of "core_tag_tag" class causes performance issues in sites with a lot of tags when create or restore a backup with tags.

      In this query, the itemid must have a colon.

       

      $ordering = $DB->get_field_sql('SELECT MAX(ordering) FROM {tag_instance} ti
              WHERE ti.itemtype = :itemtype AND ti.itemid = itemid AND
              ti.component = :component' . $usersql, $params);
      

       

      They should be:

       

      $ordering = $DB->get_field_sql('SELECT MAX(ordering) FROM {tag_instance} ti
              WHERE ti.itemtype = :itemtype AND ti.itemid = :itemid AND
              ti.component = :component' . $usersql, $params);
      

       

       

        Attachments

          Activity

            People

            Assignee:
            bitumin Mitxel Moriana
            Reporter:
            albertolarah Alberto Lara Hernández
            Peer reviewer:
            Sara Arjona (@sarjona)
            Integrator:
            David Monllaó
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              10/Sep/18

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 42 minutes
                42m