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-6504: Gracefully handled URL generation in RoutingExtension #389

Merged
merged 7 commits into from
Oct 26, 2023

Conversation

barw4
Copy link
Member

@barw4 barw4 commented Oct 19, 2023

Question Answer
JIRA issue IBX-6504
Type improvement
Target Ibexa version v3.3
BC breaks no

Related PR: https://github.com/ezsystems/ezplatform-page-fieldtype/pull/251

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (master for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ezsystems/engineering-team).

@barw4 barw4 self-assigned this Oct 19, 2023
@barw4 barw4 changed the title [WIP] IBX-6504: Used forcedLanguage parameter in RoutingExtension during preview [WIP] IBX-6504: Used forcedLanguageCode parameter in RoutingExtension during preview state Oct 19, 2023
@barw4 barw4 requested a review from alongosz October 20, 2023 09:32
@barw4 barw4 changed the title [WIP] IBX-6504: Used forcedLanguageCode parameter in RoutingExtension during preview state IBX-6504: Gracefully handled URL generation in RoutingExtension Oct 20, 2023
@barw4 barw4 requested a review from a team October 20, 2023 11:18
@barw4 barw4 changed the title IBX-6504: Gracefully handled URL generation in RoutingExtension IBX-6504: Gracefully handled URL generation in RoutingExtension Oct 20, 2023
@barw4 barw4 added the Improvement Changes not fixing or changing behavior label Oct 20, 2023
@barw4 barw4 requested a review from Steveb-p October 23, 2023 10:43
@micszo micszo self-assigned this Oct 23, 2023
@micszo
Copy link
Member

micszo commented Oct 24, 2023

Fix works when LP preview is empty (no block or no base lang). Otherwise exception persists but template changes (ezplatform-kernel/eZ/Bundle/EzPublishCoreBundle/Resources/views/pagelayout.html.twig -> ezplatform-page-fieldtype/src/bundle/Resources/views/default_layout.html.twig).

@barw4
Copy link
Member Author

barw4 commented Oct 24, 2023

@alongosz @konradoboza @Steveb-p @kisztof as @micszo noticed with the certain case the preview still wasn't able to be loaded. This is due to block rendering in a new language and loading old values if we are basing a new translation on an old translation. https://github.com/ezsystems/ezplatform-page-fieldtype/pull/251 + 124723a should handle this case

@micszo
Copy link
Member

micszo commented Oct 24, 2023

This unblocked the mentioned flow. 🙂

@alongosz
Copy link
Member

@barw4 so if page is translated into many languages that would hit performance badly as all 30 translations would be loaded. I'm not sure if there's API issue here or we use it incorrectly, but that doesn't feel like a good direction performance wise. Not sure what to suggest without looking deeper into this. What is exactly the error there and what and where we're trying to load that we shouldn't?

cc @ezsystems/php-dev-team

@barw4
Copy link
Member Author

barw4 commented Oct 24, 2023

@alongosz we have multiple calls like this (with Language::ALL) throughout the whole codebase so I'm a bit surprised this has become a problem of performance just now. Especially, if this will only in reality affect PB's previews. In the same request, we are having the exact same calls from other packages as well (for example https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/lib/FieldType/Page/ParameterProvider.php#L116).

To answer your question, this is basically the same case and comes down to loading Location, but now this is caused by blocks rendering https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/bundle/Resources/views/default_layout.html.twig#L8, specifically https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/lib/FragmentRenderer/BlockRenderOptionsFragmentRenderer.php#L121 and later https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/lib/FragmentRenderer/BlockRenderOptionsFragmentRenderer.php#L148. Situation is pretty much similar as ez_path - we cannot load Location in given Site Access when alwaysAvailable flag is false without an error.

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

@alongosz we have multiple calls like this (with Language::ALL) throughout the whole codebase so I'm a bit surprised this has become a problem of performance just now. Especially, if this will only in reality affect PB's previews. In the same request, we are having the exact same calls from other packages as well (for example https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/lib/FieldType/Page/ParameterProvider.php#L116).

To answer your question, this is basically the same case and comes down to loading Location, but now this is caused by blocks rendering https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/bundle/Resources/views/default_layout.html.twig#L8, specifically https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/lib/FragmentRenderer/BlockRenderOptionsFragmentRenderer.php#L121 and later https://github.com/ezsystems/ezplatform-page-fieldtype/blob/2.3/src/lib/FragmentRenderer/BlockRenderOptionsFragmentRenderer.php#L148. Situation is pretty much similar as ez_path - we cannot load Location in given Site Access when alwaysAvailable flag is false without an error.

I'm not fully convinced by "we're already doing it like that" argument, however maybe it's fine for now if @micszo tries to benchmark it a bit with e.g. content item with 30 translations? AFAIR test-fixtures already contain a lot of languages, creating such content might be a bit time consuming, so maybe some sort of command to loop over languages and create translations? ;)

@alongosz alongosz requested a review from a team October 26, 2023 10:37
@konradoboza konradoboza requested a review from a team October 26, 2023 10:38
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@micszo
Copy link
Member

micszo commented Oct 26, 2023

however maybe it's fine for now if @micszo tries to benchmark it a bit with e.g. content item with 30 translations?

Tested the flow by adding 30 translations to a Landing page with simple non-empty preview. Did not observe any significant increase in time when editing, previewing or publishing.

Copy link
Member

@micszo micszo 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 Ibexa Commerce 3.3.36-dev.

@micszo micszo removed their assignment Oct 26, 2023
@alongosz alongosz merged commit 8880cf8 into 1.3 Oct 26, 2023
26 checks passed
@alongosz alongosz deleted the ibx-6504-forcedLanguage-in-UrlAliasRouter-preview branch October 26, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Changes not fixing or changing behavior QA approved
Development

Successfully merging this pull request may close these issues.

6 participants