Routing/Language: Refactoring the language system to simplify the code#5140
Routing/Language: Refactoring the language system to simplify the code#5140Hackwar wants to merge 56 commits intojoomla:stagingfrom
Conversation
|
SEF on: Switcher broken => Switching to another home page impossible As I have merged #5135, this will anyway need update |
|
Its updated. I will have a look at the rest later. |
|
Anyway, this would not be B/C at all. Also we would have other places in code where the prefix is used and not the language tag. Not for this series imho. |
|
Right now, it depends on your definition of BC. Because it still parses the old URLs and it also still processes the old URLs, since there are to many extensions out there, that are using the current Joomla style of generating these URLs. If you can live with the change for the current non-SEF URLs, then this is still BC. |
|
As long as we propose in Global Configuration SEF as an option, this would not be B/C. |
|
As I said earlier: The old URLs still work. We would only be introducing new URLs for the future. |
|
If existing URLs and features continue to work as they are today, there's no need for a config option IMO. |
|
With these latest changes, this would be B/C. These changes require #5264 to be applied, too. Besides these changes, I just wanted to make you aware of it that we are not using the language parameter of any article in our system right now in the routing... Actually, I searched the whole system and out of 35 files, we are only using the language parameter in 3 of those and there are maybe 10 files where we are not even using the category ID, thus making the resulting URL complete garbage. Will write a PR for that... |
|
Test: not good here SEF on: |
|
Please check this again. I invested several hours into this now to work mostly through it and this should be good now. I would call this merge-ready right now. Again, as I wrote earlier, this requires #5264 to work. @weeblr-dev Please have a look over this, too. Would this still work properly with your system? |
ok. I will add a PR after the merge here.
Thanks looks fixed with: Hackwar@b8127ed |
|
Regarding the bug: Again the old implementation gets us here. In the old implementation, the first part of the URL was always parsed as a language and in the actual parsing routine, nothing could majorly be broken. Now however, I was first checking if we were called via a POST request. If that is the case, the rest would not be checked. But a POST URL also contains a SEF part and thus we first need to discover that part and then check if we are called via POST. Please note that the last commit is really simply just a codestyle commit and does not require new tests. Now that we have 2 tests by @richard67 and @zero-24, could this be set to RTC? 😉 |
|
Hmm, from my point of view it is not only code style to remove this unused if, it is a refactoring. I trust you, but I know by experience from myself that errors can happen even with simple things. So I will retest anyway and let you know the result. |
|
@richard67 The code was the following: $found = false;
if (!$found) {
//do stuff
}That |
|
@Hackwar Yes, I just have checked it with Beyond Compare, which is a bit more useful than the stupid GitHub diff, and it looks safe. |
|
@Hackwar You know the code change above was clear to me also by the GitHub diff, but it was not so obvious if not accidently anything else had been changed within the if beside indention, e.g. because you have hit the del key with your head when falling asleep after this much work in this PR ;-) Maybe call me paranoid ;-) This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5140. |
|
No problem. |
|
@test successful - on my bilingual site everything still works after the latest change. Didn't detect any issue when switching languages with SEF enabled/disabled. |
|
@test tested it on a site with three different languages. Couldn't find any issues while looking around and testing the language stuff. Looks good to me. |
|
looks fine now here with my usual tests. |
|
Based on several testing i think we can move it to RTC now. Thanks to all for the hard work on this! This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5140. |
|
Thanks. Merged with a9c7eb2 |
|
Thank you |
Regression: remaining code from #5140 breaks multilanguage
The code for the current multi-language system is unnecessarily complex. This PR tries to improve on #5135 and simplify the code further.
Goal
This PR tries to achieve 4 goals:
Especially the last part should be discussed in this PR. The new code does not force you to always use one specific language, but allows you to switch between them. The behavior should be the following:
This means that a user that surfs a french website and then clicks on a link to a specific english page on the site, the user is not redirected to a french page with the english content inside or an error page or similar.
How to test
Simply apply the changes included in here and see that the URLs stay the same and the behavior for language handling is the way you expect it.
Routing changes
The above mentioned routing changes are primarily aimed at easing the code in other parts of Joomla. Currently, a URL is first created via a *HelperRoute class, which replaces the ISO language code from the content item with the corresponding SEF code. The language plugin, which right now is run before every other code in the routing process, takes that SEF code, compares it to the existing SEF codes, looks up the right language for it and then takes the SEF code from that language and adds it as part of the path in the URL. After that, it deletes the language code from the query, so that it is not available to the rest of the routing process anymore. Since the language is an important part of looking up the right Itemid, this means that the lookup of that part has to stay in the *HelperRoute class, instead of moving it to the component router itself.
Notice
I changed the above description massively on January 3rd, 2015 in order to make it better understandable. Between opening the PR with the first description and this updated description, the code was again extensively changed and thus the comments before #5140 (comment) are not valid anymore.