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

difference in preview vs Sulu data object (array vs object) - settings property #117

Open
DanielRuf opened this issue Jul 21, 2022 · 8 comments
Labels
bug Error or unexpected behavior of already existing functionality
Milestone

Comments

@DanielRuf
Copy link

It looks like there is some difference in the settings property.

Is this already known, a bug, feature or something else due to typecasting?

preview:

image (4)

frontend:

image (2)

mage (3)

The logic seems to come from here:

https://github.com/sulu/SuluHeadlessBundle/blob/0.x/Content/ContentTypeResolver/BlockResolver.php#L73

$content[$i] = ['type' => $blockPropertyType->getName(), 'settings' => $blockPropertyType->getSettings()];

I guess in the preview it should also be an object? Not sure if it is because of the logic of getValue() for block properties combined with the normalization.

@alexander-schranz
Copy link
Member

Thx for reporting. Interesting that it is even a object on the website would it expected that if empty array also there how the code is written. But good to know that it atleast is correctly normalized there. I think we need to have a deeper look at it.

If you want to have a look at it it would be interesting what dump($blockPropertyType->getSettings()); returns you in the preview and what it returns on the website?

@DanielRuf
Copy link
Author

If you want to have a look at it it would be interesting what dump($blockPropertyType->getSettings()); returns you in the preview and what it returns on the website?

In which files and locations would that be for Sulu preview and Sulu headless output?

@alexander-schranz
Copy link
Member

The line you mention here: https://github.com/sulu/SuluHeadlessBundle/blob/0.x/Content/ContentTypeResolver/BlockResolver.php#L73

You can also use xdebug with a breakpoint there to debug it.

@DanielRuf
Copy link
Author

Hm, I'm a bit confused.

returns you in the preview and what it returns on the website

Is the same line called in both views?

@alexander-schranz
Copy link
Member

Is the same line called in both views?

Yes once you need to debug it in the preview and once when rendered on the website.

@DanielRuf
Copy link
Author

DanielRuf commented Jul 21, 2022

frontend:

image

preview:

image

Tested with var_dump since dump did not work for both, only for preview.

@alexander-schranz
Copy link
Member

Okay that helps a little bit. Would be itneresting where the stdClass comes from as that should also be the case then in the preview. But I think maybe its already saved that way and as the preview is not saved it is outputted this way. A workaround would be empty($settings) ? new \stdClass() : $settings at that line.

@DanielRuf
Copy link
Author

Would be itneresting where the stdClass comes from as that should also be the case then in the preview.

Definitely interesting, yes.

But I think maybe its already saved that way and as the preview is not saved it is outputted this way.

Same happens when the page is saved + published.

image

A workaround would be empty($settings) ? new \stdClass() : $settings at that line.

Sounds like a feasible solution.

@alexander-schranz alexander-schranz added the bug Error or unexpected behavior of already existing functionality label Sep 26, 2022
@alexander-schranz alexander-schranz added this to the 1.0 Release milestone Sep 26, 2022
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

No branches or pull requests

2 participants