From e5ead3c03a782631f8d1930ae1a498f552173c5c Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 15 Feb 2024 10:13:02 +0100 Subject: [PATCH] MDL-80950 external: Fix PHP deprecated error for explode() This patch fixes the following error: PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in lib/upgradelib.php on line 1299 --- lib/upgradelib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 86e19c98d380a..45bb85b5424de 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -1287,7 +1287,9 @@ function external_update_descriptions($component) { if ($dbfunction->services != $functionservices) { // Now, we need to check if services were removed, in that case we need to remove the function from them. - $servicesremoved = array_diff(explode(",", $dbfunction->services), explode(",", $functionservices)); + $oldservices = $dbfunction->services ? explode(',', $dbfunction->services) : []; + $newservices = $functionservices ? explode(',', $functionservices) : []; + $servicesremoved = array_diff($oldservices, $newservices); foreach ($servicesremoved as $removedshortname) { if ($externalserviceid = $DB->get_field('external_services', 'id', array("shortname" => $removedshortname))) { $DB->delete_records('external_services_functions', array('functionname' => $dbfunction->name,