Skip to content

Commit

Permalink
[BUGFIX] Don't force arrays when json_encoding parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuurlijk committed Sep 28, 2021
1 parent 496feaa commit 149c530
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
13 changes: 11 additions & 2 deletions Classes/Controller/H5pModuleController.php
Expand Up @@ -634,10 +634,19 @@ public function editAction(int $contentId)
$contentLibrary = $content->getLibrary()->toAssocArray();
$this->view->assign('content', $content);
$this->view->assign('library', sprintf('%s %d.%d', $contentLibrary['machineName'], $contentLibrary['majorVersion'], $contentLibrary['minorVersion']));
$parameters = (array)json_decode($content->getFiltered(), true);
$parameters = (array)json_decode($content->getFiltered());
$parameters = $this->injectMetadataIntoParameters($parameters, $content);
$parameters = json_encode($parameters, JSON_THROW_ON_ERROR);
$parameters = str_replace('"image":[]', '"image":{}', $parameters);
// Unbreak wrongly encoded parameters (Content.php updateFromContentData())
$parameters = str_replace([
'"globalBackgroundSelector":[]',
'"slideBackgroundSelector":[]',
'"image":[]'
], [
'"globalBackgroundSelector":{}',
'"slideBackgroundSelector":{}',
'"image":{}'
], $parameters);
$this->view->assign('parameters', $parameters);
}

Expand Down
4 changes: 1 addition & 3 deletions Classes/Domain/Model/Content.php
Expand Up @@ -195,9 +195,7 @@ public function updateFromContentData(array $contentData, Library $library)
}

if (isset($contentData['params'])) {
// Yes, twice. they added metadata later and didnt rename the top level.
$parameters = json_decode($contentData['params'], true);
$this->setParameters(json_encode($parameters));
$this->setParameters($contentData['params']);

// "H5P Metadata"
$this->setTitle(html_entity_decode($contentData['metadata']->title));
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Expand Up @@ -11,7 +11,7 @@
'dependencies' => '',
'state' => 'stable',
'uploadfolder' => 0,
'version' => '0.2.22',
'version' => '0.2.23',
'constraints' => [
'depends' => [
'typo3' => '7.0.0-9.5.99',
Expand Down

0 comments on commit 149c530

Please sign in to comment.