From 58597460f662234dfbe7d4d60385357e58ebad7b Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Mon, 9 Apr 2018 11:43:48 +0200 Subject: [PATCH] HFP-1905 Fix updating for scripts with old update functions "params" (and "extras", e.g. metadata) flow through each update function and are changed if necessary. Since "extras" was added later and old update functions don't return it, we need to ignore undefined values -- or change every single update function in all content types. --- js/h5p-content-upgrade-process.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/h5p-content-upgrade-process.js b/js/h5p-content-upgrade-process.js index 0f954ac..e440341 100644 --- a/js/h5p-content-upgrade-process.js +++ b/js/h5p-content-upgrade-process.js @@ -130,7 +130,15 @@ H5P.ContentUpgradeProcess = (function (Version) { try { unnecessaryWrapper(params, function (err, upgradedParams, upgradedExtras) { params = upgradedParams; - extras = upgradedExtras; + /** + * "params" (and "extras", e.g. metadata) flow through each update function and are changed + * if necessary. Since "extras" was added later and old update functions don't return + * it, we need to ignore undefined values here -- or change every single update function + * in all content types. + */ + if (upgradedExtras) { + extras = upgradedExtras; + } nextMinor(err); }, extras); }