Moodle
  1. Moodle
  2. MDL-26071

Upgrade fails when adding fields to tag_instance table.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker 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
    • Rank:
      16049

      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.

        Issue Links

          Activity

          Hide
          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
          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
          Eloy Lafuente (stronk7) added a comment -

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

          Show
          Eloy Lafuente (stronk7) added a comment - Assigning this to Dongsheng that has been already working on it @ MDL-26116 .
          Hide
          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 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 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 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 Cai added a comment -

          PULL request submitted.

          Thanks all.

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

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

          Show
          David Mudrak added a comment - The patch has been reviewed, accepted and tested. Closing. Thanks Mark for the report!
          Hide
          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
          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
          David Mudrak added a comment -

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

          Show
          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: