diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5861b0b8d55..2d7b0d7ea94 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG for Sulu
==================
+* 1.6.36 (2020-08-26)
+ * BUGFIX #5415 [ContentBundle] Fix teaser-selection deselecting
+ * BUGFIX #5442 [AudienceTargetingBundle] Fix export data function of audience-target selection
+ * BUGFIX #5418 [MediaBundle] Store values from image crop as integers
+
* 1.6.35 (2020-07-30)
* BUGFIX #5435 [ContactBundle] Fix type of tag names for serialization of contacts
diff --git a/src/Sulu/Bundle/AdminBundle/Exception/InvalidRootTagException.php b/src/Sulu/Bundle/AdminBundle/Exception/InvalidRootTagException.php
new file mode 100644
index 00000000000..4f1b9500db8
--- /dev/null
+++ b/src/Sulu/Bundle/AdminBundle/Exception/InvalidRootTagException.php
@@ -0,0 +1,45 @@
+resource = $resource;
+ $this->rootTag = $rootTag;
+ }
+
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ public function getRootTag()
+ {
+ return $this->rootTag;
+ }
+}
diff --git a/src/Sulu/Bundle/AdminBundle/FormMetadata/FormXmlLoader.php b/src/Sulu/Bundle/AdminBundle/FormMetadata/FormXmlLoader.php
index 479f22b3bce..ce1df6b3ca0 100644
--- a/src/Sulu/Bundle/AdminBundle/FormMetadata/FormXmlLoader.php
+++ b/src/Sulu/Bundle/AdminBundle/FormMetadata/FormXmlLoader.php
@@ -11,6 +11,7 @@
namespace Sulu\Bundle\AdminBundle\FormMetadata;
+use Sulu\Bundle\AdminBundle\Exception\InvalidRootTagException;
use Sulu\Bundle\AdminBundle\FormMetadata\FormMetadata as ExternalFormMetadata;
use Sulu\Bundle\AdminBundle\Metadata\FormMetadata\FormMetadata;
use Sulu\Bundle\AdminBundle\Metadata\FormMetadata\LocalizedFormMetadataCollection;
@@ -69,6 +70,10 @@ protected function parse($resource, \DOMXPath $xpath, $type): LocalizedFormMetad
// init running vars
$tags = [];
+ if (0 === $xpath->query('/x:form')->count()) {
+ throw new InvalidRootTagException($resource, 'form');
+ }
+
$form = new ExternalFormMetadata();
$form->setResource($resource);
$form->setKey($xpath->query('/x:form/x:key')->item(0)->nodeValue);
diff --git a/src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/FormXmlLoaderTest.php b/src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/FormXmlLoaderTest.php
index 83dde2bce5e..91a011fcf03 100644
--- a/src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/FormXmlLoaderTest.php
+++ b/src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/FormXmlLoaderTest.php
@@ -12,6 +12,7 @@
namespace Sulu\Bundle\AdminBundle\Tests\Unit\FormMetadata;
use PHPUnit\Framework\TestCase;
+use Sulu\Bundle\AdminBundle\Exception\InvalidRootTagException;
use Sulu\Bundle\AdminBundle\FormMetadata\FormMetadataMapper;
use Sulu\Bundle\AdminBundle\FormMetadata\FormXmlLoader;
use Sulu\Bundle\AdminBundle\Metadata\FormMetadata\FormMetadata;
@@ -504,6 +505,16 @@ public function testLoadFormWithSizedSections()
$this->assertCount(1, $formMetadata->getItems()['name']->getItems());
}
+ public function testLoadFormInvalidRootTag()
+ {
+ $this->expectException(InvalidRootTagException::class);
+ $this->expectExceptionMessageRegExp('/"form"/');
+
+ $this->loader->load(
+ __DIR__ . \DIRECTORY_SEPARATOR . 'data' . \DIRECTORY_SEPARATOR . 'form_invalid_root_tag.xml'
+ );
+ }
+
public function testLoadFormInvalid()
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/data/form_invalid_root_tag.xml b/src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/data/form_invalid_root_tag.xml
new file mode 100644
index 00000000000..29f06deea2b
--- /dev/null
+++ b/src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/data/form_invalid_root_tag.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/src/Sulu/Bundle/AudienceTargetingBundle/Content/Types/TargetGroupSelection.php b/src/Sulu/Bundle/AudienceTargetingBundle/Content/Types/TargetGroupSelection.php
index aadabc349fa..dd576a48eb2 100644
--- a/src/Sulu/Bundle/AudienceTargetingBundle/Content/Types/TargetGroupSelection.php
+++ b/src/Sulu/Bundle/AudienceTargetingBundle/Content/Types/TargetGroupSelection.php
@@ -74,7 +74,7 @@ public function exportData($propertyValue)
return \json_encode($propertyValue);
}
- return [];
+ return \json_encode([]);
}
public function importData(
diff --git a/src/Sulu/Bundle/AudienceTargetingBundle/Resources/config/doctrine/TargetGroup.orm.xml b/src/Sulu/Bundle/AudienceTargetingBundle/Resources/config/doctrine/TargetGroup.orm.xml
index df2f972fde2..b0b14135490 100644
--- a/src/Sulu/Bundle/AudienceTargetingBundle/Resources/config/doctrine/TargetGroup.orm.xml
+++ b/src/Sulu/Bundle/AudienceTargetingBundle/Resources/config/doctrine/TargetGroup.orm.xml
@@ -2,10 +2,11 @@
-
-
+
@@ -16,16 +17,20 @@
-
+
-
+
diff --git a/src/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/TargetGroupSelection.php b/src/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/TargetGroupSelectionTest.php
similarity index 75%
rename from src/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/TargetGroupSelection.php
rename to src/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/TargetGroupSelectionTest.php
index e2765752a3e..c17d7820259 100644
--- a/src/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/TargetGroupSelection.php
+++ b/src/Sulu/Bundle/AudienceTargetingBundle/Tests/Unit/Content/Types/TargetGroupSelectionTest.php
@@ -119,4 +119,39 @@ public function testRemoveNotExisting()
$this->audienceTargetingGroups->remove($node->reveal(), $property->reveal(), 'sulu_io', 'en', null);
}
+
+ public function testExportData()
+ {
+ $this->assertEquals('[]', $this->audienceTargetingGroups->exportData(null));
+ $this->assertEquals('[]', $this->audienceTargetingGroups->exportData([]));
+ $this->assertEquals('[1]', $this->audienceTargetingGroups->exportData([1]));
+ }
+
+ public function testImportDataEmpty()
+ {
+ $node = $this->prophesize(NodeInterface::class);
+ $property = $this->prophesize(PropertyInterface::class);
+
+ $property->getName()->willReturn('test');
+
+ $property->setValue([])->shouldBeCalled();
+ $property->getValue()->willReturn([]);
+ $node->setProperty('test', [])->shouldBeCalled();
+
+ $this->audienceTargetingGroups->importData($node->reveal(), $property->reveal(), '[]', 1, 'sulu_io', 'en');
+ }
+
+ public function testImportData()
+ {
+ $node = $this->prophesize(NodeInterface::class);
+ $property = $this->prophesize(PropertyInterface::class);
+
+ $property->getName()->willReturn('test');
+
+ $property->setValue([1, 2])->shouldBeCalled();
+ $property->getValue()->willReturn([1, 2]);
+ $node->setProperty('test', [1, 2])->shouldBeCalled();
+
+ $this->audienceTargetingGroups->importData($node->reveal(), $property->reveal(), '[1, 2]', 1, 'sulu_io', 'en');
+ }
}
diff --git a/src/Sulu/Bundle/CoreBundle/DependencyInjection/Compiler/JmsObjectConstructorCompilerPass.php b/src/Sulu/Bundle/CoreBundle/DependencyInjection/Compiler/JmsObjectConstructorCompilerPass.php
new file mode 100644
index 00000000000..a1c2d228bbf
--- /dev/null
+++ b/src/Sulu/Bundle/CoreBundle/DependencyInjection/Compiler/JmsObjectConstructorCompilerPass.php
@@ -0,0 +1,33 @@
+getDefinition('jms_serializer.doctrine_object_constructor')->getDecoratedService()) {
+ return;
+ }
+
+ $container->removeDefinition('jms_serializer.object_constructor');
+ $container->setAlias('jms_serializer.doctrine_object_constructor', DoctrineObjectConstructor::class);
+ $container->setAlias('jms_serializer.object_constructor', 'jms_serializer.unserialize_object_constructor');
+ }
+}
diff --git a/src/Sulu/Bundle/CoreBundle/SuluCoreBundle.php b/src/Sulu/Bundle/CoreBundle/SuluCoreBundle.php
index 5ced4131509..f73eed5e8d5 100644
--- a/src/Sulu/Bundle/CoreBundle/SuluCoreBundle.php
+++ b/src/Sulu/Bundle/CoreBundle/SuluCoreBundle.php
@@ -13,6 +13,7 @@
use Sulu\Bundle\CoreBundle\DependencyInjection\Compiler\CsvHandlerCompilerPass;
use Sulu\Bundle\CoreBundle\DependencyInjection\Compiler\ExceptionHandlerCompilerPass;
+use Sulu\Bundle\CoreBundle\DependencyInjection\Compiler\JmsObjectConstructorCompilerPass;
use Sulu\Bundle\CoreBundle\DependencyInjection\Compiler\ListBuilderMetadataProviderCompilerPass;
use Sulu\Bundle\CoreBundle\DependencyInjection\Compiler\RegisterContentTypesCompilerPass;
use Sulu\Bundle\CoreBundle\DependencyInjection\Compiler\RegisterLocalizationProvidersPass;
@@ -51,5 +52,6 @@ public function build(ContainerBuilder $container)
);
$container->addCompilerPass(new ExceptionHandlerCompilerPass());
+ $container->addCompilerPass(new JmsObjectConstructorCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1024);
}
}
diff --git a/src/Sulu/Bundle/MediaBundle/Entity/FormatOptions.php b/src/Sulu/Bundle/MediaBundle/Entity/FormatOptions.php
index 8bd035486d5..8f9a1804fa9 100644
--- a/src/Sulu/Bundle/MediaBundle/Entity/FormatOptions.php
+++ b/src/Sulu/Bundle/MediaBundle/Entity/FormatOptions.php
@@ -55,7 +55,7 @@ class FormatOptions
*/
public function setCropX($cropX)
{
- $this->cropX = $cropX;
+ $this->cropX = (int) \round($cropX);
return $this;
}
@@ -79,7 +79,7 @@ public function getCropX()
*/
public function setCropY($cropY)
{
- $this->cropY = $cropY;
+ $this->cropY = (int) \round($cropY);
return $this;
}
@@ -103,7 +103,7 @@ public function getCropY()
*/
public function setCropWidth($cropWidth)
{
- $this->cropWidth = $cropWidth;
+ $this->cropWidth = (int) \round($cropWidth);
return $this;
}
@@ -127,7 +127,7 @@ public function getCropWidth()
*/
public function setCropHeight($cropHeight)
{
- $this->cropHeight = $cropHeight;
+ $this->cropHeight = (int) \round($cropHeight);
return $this;
}
diff --git a/src/Sulu/Bundle/MediaBundle/Media/FormatOptions/FormatOptionsManager.php b/src/Sulu/Bundle/MediaBundle/Media/FormatOptions/FormatOptionsManager.php
index fb787b0c3d2..4c647f4d040 100644
--- a/src/Sulu/Bundle/MediaBundle/Media/FormatOptions/FormatOptionsManager.php
+++ b/src/Sulu/Bundle/MediaBundle/Media/FormatOptions/FormatOptionsManager.php
@@ -121,8 +121,8 @@ public function save($mediaId, $formatKey, array $data)
if (!isset($formatOptions)) {
$formatOptions = new FormatOptions();
$formatOptions->setFileVersion($fileVersion);
- $fileVersion->addFormatOptions($formatOptions);
$formatOptions->setFormatKey($formatKey);
+ $fileVersion->addFormatOptions($formatOptions);
}
$formatOptions = $this->setDataOnEntity($formatOptions, $data);
diff --git a/src/Sulu/Bundle/MediaBundle/Tests/Unit/Media/FormatOptionsManager/FormatOptionsManagerTest.php b/src/Sulu/Bundle/MediaBundle/Tests/Unit/Media/FormatOptionsManager/FormatOptionsManagerTest.php
index a1dd35038ae..724da9b312b 100644
--- a/src/Sulu/Bundle/MediaBundle/Tests/Unit/Media/FormatOptionsManager/FormatOptionsManagerTest.php
+++ b/src/Sulu/Bundle/MediaBundle/Tests/Unit/Media/FormatOptionsManager/FormatOptionsManagerTest.php
@@ -196,10 +196,10 @@ public function testSave()
42,
'sulu-100x100',
[
- 'cropX' => 10,
- 'cropY' => 11,
- 'cropHeight' => 12,
- 'cropWidth' => 13,
+ 'cropX' => 10.05,
+ 'cropY' => 11.15,
+ 'cropHeight' => 12.12,
+ 'cropWidth' => 13.42,
]
);
diff --git a/src/Sulu/Bundle/PageBundle/Tests/Functional/Export/WebspaceExportTest.php b/src/Sulu/Bundle/PageBundle/Tests/Functional/Export/WebspaceExportTest.php
index eb3fe85a006..9ec11e5b212 100644
--- a/src/Sulu/Bundle/PageBundle/Tests/Functional/Export/WebspaceExportTest.php
+++ b/src/Sulu/Bundle/PageBundle/Tests/Functional/Export/WebspaceExportTest.php
@@ -501,7 +501,7 @@ private function getExportResultData($documents)
'audience_targeting_groups',
'target_group_selection',
false,
- $extensionData['excerpt']['audience_targeting_groups']
+ \json_encode($extensionData['excerpt']['audience_targeting_groups'])
),
],
];
diff --git a/src/Sulu/Component/Webspace/Manager/WebspaceManager.php b/src/Sulu/Component/Webspace/Manager/WebspaceManager.php
index e576cdc1343..babebcff755 100644
--- a/src/Sulu/Component/Webspace/Manager/WebspaceManager.php
+++ b/src/Sulu/Component/Webspace/Manager/WebspaceManager.php
@@ -467,8 +467,10 @@ protected function matchUrl($url, $portalUrl)
*/
private function createResourceLocatorUrl($portalUrl, $resourceLocator, $scheme = null)
{
+ $currentRequest = $this->requestStack->getCurrentRequest();
+
if (!$scheme) {
- $scheme = $this->defaultScheme;
+ $scheme = $currentRequest ? $currentRequest->getScheme() : $this->defaultScheme;
}
if (false !== \strpos($portalUrl, '/')) {
@@ -479,7 +481,6 @@ private function createResourceLocatorUrl($portalUrl, $resourceLocator, $scheme
$url = \rtrim(\sprintf('%s://%s', $scheme, $portalUrl), '/') . $resourceLocator;
// add port if url points to host of current request and current request uses a custom port
- $currentRequest = $this->requestStack->getCurrentRequest();
if ($currentRequest) {
$host = $currentRequest->getHost();
$port = $currentRequest->getPort();
diff --git a/src/Sulu/Component/Webspace/Tests/Unit/Manager/WebspaceManagerTest.php b/src/Sulu/Component/Webspace/Tests/Unit/Manager/WebspaceManagerTest.php
index 3ecbbc24019..1f01e1ac87a 100644
--- a/src/Sulu/Component/Webspace/Tests/Unit/Manager/WebspaceManagerTest.php
+++ b/src/Sulu/Component/Webspace/Tests/Unit/Manager/WebspaceManagerTest.php
@@ -700,6 +700,24 @@ public function testFindUrlsByResourceLocatorWithSchemeNull()
$this->assertEquals(['http://sulu.lo/test'], $result);
}
+ public function testFindUrlsByResourceLocatorWithSchemeFromRequest()
+ {
+ $request = $this->prophesize(Request::class);
+ $request->getHost()->willReturn('massiveart.lo');
+ $request->getPort()->willReturn(8080);
+ $request->getScheme()->willReturn('https');
+ $this->requestStack->getCurrentRequest()->willReturn($request->reveal());
+
+ $result = $this->webspaceManager->findUrlsByResourceLocator('/test', 'dev', 'en_us', 'massiveart');
+
+ $this->assertCount(2, $result);
+ $this->assertContains('https://massiveart.lo:8080/en-us/w/test', $result);
+ $this->assertContains('https://massiveart.lo:8080/en-us/s/test', $result);
+
+ $result = $this->webspaceManager->findUrlsByResourceLocator('/test', 'dev', 'de_at', 'sulu_io');
+ $this->assertEquals(['https://sulu.lo/test'], $result);
+ }
+
public function testFindUrlsByResourceLocatorRoot()
{
$result = $this->webspaceManager->findUrlsByResourceLocator('/', 'dev', 'en_us', 'massiveart');