-
Notifications
You must be signed in to change notification settings - Fork 206
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
Fix Duplicated Siteaccesses in Generated URL. #2371
Conversation
This comment has been minimized.
This comment has been minimized.
ca44889
to
966e3e4
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
966e3e4
to
5ad199a
Compare
This comment has been minimized.
This comment has been minimized.
5ad199a
to
fa963f8
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
fa963f8
to
18b9d47
Compare
This comment has been minimized.
This comment has been minimized.
Hi @zerustech, nice to see you again :) Maybe we should archive/delete the older branches to make that more clear. Anyway, it might solve the php coding style errors you are getting here if you rebase or reopen on 6.7 for instance. There you will be able to run Best, |
18b9d47
to
1385a30
Compare
Hi @andrerom, Great to hear from you again :) Thanks for your feedback, I have fixed the cs issue and re-based this PR to 6.7 and I will re-base it to 6.13 and 7.x branches once it has been approved. In the meantime, I will close the other PR. Kind regards, Michael |
1385a30
to
e19488d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Michael. Thanks a lot for the report and bugfix.
Have you considered using a key in $parameters
for this ? It would avoid adding arguments to a method that implements a Symfony interface. We already use them to pass the siteaccess on in the same area.
A question: at which point does the UrlGenerator add the prefix again in the sequence ? I'd like to use something other than "ignore_siteaccess". It tells the router what to do. Ideally, it would provide it with an information, and the router would react by skipping the siteaccess prefix (ask, don't tell).
It works as it is, but trying to answer this point may help keep the architecture clear for the future.
Assume two siteaccesses, `eng` and `chi`, have been configured to support `eng-US` and `chi-CN` locales respectively. If an article at `/chi/news/article_1` only has `chi-CN` translation available, calling `path(ez_route(null, {language: 'eng-US'}))` in the template would output something like `/eng/chi/view/content/...`, which is incorrect because the `/chi` part should not be there. This issue occurs when `UrlAliasGenerator` has failed to generate the URL alias for the specific article in the target language, as the translation in the target language does not exist, so as the fallback generator, the `DefaultRouter` will be used to generate the internal URL for the article. However, by default, the `DefaultRouter` always prepends the siteaccess, which is `chi` in this case, to the genreated URL, and finally the `UrlAliasGenerator` will also prepend the target siteaccess 'eng' to the URL. To fix this issue, a new parameter 'ignoreSiteAccess' has been introducted in `$parameters` of `DefaultRouter::generate()`, which indicates if the `DefaultRouter` should ignore the stieaccess from the start of the URL it generates. | Question | Answer | ------------------ | ------------------ | **JIRA issue** | [EZP-29364](https://jira.ez.no/browse/EZP-29364) | **Bug** | yes | **New feature** | yes | **Target version** | `6.x`/`7.x` | **BC breaks** | no | **Tests pass** | yes | **Doc needed** | no **TODO**: - [ ] Implement feature / fix a bug. - [ ] Implement tests. - [ ] Fix new code according to Coding Standards (`$ composer fix-cs`). - [x] Ask for Code Review.
e19488d
to
563b1d1
Compare
Hi @bdunogier, Thanks for your feedback. Actually, it was my first choice as well, but I found the 'ignoreSiteAccess' parameter was exposed in the query string of the URL generated, so I implemented it with the extra argument. However, I just realized that it is safe to unset it from |
Hi @bdunogier
{# language is the language code of the target site-access #}
{% set path = path(ez_route(null, {language: language})) %}
...
As for the name of the parameter, please let me know when you have decided so that I can update the PR again. Kind regards, Michael |
Closing PR as obsolete. eZ Platform 2.5 has reached EOM, so please reopen PR in ezsystems/ezplatform-kernel (bug fixes) or ibexa/core (features/improvements) if issue is still valid for v3.3 / v4.x and you are willing to work on it. |
Assume two siteaccesses,
eng
andchi
, have been configured to supporteng-US
andchi-CN
locales respectively. If an article at/chi/news/article_1
only haschi-CN
translation available, callingpath(ez_route(null, {language: 'eng-US'}))
in the template wouldoutput something like
/eng/chi/view/content/...
, which is incorrectbecause the
/chi
part should not be there.This issue occurs when
UrlAliasGenerator
has failed to generate theURL alias for the specific article in the target language, as the
translation in the target language does not exist, so as the fallback
generator, the
DefaultRouter
will be used to generate the internal URLfor the article. However, by default, the
DefaultRouter
alwaysprepends the siteaccess, which is
chi
in this case, to the genreatedURL, and finally the
UrlAliasGenerator
will also prepend the targetsiteaccess 'eng' to the URL.
To fix this issue, a new parameter
$ignoreSiteAccess
has beenintroducted in argument
$parameters
ofDefaultRouter::generate()
, which indicates if theDefaultRouter
should ignore the siteaccess from the start of the URL it generates.6.x
/7.x
TODO:
$ composer fix-cs
).