MDL-69331 core_h5p: Only upgrade enabled libraries
authorSara Arjona <sara@moodle.com>
Thu, 25 Feb 2021 15:21:51 +0000 (16:21 +0100)
committerSara Arjona <sara@moodle.com>
Thu, 15 Apr 2021 07:03:56 +0000 (09:03 +0200)
The core\task\h5p_get_content_types_task task will only download
content-type for enabled libraries.

h5p/classes/core.php

index 3d80611..6b18024 100644 (file)
@@ -179,6 +179,11 @@ class core extends \H5PCore {
         $framework = $factory->get_framework();
 
         foreach ($contenttypes->contentTypes as $type) {
+            // Don't fetch content types if any of the versions is disabled.
+            $librarydata = (object) ['machinename' => $type->id];
+            if (!api::is_library_enabled($librarydata)) {
+                continue;
+            }
             // Don't fetch content types that require a higher H5P core API version.
             if (!$this->is_required_core_api($type->coreApiVersionNeeded)) {
                 continue;