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

          Chien Wen-Chang(簡文章) created issue -
          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.
          Charles Fulton made changes -
          Field Original Value New Value
          Link This issue is a regression caused by MDL-19125 [ MDL-19125 ]
          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.
          Tim Hunt made changes -
          Fix Version/s STABLE backlog [ 10463 ]
          Priority Minor [ 4 ] Critical [ 2 ]
          Labels triaged
          Assignee moodle.com [ moodle.com ] Tim Hunt [ timhunt ]
          Tim Hunt made changes -
          Status Open [ 1 ] Waiting for integration review [ 10010 ]
          Pull Master Diff URL https://github.com/timhunt/moodle/compare/master...MDL-34082
          Pull 2.3 Diff URL https://github.com/timhunt/moodle/compare/MOODLE_23_STABLE...MDL-34082_23
          Pull Master Branch MDL-34082
          Pull from Repository git://github.com/timhunt/moodle.git
          Fix Version/s 2.3.3 [ 12373 ]
          Fix Version/s 2.4 [ 12255 ]
          Fix Version/s STABLE backlog [ 10463 ]
          Testing Instructions 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!
          Pull 2.3 Branch MDL-34082_23
          Eloy Lafuente (stronk7) made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator stronk7
          Eloy Lafuente (stronk7) made changes -
          Status Integration review in progress [ 10004 ] Waiting for integration review [ 10010 ]
          Eloy Lafuente (stronk7) made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Currently in integration Yes [ 10041 ]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (23 and master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (23 and master), thanks!
          Eloy Lafuente (stronk7) made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          Affects Version/s 2.4 [ 12255 ]
          Fix Version/s 2.4 [ 12255 ]
          Eloy Lafuente (stronk7) made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Tester stronk7
          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
          Eloy Lafuente (stronk7) made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          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!
          Eloy Lafuente (stronk7) made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes [ 10041 ]
          Integration date 14/Sep/12

            People

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

              Dates

              • Created:
                Updated:
                Resolved: