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

Missing colon in query placeholder causes performance issues.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.3.5, 3.3.6
    • 3.4.5, 3.5.2
    • Tags
    • MOODLE_33_STABLE
    • MOODLE_34_STABLE, MOODLE_35_STABLE
    • MDL-62867-missing_colon_in_query
    • Easy
    • 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.

    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

            bitumin Mitxel Moriana
            albertolarah Alberto Lara Hernández
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            David Monllaó David Monllaó
            Janelle Barcega Janelle Barcega
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10/Sep/18

              Time Tracking

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