Skip to content

Commit

Permalink
Merge branch 'MDL-77783-400' of https://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
andrewnicols committed Mar 31, 2023
2 parents db31cd3 + 13fec41 commit dc2b74c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/classes/component.php
Expand Up @@ -553,7 +553,18 @@ protected static function fetch_subtypes($ownerdir) {
$types = array();
$subplugins = array();
if (file_exists("$ownerdir/db/subplugins.json")) {
$subplugins = (array) json_decode(file_get_contents("$ownerdir/db/subplugins.json"))->plugintypes;
$subplugins = [];
$subpluginsjson = json_decode(file_get_contents("$ownerdir/db/subplugins.json"));
if (json_last_error() === JSON_ERROR_NONE) {
if (!empty($subpluginsjson->plugintypes)) {
$subplugins = (array) $subpluginsjson->plugintypes;
} else {
error_log("No plugintypes defined in $ownerdir/db/subplugins.json");
}
} else {
$jsonerror = json_last_error_msg();
error_log("$ownerdir/db/subplugins.json is invalid ($jsonerror)");
}
} else if (file_exists("$ownerdir/db/subplugins.php")) {
error_log('Use of subplugins.php has been deprecated. ' .
"Please update your '$ownerdir' plugin to provide a subplugins.json file instead.");
Expand Down

0 comments on commit dc2b74c

Please sign in to comment.