From 32754bdf2a754f8fe3cd0bd1e6401c6f9fda01c2 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Thu, 7 Apr 2022 13:23:08 +0800 Subject: [PATCH] MDL-74434 block_tag_youtube: Update instances only if category is set Modifies the existing upgrade step to only take into consideration block instances that have a specific category set prior to determening if a legacy category is being used and updating them. Instances that do not have any category set should be ignored. --- blocks/tag_youtube/db/upgrade.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/blocks/tag_youtube/db/upgrade.php b/blocks/tag_youtube/db/upgrade.php index 897eb1ebe14..fc0bf34f27c 100644 --- a/blocks/tag_youtube/db/upgrade.php +++ b/blocks/tag_youtube/db/upgrade.php @@ -101,6 +101,12 @@ function xmldb_block_tag_youtube_upgrade($oldversion) { // If the block uses a legacy category name, update it to use the current category ID instead. foreach ($blockinstances as $blockinstance) { $blockconfig = unserialize(base64_decode($blockinstance->configdata)); + + // Skip if the block does not have a specific category set. + if (!isset($blockconfig->category)) { + continue; + } + $blockcategoryconfig = $blockconfig->category; // The block is using a legacy category name as a category config. if (array_key_exists($blockcategoryconfig, $categorynamemap)) {