MDL-81717 h5p: Improve robustness content type fetching

Strengthen code to ensure retrieval of all content types, despite
failures.
This commit is contained in:
Sara Arjona
2024-04-29 12:12:08 +02:00
parent 792698af00
commit c60d03a7b6
+9 -1
View File
@@ -273,8 +273,16 @@ class core extends H5PCore {
$librarykey = static::libraryToString($library);
if (is_null($factory->get_storage()->h5pC->librariesJsonData)) {
// There was an error fetching the content type.
debugging('Error fetching content type: ' . $librarykey);
return null;
}
$libraryjson = $factory->get_storage()->h5pC->librariesJsonData[$librarykey];
if (!array_key_exists('libraryId', $libraryjson)) {
if (is_null($libraryjson) || !array_key_exists('libraryId', $libraryjson)) {
// There was an error fetching the content type.
debugging('Error fetching content type: ' . $librarykey);
return null;
}