From e2e6d0be677e0cd3f96e1f2a5383b86a924a8a17 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:04:01 +0100 Subject: [PATCH] Fix 'A lock was created but not released at' error? --- classes/toolbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/toolbox.php b/classes/toolbox.php index fcc0e607..f9353897 100644 --- a/classes/toolbox.php +++ b/classes/toolbox.php @@ -615,7 +615,7 @@ private static function update_the_displayed_images($courseid = null) { if (!empty($coursesectionimages)) { $fs = get_file_storage(); $lockfactory = null; - $lock = true; + $lock = null; if (!defined('BEHAT_SITE_RUNNING')) { $lockfactory = \core\lock\lock_config::get_lock_factory('format_grid'); } @@ -630,7 +630,7 @@ private static function update_the_displayed_images($courseid = null) { if (!defined('BEHAT_SITE_RUNNING')) { $lock = $lockfactory->get_lock('sectionid'.$coursesectionimage->sectionid, 5); } - if ($lock) { + if (($lock instanceof \core\lock\lock) || (defined('BEHAT_SITE_RUNNING'))) { $files = $fs->get_area_files($coursecontext->id, 'format_grid', 'sectionimage', $coursesectionimage->sectionid); foreach ($files as $file) { if (!$file->is_directory()) {