User tests: Successful: Unsuccessful:
This PR proposes a cleaned up structure for the application router. This is a work in progress and submitted as a PR to get feedback from the project community.
In the past, the application router was pretty messy with lots of hardcoded behavior and sometimes did some backtracking. This cleanup tries to make this easier to understand and easier to modify.
Parseing and building a URL applies the respective rules to the URI object given. To give the rules a bit of order, there are 3 steps per process, the BEFORE, DURING and AFTER step. For parseing, the URL would be cleaned up (decoding URL encoding, removing unnecessary index.php parts, etc.) in the BEFORE step, parse the URL into query elements in the DURING step and rename for example the pagination query element in the AFTER step.
For building a URL, finding the right Itemid would be a rule for the BEFORE step, creating the SEF URL would be done in DURING and cleaning up would be done in the AFTER step.
There are no SEF and RAW modes anymore, since the difference between the two is not as binary as the current system makes us want to believe. All URLs need the component preprocessor, enabling SEF URLs does not enable all features, etc. Instead, the behavior is read directly from the application object and should mainly be setup in the constructor of the class. That way, we are not checking a few thousand times if SEF is enabled for building a thousand URLs.
Instead of working with a JURI object, a $vars array and a variable storage in the router object itself, the routing in 4.0 should only work with a JURI object. There is still a variable storage in the router object, but the usage of that should be greatly reduced and the only reason to even use it anymore will be shown in the section below. In general, I'm trying to think of the router as something like a production line in a factory (or more mathematical: a bijection from one form to another) You put in a JURI object on one end and on each step of the process, that object gets transformed and molded into the final product.
Joomla right now supports three different types of input URLs with differing behaviors.
The new router should only have different behavior for 2 different types of input URLs.
This would mean that component routers would have to do the correct lookups for the Itemid, instead of simply relying on the current Itemid being injected. The reason is, that we simply don't know if the Itemid that a component router sees is the one being forcefully injected from the router because there was no Itemid or if that Itemid was intentionally given to us. Yes, this requires a little bit more work for component developers, but on the other hand we do provide a simplified view based component router which does this for you already.
This change should improve performance a little bit. By removing lots of old methods and cleaning up the code, we should see an overal improvement. At the same time, only checking for the enabled features upon creating the router object should also help a little bit. Doing some simple tests showed an increase in the parseing performance from 30ms to less than 20ms on the default testing data.
This change means 2 breaks in backwards compatibility:
JRouter and JRouterSite have been finished, as well as the unittests. With that, this PR is ready for primetime.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
This is really fun to do. I was just able to delete another 80 lines of code that was duplicate or completely unnecessary. With this last commit, the parseing of URLs is finished.
Labels |
Added:
?
|
Category | Libraries | ⇒ | Libraries Unit Tests |
The building of URLs is finished as well. We are now just missing the unittests...
Unittests are done, too. With that, this PR is ready for primetime. The error in the build is unrelated to this.
Of course, I don't really wanna do a monologue here. I'd be happy if people would join in.
Unittests have almost perfect code coverage, codestyle issues are fixed.
Just from installing and clicking around with the core components everything seems in good shape. Haven't really looked at the API changes yet so we'll see how that looks later.
I'm assuming the following PR will make it into J 3.7? https://issues.joomla.org/tracker/joomla-cms/11320
So I guess I'm wondering about the main differences between that PR and this one. I see this PR is under the J4 branch.
The other PR removes IDs from component routers. This PR removes fugly and broken code in a backwards incompatible way from the application router for Joomla 4.0.
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-10-05 18:54:53 |
Closed_By | ⇒ | wilsonge |
Added detach and getrules methods to JRouter and updated progress infos above.