MDL-67057 h5p: Set framework file when saving package
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 7 Nov 2019 03:48:36 +0000 (11:48 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 7 Nov 2019 03:56:12 +0000 (11:56 +0800)
h5p/classes/helper.php
h5p/classes/player.php

index de3d857..06cb26c 100644 (file)
@@ -51,6 +51,7 @@ class helper {
         \core_php_time_limit::raise();
 
         $core = $factory->get_core();
+        $core->h5pF->set_file($file);
         $path = $core->fs->getTmpPath();
         $core->h5pF->getUploadedH5pFolderPath($path);
         // Add manually the extension to the file to avoid the validation fails.
index 224e0bf..e22db16 100644 (file)
@@ -278,9 +278,6 @@ class player {
             // content-type libraries exist, to avoid users without the h5p:updatelibraries capability upload malicious content.
             $onlyupdatelibs = !helper::can_update_library($file);
 
-            // Set the .h5p file, in order to check later the permissions to update libraries.
-            $this->core->h5pF->set_file($file);
-
             // Validate and store the H5P content before displaying it.
             $h5pid = helper::save_h5p($this->factory, $file, $config, $onlyupdatelibs, false);
             if (!$h5pid && $file->get_userid() != $USER->id && has_capability('moodle/h5p:updatelibraries', $this->context)) {