Moodle
  1. Moodle
  2. MDL-34082

Moodle 2.2 upgrade to 2.3 error: Unknown column 'retrictmodules' in 'where clause'

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.3, 2.4
    • Fix Version/s: 2.3.3
    • Component/s: Installation
    • Labels:
    • Testing Instructions:
      Hide

      You need to test upgrading a site from 2.2 to 2.3, where $CFG->restrictmodulesfor is set to 'requested'.

      So, that is rather like the MDL-19125 testing instructions, except that we clearly failed to test that case before. Oops!

      Show
      You need to test upgrading a site from 2.2 to 2.3, where $CFG->restrictmodulesfor is set to 'requested'. So, that is rather like the MDL-19125 testing instructions, except that we clearly failed to test that case before. Oops!
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      42389

      Description

      Error Message :

      Default exception handler: Error reading from database Debug: Unknown column 'retrictmodules' in 'where clause'
      SELECT id, 1 FROM mdl_course WHERE retrictmodules = ? ORDER BY id
      [array (
      0 => 1,
      )]

      Error code: dmlreadexception

      • line 407 of \lib\dml\moodle_database.php: dml_read_exception thrown
      • line 864 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
      • line 1166 of \lib\dml\moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
      • line 1113 of \lib\dml\moodle_database.php: call to moodle_database->get_records_select()
      • line 1206 of \lib\dml\moodle_database.php: call to moodle_database->get_records()
      • line 251 of \lib\db\upgrade.php: call to moodle_database->get_records_menu()
      • line 1481 of \lib\upgradelib.php: call to xmldb_main_upgrade()
      • line 275 of \admin\index.php: call to upgrade_core()

      ============================================================================
      Part source codes of \lib\db\upgrade.php as follow.

      if ($oldversion < 2012031500.01) {
      // Upgrade old course_allowed_modules data to be permission overrides.
      if ($CFG->restrictmodulesfor === 'all')

      { $courses = $DB->get_records_menu('course', array(), 'id', 'id, 1'); }

      else if ($CFG->restrictmodulesfor === 'requested')

      { $courses = $DB->get_records_menu('course', array('retrictmodules' => 1), 'id', 'id, 1'); }

      else

      { $courses = array(); }

      =============================================================================
      'retrictmodules' need replace by 'restrictmodules'.

        Issue Links

          Activity

          Hide
          Tiffan added a comment -

          Hello!

          try changing column name to 'restrictmodules'.
          just go to phpmyadmin, your moodle databse, mdl_course table, structure and change the column name, then try upgrading again.

          it seems to me that you first upgraded from 1.9 dbase, where as there is no column under mdl_course with such name (retrictmodules), but restrictmodules .

          let us know if that helped!

          cheers!

          Show
          Tiffan added a comment - Hello! try changing column name to 'restrictmodules'. just go to phpmyadmin, your moodle databse, mdl_course table, structure and change the column name, then try upgrading again. it seems to me that you first upgraded from 1.9 dbase, where as there is no column under mdl_course with such name (retrictmodules), but restrictmodules . let us know if that helped! cheers!
          Hide
          Stephen Bloomer added a comment -

          if we rename the column to "retrictmodules" it will cause lots of issues in future upgrades. Does anyone know when the code will be fixed in the upgrade?

          Show
          Stephen Bloomer added a comment - if we rename the column to "retrictmodules" it will cause lots of issues in future upgrades. Does anyone know when the code will be fixed in the upgrade?
          Hide
          Charles Fulton added a comment -

          I definitely wouldn't touch the database since it's just a typo in the code. Do a find/replace in lib/db/upgrade.php for 'retrictmodules' and replace with 'restrictmodules'. That should allow the upgrade to proceed.

          Incidentally the table gets dropped in the next upgrade step so downstream effects are minimal.

          Show
          Charles Fulton added a comment - I definitely wouldn't touch the database since it's just a typo in the code. Do a find/replace in lib/db/upgrade.php for 'retrictmodules' and replace with 'restrictmodules'. That should allow the upgrade to proceed. Incidentally the table gets dropped in the next upgrade step so downstream effects are minimal.
          Hide
          Tim Hunt added a comment -

          Sorry, this was my mistake. I can't believe this slipped through testing. Taking, and fixing.

          Show
          Tim Hunt added a comment - Sorry, this was my mistake. I can't believe this slipped through testing. Taking, and fixing.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (23 and master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (23 and master), thanks!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Tested by setting one 2.2 site with "requested" and upgrading to 2.3, I got the correct:

          SELECT id, 1 FROM mdl_course WHERE restrictmodules = ? ORDER BY id [array ( 0 => 1, )]
          

          being executed on upgrade, so passing. Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Tested by setting one 2.2 site with "requested" and upgrading to 2.3, I got the correct: SELECT id, 1 FROM mdl_course WHERE restrictmodules = ? ORDER BY id [array ( 0 => 1, )] being executed on upgrade, so passing. Ciao
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio

          This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads).

          Thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads). Thanks!

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: