Skip to content

Fix return empty array if teaser selection property resolver data not matching #7922

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

Merged

Conversation

alexander-schranz
Copy link
Member

@alexander-schranz alexander-schranz commented Apr 28, 2025

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Fixed tickets fixes #
Related issues/PRs #7928
License MIT
Documentation PR sulu/sulu-docs#

What's in this PR?

Return always empty array for teaser selection if unexpected data was given the the property resolver.

Why?

If I switch a block type or change property xmls without a migration a teaser selection should return a empty array instead of the eventually false raw data of another type.

Currently this code snippet can error:

{% for teaser in content.teasers %}

as it might return null, string or something else.

@alexander-schranz alexander-schranz added the Bug Error or unexpected behavior of already existing functionality label Apr 28, 2025
@alexander-schranz alexander-schranz marked this pull request as ready for review April 28, 2025 09:24
@alexander-schranz alexander-schranz changed the title Fix return empty array if teaser selection type not matching Fix return empty array if teaser selection property resolver data not matching Apr 28, 2025
@@ -32,7 +32,7 @@ public function resolve(mixed $data, string $locale, array $params = []): Conten
|| !\array_key_exists('items', $data)
|| !\is_array($data['items'])
) {
return ContentView::create($data, $returnedParams);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a small test for this in the TeaserSelectionPropertyResolverTest ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prokyonn good catch 👍 added

@alexander-schranz alexander-schranz force-pushed the bugfix/teaser-selection-default branch from 8caa45c to 829ad8f Compare April 28, 2025 10:05
@alexander-schranz alexander-schranz merged commit df6e8b1 into sulu:3.0 Apr 28, 2025
9 checks passed
@alexander-schranz alexander-schranz deleted the bugfix/teaser-selection-default branch April 28, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Error or unexpected behavior of already existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants