Skip to content

Commit

Permalink
Fix 'Version 404.1.2 adhoc task fails' - #222. Note: Need to up codeb…
Browse files Browse the repository at this point in the history
…ase as previous adhoc tasks could have failed!
  • Loading branch information
gjb2048 committed Sep 28, 2024
1 parent 867d882 commit 61f3b54
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ History

Version 404.1.2.5 - 28/09/2024
------------------------------
1. Fix 'Version 404.1.2 adhoc task fails' - #222.

Version 404.1.2 - 23/09/2024
----------------------------
Expand Down
3 changes: 2 additions & 1 deletion classes/task/update_displayed_images_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static function update_displayed_images_imageresizemethod() {
$gridcourses = $DB->get_records('course', ['format' => 'grid'], '', 'id');

foreach ($gridcourses as $gridcourse) {
$format = course_get_format($gridcourse->id);
// Instead of course_get_format() for CLI usage.
$format = \core_courseformat\base::instance($gridcourse->id);
$imageresizemethod = $format->get_format_options()['imageresizemethod'];
if ($imageresizemethod != 0) {
$task = new update_displayed_images_adhoc();
Expand Down
3 changes: 2 additions & 1 deletion classes/toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ private static function update_the_displayed_images($courseid = null) {
foreach ($coursesectionimages as $coursesectionimage) {
if ($courseid != $coursesectionimage->courseid) {
$courseid = $coursesectionimage->courseid;
$format = course_get_format($courseid);
// Instead of course_get_format() for CLI usage.
$format = \core_courseformat\base::instance($courseid);
if (get_class($format) != 'format_grid') {
// Not currently in the Grid format, but was.
$format = null;
Expand Down
8 changes: 4 additions & 4 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ function xmldb_format_grid_upgrade($oldversion = 0) {
upgrade_plugin_savepoint(true, 2023051001, 'format', 'grid');
}

if ($oldversion < 2024032902) {
if ($oldversion < 2024032904) {
// Has the upgrade already happened? Thus in versions for Moodle 4.1+ ?
$codebase = get_config('format_grid', 'codebase');
if ((empty($codebase)) || ((!empty($codebase)) && ($codebase < 2024090700))) {
if ((empty($codebase)) || ((!empty($codebase)) && ($codebase < 2024092900))) {
// No!
\format_grid\task\update_displayed_images_task::update_displayed_images_imageresizemethod();
set_config('codebase', 2024090700, 'format_grid');
set_config('codebase', 2024092900, 'format_grid');
}

// Grid savepoint reached.
upgrade_plugin_savepoint(true, 2024032902, 'format', 'grid');
upgrade_plugin_savepoint(true, 2024032904, 'format', 'grid');
}

// Automatic 'Purge all caches'....
Expand Down

0 comments on commit 61f3b54

Please sign in to comment.