HFP-2683 Fix empty arrays instead of groups when uploading
parent
0b1aadbbca
commit
70278d15f4
|
@ -864,7 +864,7 @@ class H5PValidator {
|
||||||
$valid = FALSE;
|
$valid = FALSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$mainH5pData = $this->getJson($tmpPath, $zip, 'h5p.json');
|
$mainH5pData = $this->getJson($tmpPath, $zip, 'h5p.json', TRUE);
|
||||||
if ($mainH5pData === NULL) {
|
if ($mainH5pData === NULL) {
|
||||||
return FALSE; // Breaking error when reading from the archive.
|
return FALSE; // Breaking error when reading from the archive.
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1044,7 @@ class H5PValidator {
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return mixed JSON content if valid, FALSE for invalid, NULL for breaking error.
|
* @return mixed JSON content if valid, FALSE for invalid, NULL for breaking error.
|
||||||
*/
|
*/
|
||||||
private function getJson($path, $zip, $file) {
|
private function getJson($path, $zip, $file, $assoc = FALSE) {
|
||||||
// Get stream
|
// Get stream
|
||||||
$stream = $zip->getStream($file);
|
$stream = $zip->getStream($file);
|
||||||
if (!$stream) {
|
if (!$stream) {
|
||||||
|
@ -1062,7 +1062,7 @@ class H5PValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode the data
|
// Decode the data
|
||||||
$json = json_decode($contents, TRUE);
|
$json = json_decode($contents, $assoc);
|
||||||
if ($json === NULL) {
|
if ($json === NULL) {
|
||||||
// JSON cannot be decoded or the recursion limit has been reached.
|
// JSON cannot be decoded or the recursion limit has been reached.
|
||||||
$this->h5pF->setErrorMessage($this->h5pF->t('Unable to parse JSON from the package: %fileName', array('%fileName' => $file)), 'unable-to-parse-package');
|
$this->h5pF->setErrorMessage($this->h5pF->t('Unable to parse JSON from the package: %fileName', array('%fileName' => $file)), 'unable-to-parse-package');
|
||||||
|
|
Loading…
Reference in New Issue