From 0c7df179a7a348c8387859311a8c0d8164ad9002 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Fri, 24 Aug 2018 12:55:42 +0200 Subject: [PATCH] Fix content upgrade bug --- h5p.classes.php | 2 +- js/h5p-content-upgrade-process.js | 2 +- js/h5p-content-upgrade.js | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index d9b4e4b..df958b0 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1806,7 +1806,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 16 + 'minorVersion' => 19 ); public static $styles = array( 'styles/h5p.css', diff --git a/js/h5p-content-upgrade-process.js b/js/h5p-content-upgrade-process.js index 81e55de..5277eb6 100644 --- a/js/h5p-content-upgrade-process.js +++ b/js/h5p-content-upgrade-process.js @@ -26,7 +26,7 @@ H5P.ContentUpgradeProcess = (function (Version) { // Make extras possible to work with for (var element in extras) { - if (extras.hasOwnProperty(element)) { + if (extras[element] !== undefined) { try { extras[element] = JSON.parse(extras[element]); if (!(extras[element] instanceof Object)) { diff --git a/js/h5p-content-upgrade.js b/js/h5p-content-upgrade.js index 564a0a8..de17fc1 100644 --- a/js/h5p-content-upgrade.js +++ b/js/h5p-content-upgrade.js @@ -248,10 +248,9 @@ self.current++; self.working++; - // Rewrap metadata - if (self.extras.metadata) { - self.extras.metadata = self.extras.metadata[id]; - } + var extras = { + metadata: (self.extras.metadata && self.extras.metadata[id]) ? self.extras.metadata[id] : undefined + }; if (worker) { worker.postMessage({ @@ -261,11 +260,11 @@ oldVersion: info.library.version, newVersion: self.version.toString(), params: self.parameters[id], - extras: self.extras + extras: extras }); } else { - new H5P.ContentUpgradeProcess(info.library.name, new Version(info.library.version), self.version, self.parameters[id], self.extras, id, function loadLibrary(name, version, next) { + new H5P.ContentUpgradeProcess(info.library.name, new Version(info.library.version), self.version, self.parameters[id], extras, id, function loadLibrary(name, version, next) { self.loadLibrary(name, version, function (err, library) { if (library.upgradesScript) { self.loadScript(library.upgradesScript, function (err) {