Skip to content

Sulu 3.0 Smart content is not resolving properties correctly #9069

Description

@KotaruS
Q A
Sulu Version 3.0.9
PHP Version 8.3.33
DB Version 10.11.7-MariaDB
Browser Version Chrome 151

Actual Behavior

Have a article smart_content property with configuration like this:

<property name="news" type="smart_content">
    <meta>
        <title lang="en">Atricles</title>
    </meta>
    <params>
        <param name="provider" value="articles" />
        <param name="max_per_page" value="6" />
        <param name="properties" type="collection">
            <param name="title" value="title"/>
            <param name="excerptTitle" value="excerpt.title"/>
            <param name="url" value="url"/>
            <param name="description" value="description"/>
            <param name="excerptDescription" value="excerpt.description"/>
            <param name="uuid" value="object.resource.uuid"/>
            <param name="authored" value="object.authored"/>
            <param name="image" value="image"/>
            <param name="template" value="object.templateKey"/>
        </param>
        <param name="present_as" type="collection">
            <param name="slider">
                <meta> 
                    <title lang="en">Slider</title>
                </meta>
            </param>
        </param>
    </params>
</property>

When this smart_content is resolved for a twig template the content.description is null even though article has a description filled.

Instead you get this:

"news" => [
    [
      "excerptTitle" => "Test"
      "excerptDescription" => "<p>test</p>"
      "uuid" => "01a06650-f727-7d6e-8528-0c199c037959"
      "authored" => "2026-09-03T08:09:37+00:00"
      "template" => "article"
      "title" => "image-name"
      "url" => "/media/9/download/image-name.jpg?v=1"
      "image" => array:35 [▶]
      "description" => null // incorrect null value
      "lastModified" => null
    ]
  ]

Expected Behavior

All content fields should be filled with correct values.

Example result:

"news" => [
    [
      "excerptTitle" => "Test"
      "excerptDescription" => "<p>test</p>"
      "uuid" => "01a06650-f727-7d6e-8528-0c199c037959"
      "authored" => "2026-09-03T08:09:37+00:00"
      "template" => "article"
      "title" => "image-name"
      "url" => "/media/9/download/image-name.jpg?v=1"
      "image" => array:35 [▶]
      "description" => "<p>Something ...</p>" // correct
      "lastModified" => null
    ]
  ]

Steps to Reproduce

Having the above configuration description will be overwritten by description within image. The error happens in
Sulu\Content\Application\ContentResolver\DataNormalizer\ContentViewDataNormalizer::recursivelyMapProperties()

During recursively mapping properties image is and array and thus stepped in here:

if (\is_array($value) && 'view' !== $key) {

Hovewer because of this line:

public function recursivelyMapProperties(
    ...
    $rootPath = $isRoot ? $rootSegments : ['content', ...$rootSegments];
    // @phpstan-ignore-next-line
    $this->propertyAccessor->setValue($data, $this->buildPropertyPath($rootPath), $value);
    ...

$rootPath is incorrectly set to ['content', 'description'] instead of ['content','image','description'] thus overwriting content.description.

Possible Solutions

When you change the order defined in smart_content properties the issue doesn't affect anything but that's a workaround. Ideally $rootSegments should also contain full path, e.g. content.image? I am not brave enough to suggest a fix to this because it's widely used function in Sulu and I don't know what else does it affect.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugError or unexpected behavior of already existing functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions