mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-79291 h5p: handle content type creation errors in test generator.
If the endpoint is temporarily down and/or misbehaving, then at least we'll a clearer failure message.
This commit is contained in:
parent
8ac8ea416a
commit
11867ee8eb
@ -379,6 +379,8 @@ class core_h5p_generator extends \component_generator_base {
|
||||
* @param array $typestonotinstall H5P content types that should not be installed
|
||||
* @param core $core h5p_test_core instance required to use the exttests URL
|
||||
* @return array Data of the content types not installed.
|
||||
*
|
||||
* @throws invalid_response_exception If request to get the latest content types fails (usually due to a transient error)
|
||||
*/
|
||||
public function create_content_types(array $typestonotinstall, core $core): array {
|
||||
global $DB;
|
||||
@ -386,12 +388,15 @@ class core_h5p_generator extends \component_generator_base {
|
||||
autoloader::register();
|
||||
|
||||
// Get info of latest content types versions.
|
||||
$contenttypes = $core->get_latest_content_types()->contentTypes;
|
||||
$response = $core->get_latest_content_types();
|
||||
if (!empty($response->error)) {
|
||||
throw new invalid_response_exception($response->error);
|
||||
}
|
||||
|
||||
$installedtypes = 0;
|
||||
|
||||
// Fake installation of all other H5P content types.
|
||||
foreach ($contenttypes as $contenttype) {
|
||||
foreach ($response->contentTypes as $contenttype) {
|
||||
// Don't install pending content types.
|
||||
if (in_array($contenttype->id, $typestonotinstall)) {
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user