Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-9337: Fixed failure to serialize field data post symfony/serializer 5.4.40 #466

Open
wants to merge 5 commits into
base: 4.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/contracts/Repository/Values/ValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Ibexa\Contracts\Core\Repository\Exceptions\PropertyNotFoundException;
use Ibexa\Contracts\Core\Repository\Exceptions\PropertyReadOnlyException;
use Symfony\Component\Serializer\Annotation\Ignore as SerializerIgnore;

/**
* The base class for all value objects and structs.
Expand Down Expand Up @@ -46,6 +47,8 @@ public function __construct(array $properties = [])
* @param array $dynamicProperties Additional dynamic properties exposed on the object
*
* @return array
*
* @SerializerIgnore()
*/
protected function getProperties($dynamicProperties = [])
{
Expand Down Expand Up @@ -201,6 +204,8 @@ final public function attributes()
* @param string $property
*
* @return bool
*
* @SerializerIgnore()
*/
final public function hasAttribute($property)
{
Expand Down
55 changes: 55 additions & 0 deletions tests/integration/Core/Repository/SerializationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Steveb-p marked this conversation as resolved.
Show resolved Hide resolved
declare(strict_types=1);

namespace Ibexa\Tests\Integration\Core\Repository;

use Ibexa\Tests\Integration\Core\RepositoryTestCase;
use Symfony\Component\Serializer\Encoder\JsonEncode;
use Symfony\Component\Serializer\SerializerInterface;

final class SerializationTest extends RepositoryTestCase
{
public function testSerialization(): void
{
$serializer = $this->getContainer()->get(SerializerInterface::class);
self::assertInstanceOf(SerializerInterface::class, $serializer);
$contentService = self::getContentService();

$user = $contentService->loadContent(14);
$field = $user->getField('user_account');
self::assertNotNull($field, 'Field "name" for admin user should not be null');

$result = $serializer->serialize($field, 'json', [JsonEncode::OPTIONS => JSON_PRETTY_PRINT]);
$passwordHash = '$2y$10$FDn9NPwzhq85cLLxfD5Wu.L3SL3Z\/LNCvhkltJUV0wcJj7ciJg2oy';
self::assertSame(
<<<JSON
{
"id": 30,
"fieldDefIdentifier": "user_account",
"value": {
"hasStoredLogin": true,
"contentId": 14,
"login": "admin",
"email": "[email protected]",
"passwordHash": "$passwordHash",
"passwordHashType": "7",
"passwordUpdatedAt": null,
"enabled": true,
"maxLogin": 10,
"plainPassword": null
},
"languageCode": "eng-US",
"fieldTypeIdentifier": "ezuser",
"fieldDefinitionIdentifier": "user_account",
"virtual": false
}
JSON,
$result,
);
}
}
Loading