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

upgrade_plugins_blocks gets confused by cron frequency changes.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.3.5, 2.4.2
    • 2.3.4, 2.4.1, 2.5
    • Installation
    • MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • 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.)

      Here is some brilliant detective work by derekw:

      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.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Derek Woolhead Derek Woolhead
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Rajesh Taneja Rajesh Taneja
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

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