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

upgrade_plugins_blocks gets confused by cron frequency changes.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4, 2.4.1, 2.5
    • Fix Version/s: 2.3.5, 2.4.2
    • Component/s: Installation
    • Labels:
    • Testing Instructions:
      Hide

      1. Create a test block (e.g. block_test) with

      $plugin->version = 1;
      $plugin->cron = 0;
      

      2. Go to admin/notifications, so that the block is installed.

      3. Add an upgrade.php to the test block, that calls upgrade_block_savepoint(true, 2, 'test');

      4. Update the test block, so that

      $plugin->version = 3;
      $plugin->cron = 1;
      

      5. Go to admin/notifications, so that the block is upgraded. Ensure the upgrade runs normally. (Before this fix, block_test would appear to be upgraded twice.)

      Show
      1. Create a test block (e.g. block_test) with $plugin->version = 1; $plugin->cron = 0; 2. Go to admin/notifications, so that the block is installed. 3. Add an upgrade.php to the test block, that calls upgrade_block_savepoint(true, 2, 'test'); 4. Update the test block, so that $plugin->version = 3; $plugin->cron = 1; 5. Go to admin/notifications, so that the block is upgraded. Ensure the upgrade runs normally. (Before this fix, block_test would appear to be upgraded twice.)
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Here is some brilliant detective work by Derek Woolhead:

      Say the the current block version is 1, the upgrade.php version is 2, version.php is 3 and current block cron is 0 and version.php cron is 1. the sequence of code in upgrade_plugins_blocks is:

      i) current block version (1) < version.php (3) so upgrade function executed
      ii) upgrade function updates block version to the value in upgrade.php (2)
      ii) current block data is re-read from database
      iii) current block version (2) < version.php (3) so block version updated to value in version.php (3)
      iv) current block cron (0) < version.php cron (1) so current block written to database with cron value
      in version.php (1) * BUT this also sets block version number in database back to (2) *

      Therefore the version number in the current block variable ($currblock) needs setting to the value from version.php before the block is updated with the cron value. I suggest the code change, which should be after the upgrade_block_savepoint before the cron update should be either to re-read $currblock from the database or set $currblock->version = $block->version.

      I prefer the later looking at the upgrade_block_savepoint function.

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            timhunt Tim Hunt
            Peer reviewer:
            Derek Woolhead
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Rajesh Taneja
            Participants:
            Component watchers:
            Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Mar/13