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

http://hub.moodle -> https://moodle.net upgrade step can violate unique constraints

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Use ngrok.com to have your site visible from internet
      2. Install site of the version that did not have changes introduced in MDL-53492 - for example 3.2.4 or 3.3.1 - has to be inside the same major version as the one you are testing
      3. Register it (Site administration > Registration)
      4. Check out code from integration but do not run upgrade
      5. Login as admin, click on "Site administration" (/admin/search.php), you will see "Your site is not registered"
      6. Register your site again, fill different data in the registration form
      7. Inspect your database, you will have two entries in the mdl_registration_hubs - one for http://hub.moodle.org and another for https://moodle.net , both confirmed and with the same tokens
      8. Run SELECT * FROM mdl_config_plugins where plugin='hub' - you will see entries ending with moodleorg and moodlenet
      9. Run upgrade
      10. Open your registration form - it should have the data from the second registration
      11. Inspect your database, there should be only one entry in mdl_registration_hubs pointing to https://moodle.net
      12. Run SELECT * FROM mdl_config_plugins where plugin='hub' again, only entries ending with moodlenet should remain
      Show
      Use ngrok.com to have your site visible from internet Install site of the version that did not have changes introduced in MDL-53492 - for example 3.2.4 or 3.3.1 - has to be inside the same major version as the one you are testing Register it (Site administration > Registration) Check out code from integration but do not run upgrade Login as admin, click on "Site administration" (/admin/search.php), you will see "Your site is not registered" Register your site again, fill different data in the registration form Inspect your database, you will have two entries in the mdl_registration_hubs - one for http://hub.moodle.org and another for https://moodle.net , both confirmed and with the same tokens Run SELECT * FROM mdl_config_plugins where plugin='hub' - you will see entries ending with moodleorg and moodlenet Run upgrade Open your registration form - it should have the data from the second registration Inspect your database, there should be only one entry in mdl_registration_hubs pointing to https://moodle.net Run SELECT * FROM mdl_config_plugins where plugin='hub' again, only entries ending with moodlenet should remain
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE
    • Pull Master Branch:
      wip-MDL-60167-master
    • Sprint:
      3.4 Sprint 5

      Description

      The upgrade step in MDL-53492 is not safe in the case of duplicate plugin values

      Default exception handler: Error writing to database Debug: ERROR:  duplicate key value violates unique constraint \"m_confplug_plunam_uix\"
      DETAIL:  Key (plugin, name)=(hub, site_name_httpsmoodlenet) already exists.
      UPDATE m_config_plugins SET name = $1 WHERE id=$2
      [array (
        'name' => 'site_name_httpsmoodlenet',
        0 => '1702',
      )]
      Error code: dmlwriteexception
      * line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
      * line 242 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      * line 1095 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 1128 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->update_record_raw()
      * line 2909 of /lib/db/upgrade.php: call to pgsql_native_moodle_database->update_record()
      * line 1694 of /lib/upgradelib.php: call to xmldb_main_upgrade()
      * line 175 of /admin/cli/upgrade.php: call to upgrade_core()
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/Nov/17