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-6312: Fixed ParentContentType View Matcher for not available parent #438

Conversation

vidarl
Copy link
Contributor

@vidarl vidarl commented Oct 17, 2024

Question Answer
JIRA issue IBX-6312
Type bug
Target Ibexa version v3.3
BC breaks yes

This is a rebase of ezsystems/ezplatform-kernel#383 made for 3.3. But 3.3 is now out-of-maintenance

Description:

When matcher is checking parent's contenttype, it might throw NotFoundException if the parent is not available ( for instance if it is not available in any languages configured in the current siteaccess). I don't think the matcher should throw an exception in this case, just simply return false.
In dev, this NotFoundException will be shown to the user, while this will be handled by Ibexa\Bundle\Core\EventListener\ExceptionListener and a non-explaining 500 will be shown:
image

The change have no functional change on the front-end site access. User will anyway be given a 404 ( but the NotFound exception is no longer originating from the matcher). However, in admin-ui there is a big difference. A Landing page is not editable in admin-ui without the fix because the preview will be rendered with the front-end siteaccess scope and the matcher will then throw the exception

With this fix, user will see this in prod:
image

In dev, the preview controller will throw a BadState exception and look like this:
image

For QA:

See instructions in ticket for how to reproduce

Documentation:

No doc needed

@vidarl vidarl changed the base branch from main to 4.6 October 17, 2024 11:42
@vidarl vidarl changed the title IBX-6312 IBX-6312: View matcher ParentContentType should not throw execption if parent is not available Oct 17, 2024
@vidarl vidarl force-pushed the ibx-6312_view_matcher_ParentContentType_when_parent_is_not_available_4.6 branch from b0c081d to 64aedb4 Compare October 17, 2024 12:51
@vidarl vidarl requested review from a team and alongosz October 17, 2024 12:57
@vidarl vidarl changed the title IBX-6312: View matcher ParentContentType should not throw execption if parent is not available IBX-6312: View matcher ParentContentType should not throw exception if parent is not available Oct 17, 2024
$this->controllerChecker
$this->controllerChecker,
false,
null
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Ideally, logger calls should be checked (via Mock expectations). Missing log information would be an issue for a developer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Steveb-p : Added test in e3a7e61

@tomaszszopinski tomaszszopinski self-assigned this Nov 14, 2024
@tomaszszopinski tomaszszopinski force-pushed the ibx-6312_view_matcher_ParentContentType_when_parent_is_not_available_4.6 branch from 9bd5144 to 3d8c612 Compare November 15, 2024 09:29
Copy link

@tomaszszopinski tomaszszopinski left a comment

Choose a reason for hiding this comment

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

QA approved on IbexaDXP 4.6 commerce.

@tomaszszopinski
Copy link

🟢 ibexa/experience#509

@vidarl vidarl force-pushed the ibx-6312_view_matcher_ParentContentType_when_parent_is_not_available_4.6 branch from 3d8c612 to f7437ad Compare November 18, 2024 13:44
@alongosz alongosz changed the title IBX-6312: View matcher ParentContentType should not throw exception if parent is not available IBX-6312: Fixed ParentContentType View Matcher for not available parent Nov 18, 2024
Comment on lines 11318 to 11322
-
message: "#^Cannot call method warning\\(\\) on Psr\\\\Log\\\\LoggerInterface\\|null\\.$#"
count: 3
path: src/lib/MVC/Symfony/Controller/Content/PreviewController.php

Copy link
Member

Choose a reason for hiding this comment

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

This is an issue that needs to be resolved, not added to the baseline, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alongosz : Adam said I could solve it this way : #438 (comment)

How to do you want it fixed then ?

Copy link
Member

Choose a reason for hiding this comment

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

@vidarl ok, but then see #438 (comment) about how to handle expected "unresolvable" issues. Baseline is sort of "todo" list. On main we could tackle it with ?-> operator. Here we would need to use if or ||, so that might become unreadable indeed.

btw. for that reason I'm not a huge fan of traits, especially that one coming from PSR. They're meant to be very flexible which leads to such trivial issues.

But the solution could be as Steve described in the mentioned comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I had missed @Steveb-p comment in #438 (comment)

Moved error to phpstan.neon.dist in ad68fc7
Better ?

Copy link
Member

Choose a reason for hiding this comment

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

Moved error to phpstan.neon.dist in ad68fc7 Better ?

Almost 🙃
See: #438 (review)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alongosz and now? ref 025414d

@adamwojs
Copy link
Member

@vidarl Could you please rebase PR? CI has been fixed on base branch.

vidarl and others added 2 commits November 20, 2024 15:51
Co-authored-by: Paweł Niedzielski <[email protected]>
…ption if parent is not available - Added test of logging
@vidarl vidarl force-pushed the ibx-6312_view_matcher_ParentContentType_when_parent_is_not_available_4.6 branch from f7437ad to b859f6f Compare November 20, 2024 14:51
@vidarl vidarl force-pushed the ibx-6312_view_matcher_ParentContentType_when_parent_is_not_available_4.6 branch from 04da2e5 to ad68fc7 Compare November 21, 2024 12:41
Comment on lines 16 to 19
-
message: "#^Cannot call method warning\\(\\) on Psr\\\\Log\\\\LoggerInterface\\|null\\.$#"
count: 3
path: src/lib/MVC/Symfony/Controller/Content/PreviewController.php
Copy link
Member

Choose a reason for hiding this comment

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

@vidarl Please notice the exact format of the mentioned example: https://github.com/ibexa/product-catalog/blob/main/phpstan.neon.dist#L18
For generic not resolvable issues we skip count and path in phpstan.neon.

Copy link

@vidarl vidarl requested a review from alongosz November 27, 2024 13:01
@alongosz alongosz merged commit 312f7ea into 4.6 Nov 28, 2024
21 checks passed
@alongosz alongosz deleted the ibx-6312_view_matcher_ParentContentType_when_parent_is_not_available_4.6 branch November 28, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants