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

Usertours sort order can be fooled in to being -1

    XMLWordPrintable

Details

    • MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • Hide

      Manual

      1. Navigate to Appearance > Users tours under Site administration
      2. Press Create a new tour
      3. Choose a name and press Save changes
      4. You should now have three tours
      5. Right-click on the Move tour up button for the second tour and copy the URL (we need to load it twice to trigger the original bug)
      6. Paste the URL into your browser and load the URL
      7. Confirm the second tour has been moved to the top of the list
      8. Paste the URL into your browser and load the URL again
      9. Confirm there are no errors and the same ordering is preserved
      10. Right-click on the Move tour down button for the current second tour and copy the URL
      11. Paste the URL into your browser and load the URL
      12. Confirm the second tour has been moved to the bottom of the list
      13. Paste the URL into your browser and load the URL again
      14. Confirm there are no errors and the same ordering is preserved

      Unit tests

      1. Run vendor/bin/phpunit tool_usertours_manager_testcase
      2. Confirm testcase passes
      Show
      Manual Navigate to Appearance > Users tours under Site administration Press Create a new tour Choose a name and press Save changes You should now have three tours Right-click on the Move tour up button for the second tour and copy the URL (we need to load it twice to trigger the original bug) Paste the URL into your browser and load the URL Confirm the second tour has been moved to the top of the list Paste the URL into your browser and load the URL again Confirm there are no errors and the same ordering is preserved Right-click on the Move tour down button for the current second tour and copy the URL Paste the URL into your browser and load the URL Confirm the second tour has been moved to the bottom of the list Paste the URL into your browser and load the URL again Confirm there are no errors and the same ordering is preserved Unit tests Run vendor/bin/phpunit tool_usertours_manager_testcase Confirm testcase passes

    Description

      Seen in multiple MC sites, the upgrade to 3.6.1 fails because a row in tool_usertours_tours has a sortorder of -1. manually updating the table and setting sortorder of 0 (or some other positive int) causes upgrade to succeed.

       

      stack trace:

       
      Default exception handler: Error writing to database Debug: ERROR:  null value in column "name" violates not-null constraint
      DETAIL:  Failing row contains (7, null, null, null, null, 4, null).
      INSERT INTO m_tool_usertours_tours (name,description,pathmatch,enabled,sortorder,configdata) VALUES($1,$2,$3,$4,$5,$6) RETURNING id
      [array (
        \'name\' => NULL,
        \'description\' => NULL,
        \'pathmatch\' => NULL,
        \'enabled\' => NULL,
        \'sortorder\' => 4,
        \'configdata\' => \'null\',
      )]
      Error code: dmlwriteexception
      * line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
      * line 248 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      * line 969 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 1017 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
      * line 521 of /admin/tool/usertours/classes/tour.php: call to pgsql_native_moodle_database->insert_record()
      * line 734 of /admin/tool/usertours/classes/manager.php: call to tool_usertours\\tour->persist()
      * line 859 of /admin/tool/usertours/classes/manager.php: call to tool_usertours\\manager::_move_tour()
      * line 52 of /admin/tool/usertours/db/upgrade.php: call to tool_usertours\\manager::update_shipped_tours()
      * line 636 of /lib/upgradelib.php: call to xmldb_tool_usertours_upgrade()
      * line 1857 of /lib/upgradelib.php: call to upgrade_plugins()
      * line 186 of /admin/cli/upgrade.php: call to upgrade_noncore()
      

      Attachments

        Activity

          People

            pholden Paul Holden
            jtomkinson Jordan Tomkinson
            Simey Lameze Simey Lameze
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11/May/20

              Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 23 minutes
                2h 23m