mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-77783 core: Validate sublugins.json
* Validate the decoded subplugins.json before processing it. * Log errors if subplugins.json is invalid or if plugintypes is not defined.
This commit is contained in:
parent
449a8b0b31
commit
c99abd65ca
@ -554,7 +554,18 @@ $cache = '.var_export($cache, true).';
|
||||
$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.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user