MDL-74895 h5p: more resilient error handling during content fetching.

On new installs, the task for downloading new H5P content types would
throw exceptions and exit when encountering unexpected and/or missing
data.
This commit is contained in:
Paul Holden 2022-07-25 20:02:14 +01:00
parent 4ce642e8ba
commit 426f533c07

View File

@ -277,7 +277,13 @@ class core extends H5PCore {
$file->delete();
$librarykey = static::libraryToString($library);
$libraryid = $factory->get_storage()->h5pC->librariesJsonData[$librarykey]["libraryId"];
$libraryjson = $factory->get_storage()->h5pC->librariesJsonData[$librarykey];
if (!array_key_exists('libraryId', $libraryjson)) {
return null;
}
$libraryid = $libraryjson['libraryId'];
// Update example and tutorial (if any of them are defined in $library).
$params = ['id' => $libraryid];