From 2d7824aa932a6b217bc16a4f7b53c6ab654a1790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Thu, 6 Nov 2014 11:13:24 +0100 Subject: [PATCH 1/4] Fix for language containing empty string in H5P export (h5p.json) --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 827903a..905b72c 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1433,7 +1433,7 @@ Class H5PExport { 'title' => $content['title'], // TODO - stop using 'und', this is not the preferred way. // Either remove language from the json if not existing, or use "language": null - 'language' => isset($content['language']) ? $content['language'] : 'und', + 'language' => (isset($content['language']) && strlen(trim($content['language'])) !== 0) ? $content['language'] : 'und', 'mainLibrary' => $content['library']['name'], 'embedTypes' => $embedTypes, ); From 60d166c6da256bb2d5a66be2f4927efd229b6fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Wed, 19 Nov 2014 12:43:59 +0100 Subject: [PATCH 2/4] Made creation of h5p export file overwrite existing file --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 905b72c..9a456a5 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1465,7 +1465,7 @@ Class H5PExport { // Create new zip instance. $zip = new ZipArchive(); - $zip->open($zipPath, ZIPARCHIVE::CREATE); + $zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);); // Get all files and folders in $tempPath $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempPath . DIRECTORY_SEPARATOR)); From 9ed2e48fb5c97ce398ba7176ca678f2d3e50209c Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 25 Nov 2014 10:55:32 +0100 Subject: [PATCH 3/4] Fixed parse error. --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 9a456a5..36151b1 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1465,7 +1465,7 @@ Class H5PExport { // Create new zip instance. $zip = new ZipArchive(); - $zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);); + $zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); // Get all files and folders in $tempPath $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempPath . DIRECTORY_SEPARATOR)); From fb07f54e3517bff606934b0b056188afce24524d Mon Sep 17 00:00:00 2001 From: falcon Date: Thu, 27 Nov 2014 23:14:15 +0100 Subject: [PATCH 4/4] Make it possible to do the dependency transactions in an atomic way --- h5p-development.class.php | 2 ++ h5p.classes.php | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/h5p-development.class.php b/h5p-development.class.php index 75e9daf..7f33689 100644 --- a/h5p-development.class.php +++ b/h5p-development.class.php @@ -93,6 +93,7 @@ class H5PDevelopment { // TODO: Should we remove libraries without files? Not really needed, but must be cleaned up some time, right? // Go trough libraries and insert dependencies. Missing deps. will just be ignored and not available. (I guess?!) + $this->h5pF->lockDependencyStorage(); foreach ($this->libraries as $library) { $this->h5pF->deleteLibraryDependencies($library['libraryId']); // This isn't optimal, but without it we would get duplicate warnings. @@ -104,6 +105,7 @@ class H5PDevelopment { } } } + $this->h5pF->unlockDependencyStorage(); // TODO: Deps must be inserted into h5p_nodes_libraries as well... ? But only if they are used?! } diff --git a/h5p.classes.php b/h5p.classes.php index 36151b1..5940e06 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -408,6 +408,17 @@ interface H5PFrameworkInterface { */ public function deleteLibraryDependencies($libraryId); + /** + * Start an atomic operation against the dependency storage + */ + public function lockDependencyStorage(); + + /** + * Stops an atomic operation against the dependency storage + */ + public function unlockDependencyStorage(); + + /** * Delete a library from database and file system *