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

Add Moodle 5.0.0 upgrade line to all the upgrade.php scripts

XMLWordPrintable

    • MOODLE_500_STABLE, MOODLE_501_STABLE
    • MOODLE_500_STABLE
    • MDL-85187-main
    • Hide

      Part 1: Run the "*Command(s) to detect..." mentioned in the description

      1-1: upgrade.php files not having the upgrade line
      1. Run the command to detect all the upgrade.php files not having the upgrade lines:

        find . -name upgrade.php | xargs grep -l 'function.*xmldb_.*_upgrade' | grep '/db/' | xargs grep -L 'Automatically generated Moodle v5.0.0 release upgrade'
        

      2. Confirm that nothing is returned
      1-2: Incorrectly added upgrade lines
      1. Run the following commands to detect that we have not added the lines to incorrect files:

        grep -lr 'Automatically generated Moodle v5.0.0 release upgrade' * | grep -v '/db/'
        grep -lr 'Automatically generated Moodle v5.0.0 release upgrade' * | xargs grep -L 'function.*xmldb_.*_upgrade'
        

      2. Confirm that nothing is returned
      1-3: Check upgrade lines added after upgrade steps made after the release
      1. Run the command to detect if the lines have been added after a post-release upgrade step. If there are upgrade steps found, verify that all of them were already there on the day of the release and have not been introduced later (you can look for differences between the release v5.0.0 and the current master to verify that)

        export rel="5.0.0" && export ver="202504" &&
        find . -name upgrade.php | \
        xargs grep -B25 "Automatically generated Moodle v${rel} release upgrade" | \
        grep "upgrade_.*_savepoint.*${ver}"
        

      2. Confirm that if any upgrade.php files are returned, the date indicated in the "upgrade_xx_savepoint()" call is not after the 5.0 release date of 20250414.

      Part 2: Check all upgrade scripts with upgrade comment

      1. Check that all upgrade scripts have the 5.0.0 comment before the return with:

         find . -ipath '*/db/upgrade.php' | xargs grep -B4 'return true;'
        

        • Random exceptions: Some upgrade scripts could be missing the comments before the return. Surely, it's because some new steps have already been introduced after the release. Verify that the comments are present in the correct place (before those new steps).

      Part 3

      1. This should return nothing too, or it will return the same exceptions mentioned in Part 2 or in 1-3:

        for u in `find . -name upgrade.php | grep 'db/upgrade'`; do grep -B4 'return true;' "$u" | grep "Automatically generated" > /dev/null; if [ $? -ne 0 ]; then echo "$u"; fi ; done
        

      Part 4

      1. Verify that the differences between the stable branch and main remain 100% the same after the patch (aka, the patch is 100% the same for both branches). Note that this is not true under parallel development or when versions have already diverged, so skip this step if that's the case.
      Show
      Part 1: Run the "*Command(s) to detect..." mentioned in the description 1-1: upgrade.php files not having the upgrade line Run the command to detect all the upgrade.php files not having the upgrade lines: find . -name upgrade.php | xargs grep -l 'function.*xmldb_.*_upgrade' | grep '/db/' | xargs grep -L 'Automatically generated Moodle v5.0.0 release upgrade' Confirm that nothing is returned 1-2: Incorrectly added upgrade lines Run the following commands to detect that we have not added the lines to incorrect files: grep -lr 'Automatically generated Moodle v5.0.0 release upgrade' * | grep - v '/db/' grep -lr 'Automatically generated Moodle v5.0.0 release upgrade' * | xargs grep -L 'function.*xmldb_.*_upgrade' Confirm that nothing is returned 1-3: Check upgrade lines added after upgrade steps made after the release Run the command to detect if the lines have been added after a post-release upgrade step. If there are upgrade steps found, verify that all of them were already there on the day of the release and have not been introduced later (you can look for differences between the release v5.0.0 and the current master to verify that) export rel= "5.0.0" && export ver= "202504" && find . -name upgrade.php | \ xargs grep -B25 "Automatically generated Moodle v${rel} release upgrade" | \ grep "upgrade_.*_savepoint.*${ver}" Confirm that if any upgrade.php files are returned, the date indicated in the " upgrade_xx_savepoint() " call is not after the 5.0 release date of 20250414. Part 2: Check all upgrade scripts with upgrade comment Check that all upgrade scripts have the 5.0.0 comment before the return with: find . -ipath '*/db/upgrade.php' | xargs grep -B4 'return true;' Random exceptions: Some upgrade scripts could be missing the comments before the return. Surely, it's because some new steps have already been introduced after the release. Verify that the comments are present in the correct place (before those new steps). Part 3 This should return nothing too, or it will return the same exceptions mentioned in Part 2 or in 1-3: for u in ` find . -name upgrade.php | grep 'db/upgrade' `; do grep -B4 'return true;' "$u" | grep "Automatically generated" > /dev/null ; if [ $? - ne 0 ]; then echo "$u" ; fi ; done Part 4 Verify that the differences between the stable branch and main remain 100% the same after the patch (aka, the patch is 100% the same for both branches). Note that this is not true under parallel development or when versions have already diverged, so skip this step if that's the case.
    • Hide

      Code verified against automated checks.

      Checked MDL-85187 using repository: https://github.com/junpataleta/moodle.git

      More information about this report

      Built on: Sun Apr 13 10:56:22 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-85187 using repository: https://github.com/junpataleta/moodle.git main (0 errors / 0 warnings) [branch: MDL-85187-main | CI Job ] More information about this report Built on: Sun Apr 13 10:56:22 UTC 2025
    • Hide

      Launching automatic jobs for branch MDL-85187-main

      Built on: Sun Apr 13 12:25:29 UTC 2025

      Show
      Launching automatic jobs for branch MDL-85187 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19002/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64998/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64999/ Behat (Firefox - boost) --> Unrelated (can be ignored) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/65000/ Behat (Firefox - classic) --> Unrelated (can be ignored) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/65001/ App tests (stable app version)  --> Unrelated (can be ignored) Built on: Sun Apr 13 12:25:29 UTC 2025
    • 1
    • Team Dragons 2025 Sprint 1.4

      To have it properly detected for the future, it would be great to add to all the upgrade.php scripts some lines like these:

      // Automatically generated Moodle v5.0.0 release upgrade line.
      // Put any upgrade step following this.
      

      exactly before the "return true;" present in all the scripts.

      Normally, it's ok to do that both in the stable (500_STABLE) and the main branches, so they will allow quickly find where 5.0.0 started and act once we decide future requirements.

      But, when under parallel development, this only can be done in the stable (500_STABLE) branch as the main branch already has diverged and can have own upgrade steps not corresponding to the version just released, but to the future version being developed in parallel.

      The change can be performed globally with:

      #!/bin/bash
      export rel="5.0.0" && find . -name upgrade.php | \
      xargs grep -l 'function.*xmldb_.*_upgrade' | \
      grep '/db/' | \
      xargs grep -L "Automatically generated Moodle v${rel} release upgrade" | \
      xargs perl -p -i -e 's@( *)(return true;)@\1// Automatically generated Moodle v$ENV{rel} release upgrade line.\n\1// Put any upgrade step following this.\n\n\1\2@s'
      

      Command to detect all the upgrade.php files not having those lines:

      find . -name upgrade.php | xargs grep -l 'function.*xmldb_.*_upgrade' | grep '/db/' | xargs grep -L 'Automatically generated Moodle v5.0.0 release upgrade'
      

      Commands to detect that we have not added the lines to incorrect files:

      grep -lr 'Automatically generated Moodle v5.0.0 release upgrade' * | grep -v '/db/'
      grep -lr 'Automatically generated Moodle v5.0.0 release upgrade' * | xargs grep -L 'function.*xmldb_.*_upgrade'
      

      Command to detect if the lines have been added after a post-release upgrade step. If there are upgrade steps found, verify that all of them were already there the day of the release and have not been introduced later (you can look for differences between the release v5.0.0 and the current main branch to verify that)

      export rel="5.0.0" && export ver="202504" &&
      find . -name upgrade.php | \
      xargs grep -B25 "Automatically generated Moodle v${rel} release upgrade" | \
      grep "upgrade_.*_savepoint.*${ver}"
      

      Important note to integrators: The sooner this issue is integrated after release, the fewer chances to get the lines put in an incorrect place (that's what the last "command to detect" above tries to avoid. We need to ensure that the lines are exactly at the release point (or we may end up deleting upgrade steps incorrectly in the future). So, immediate integration after release (within the on-sync period and ideally before any new upgrade step is added), it the best achievement.

      Ciao

        1. (1) 1 Passed -- (Main)MDL-85187.png
          29 kB
          Kim Jared Lucas
        2. (1) 2 Passed -- (Main)MDL-85187.png
          30 kB
          Kim Jared Lucas
        3. (1) 3 Passed -- (Main)MDL-85187.png
          54 kB
          Kim Jared Lucas
        4. (2) 1 Passed -- (Main)MDL-85187.png
          234 kB
          Kim Jared Lucas
        5. (3) 1 Passed -- (Main)MDL-85187.png
          32 kB
          Kim Jared Lucas

            jpataleta Jun Pataleta
            jpataleta Jun Pataleta
            Moodle HQ Moodle HQ
            Huong Nguyen Huong Nguyen
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 49 minutes
                49m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.