Skip to content

Fix block response for minOccurs=1 / maxOccurs=1 #7751

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
merged 2 commits into from
Feb 4, 2025

Conversation

Prokyonn
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Fixed tickets part of #7672
License MIT

What's in this PR?

Adjusts the response of the BlockPropertyResolver to return the single block instead of a list when minOccurs and maxOccurs are 1.

Why?

The behaviour should not be changed between Sulu 2.6 and 3.0.

@alexander-schranz alexander-schranz added the Bug Error or unexpected behavior of already existing functionality label Jan 27, 2025
Comment on lines 97 to 103
$minOccurs = $metadata->getMinOccurs();
$maxOccurs = $metadata->getMaxOccurs();

if (1 === $minOccurs && 1 === $maxOccurs && \count($contentViews) > 0) {
$contentViews = $contentViews[0]->getContent();
}

Copy link
Member

Choose a reason for hiding this comment

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

@benr77 can you test if this ends in the expected result?

Copy link

Choose a reason for hiding this comment

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

Yes, this is working correctly.

$maxOccurs = $metadata->getMaxOccurs();

if (1 === $minOccurs && 1 === $maxOccurs && \count($contentViews) > 0) {
$contentViews = $contentViews[0]->getContent();
Copy link
Member

Choose a reason for hiding this comment

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

@Prokyonn aren't we loosing the view now?

Copy link
Member Author

Choose a reason for hiding this comment

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

You were right, fixed it.

@alexander-schranz alexander-schranz merged commit fcef2c9 into sulu:3.0 Feb 4, 2025
8 of 9 checks passed
@benr77
Copy link

benr77 commented Feb 4, 2025

Confirmed this is working as expected :)

@alexander-schranz alexander-schranz added this to the Release 3.0 milestone Feb 13, 2025
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.

3 participants