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

Upgrade fails when adding fields to tag_instance table.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0, 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: Installation, Tags
    • Labels:
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Here is the stack track, it explains the issue.

      Debug info: Field tag_instance->tiuserid cannot be added. Not null fields added to non empty tables require default value. Create skipped
      Stack trace:

      • line 579 of /lib/ddl/database_manager.php: ddl_exception thrown
      • line 243 of /lib/db/upgrade.php: call to database_manager->add_field()
      • line 1309 of /lib/upgradelib.php: call to xmldb_main_upgrade()
      • line 252 of /admin/index.php: call to upgrade_core()

      Looking at line 242 in /lib/db/upgrade.php contains the following line: $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'itemid');

      Changing this to: $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'itemid'); fixes the issue. It is also possible to set the other field to XMLDB_NULL instead.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Well spotted, Mark, thanks!

            Sending this to stable backlog to be fixed asap. Changes should include:

            • modify install.xml to have the tag_instance->tiuserid column using default = 0
            • modify upgrade.php as commented above, adding default = 0
            • add one new upgrade.php step doing:
              • drop the itemtype-itemid-tagid-tiuserid index.
              • modify tag_instance->tiuserid column to have default = 0
              • recreate the itemtype-itemid-tagid-tiuserid index.

            That way both new installations and any upgraded Moodle 2.0.x will have that column with proper default = 0. I've looked across uses in codebase and seems that 0 is a good default to be applied.

            Ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Well spotted, Mark, thanks! Sending this to stable backlog to be fixed asap. Changes should include: modify install.xml to have the tag_instance->tiuserid column using default = 0 modify upgrade.php as commented above, adding default = 0 add one new upgrade.php step doing: drop the itemtype-itemid-tagid-tiuserid index. modify tag_instance->tiuserid column to have default = 0 recreate the itemtype-itemid-tagid-tiuserid index. That way both new installations and any upgraded Moodle 2.0.x will have that column with proper default = 0. I've looked across uses in codebase and seems that 0 is a good default to be applied. Ciao
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Assigning this to Dongsheng that has been already working on it @ MDL-26116.

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Assigning this to Dongsheng that has been already working on it @ MDL-26116 .
            Hide
            dongsheng Dongsheng Cai added a comment -

            Hi, Eloy

            I just added upgrade block to drop and recreate index.
            https://github.com/dongsheng/moodle/commit/eb1f6027c02a4497de178d27bd0bd43329ad42de

            Show
            dongsheng Dongsheng Cai added a comment - Hi, Eloy I just added upgrade block to drop and recreate index. https://github.com/dongsheng/moodle/commit/eb1f6027c02a4497de178d27bd0bd43329ad42de
            Hide
            dongsheng Dongsheng Cai added a comment -

            Added Sam to watcher list.

            Sam, can you please have a look at my commit, if it is ok, I will submit the pull request, Thanks.

            Regards,
            Dongsheng

            Show
            dongsheng Dongsheng Cai added a comment - Added Sam to watcher list. Sam, can you please have a look at my commit, if it is ok, I will submit the pull request, Thanks. Regards, Dongsheng
            Hide
            dongsheng Dongsheng Cai added a comment -

            PULL request submitted.

            Thanks all.

            Show
            dongsheng Dongsheng Cai added a comment - PULL request submitted. Thanks all.
            Hide
            mudrd8mz David Mudrak added a comment -

            The patch has been reviewed, accepted and tested. Closing. Thanks Mark for the report!

            Show
            mudrd8mz David Mudrak added a comment - The patch has been reviewed, accepted and tested. Closing. Thanks Mark for the report!
            Hide
            tmikula Tim Mikula added a comment -

            I am having this problem as well. When will the current code include this patch so I can try my 1.9 to 2.0 upgrade again?

            Show
            tmikula Tim Mikula added a comment - I am having this problem as well. When will the current code include this patch so I can try my 1.9 to 2.0 upgrade again?
            Hide
            mudrd8mz David Mudrak added a comment -

            Tim, Moodle 2.0.1+ containing the patch is now available at http://download.moodle.org

            Show
            mudrd8mz David Mudrak added a comment - Tim, Moodle 2.0.1+ containing the patch is now available at http://download.moodle.org

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  21/Feb/11