Skip to content

Commit

Permalink
MDL-80950 external: Fix PHP deprecated error for explode()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sarjona committed Feb 15, 2024
1 parent e4bbd79 commit 63d96ee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,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,
Expand Down

0 comments on commit 63d96ee

Please sign in to comment.