[RTM] Always fix the domain and language when generating URLs#8238
[RTM] Always fix the domain and language when generating URLs#8238leofeyer merged 13 commits intohotfix/3.5.7from
Conversation
|
Why do we need still the |
|
Also, can we add support for |
|
Thought about it, too. Maybe not in the bugfix release. |
|
What's the difference? If we always force domain, we always force the language… |
We do not need it, we just keep supporting it for BC. Not sure what people have used it for … |
To force the language, like the parameter says? If you don't have any front end context, how would you generate it correctly? :-) BTW: I think I have a better approach for your code performance wise which will be fully backwards compatible:
public function getLanguage()
{
// Ensure root page language is inherited if not set by save_callback (BC)
if ('' === $this->language) {
$this->loadDetails();
}
return $this->language;
}
Why in 3.5: Well, we have to change the handling because it's buggy at the moment but if we already change it then we should make it right :-) |
No front end context is required. It will set the language and domain based on
How is your code performing better? We'd still have to bubble up to the root page to check the domain, wouldn't we? |
|
Not to forget |
|
The PR is ready to merge now. Please review one last time. |
| $objDatabase = \Database::getInstance(); | ||
|
|
||
| // Get published pages | ||
| $objPages = $objDatabase->prepare("SELECT * FROM tl_page WHERE pid=? AND (start='' OR start<='$time') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1' ORDER BY sorting") |
There was a problem hiding this comment.
If I remember correctly, we intentionally do not use models here because of performance and memory …
There was a problem hiding this comment.
I don't remember anything alike. Has there been a ticket?
There was a problem hiding this comment.
I remember something like this as well. Cannot find it though but it sure is an issue with a lot of pages. Please do not change this!
There was a problem hiding this comment.
I have to change it to fix the initial problem.
There was a problem hiding this comment.
This will fail miserably, I tell you. This is a no go, I'm sorry.
There was a problem hiding this comment.
You are telling me this based on something you think you remember, which however is nowhere documented?
95b5a98 to
57abb98
Compare
de5e692 to
001fcd4
Compare
|
I have investigated a bit. Here are some findings of where not to use models:
Rebuilding the search index is not one of them. Also, I have debugged rebuilding the search index with and without models: With models Without models Using models requires 10% more memory, however, it also decreases the number of database queries and the number of rows which need to be transferred. @Toflar What exactly are your concerns? |
|
Try this on an installation with 3000 pages that are split over 12 domains times 4 languages (= 48 root pages). I think it's going to fail 😄 |
That's just not true. The last comment was "please test", so we don't know if anything changes. The major difference (in my opinion) is that the models will be kept in the registry indefinitely, whereas the database result will be removed from memory when not used anymore. |
|
Of course they were gone. We have tested the change extensively, we have just not commented in the ticket. But it was only closed two weeks after finding the bug. |
|
I tried to do some tests to back my use case and ended up with a regular page model requiring more or less 20kb of RAM. So for 3000 pages it would require about 60 MB RAM which is fine then I think :-) If they are split over 48 root pages it will certainly need quite a lot more memory but it should still be fine. So I guess my concerns are refuted :-) However, I still think, inheriting |
That's certainly something we should think about, but certainly not in the 3.5.7 patch release ^^ |
Yes, I'm totally with you on this one. However, that is a different issue. The problem is that storing the fields in the database is pretty cumbersome and also error-prone, because you have to keep it in sync when the root page changes. There are some solutions for this problem already and backbone87 has implemented one in #6193 (his initial issue was #6830). |
|
So now that we have settled this and that I have changed all you have suggested, can I merge the PR? |
|
Imho, yes. |
|
Ah, no, I cannot. I have not solved this issue brought up by @aschempp :( |
I have thought about exactly this, too 😄 I have not asked you though, because I also think it is a new feature. But we should definitely implement this! |
|
I have created a separate ticket: contao/core-bundle#452 |
|
Merged in c68d813. |
### 4.1.1 (2015-03-03) * Remove the "disable IP check" field from the back end settings (see #436). * Do not quote the search string in `FIND_IN_SET()` (see #424). * Always fix the domain and language when generating URLs (see contao/core#8238). * Fix two issues with the flexible back end theme (see contao/core#8227). * Correctly toggle custom page type icons (see contao/core#8236). * Correctly render the links in the monthly/yearly event list menu (see contao/core#8140). * Skip the registration related fields if a user is duplicated (see contao/core#8185). * Correctly show the form field type help text (see contao/core#8200). * Correctly create the initial version of a record (see contao/core#8141). * Correctly show the "expand preview" buttons (see contao/core#8146). * Correctly check that a password does not match the username (see contao/core#8209). * Check if a directory exists before executing `mkdir()` (see contao/core#8150). * Do not link to the maintenance module if the user cannot access it (see contao/core#8151). * Show the "new folder" button in the template manager (see contao/core#8138).


This PR fixed #8204 and all duplicate tickets for good (hopefully).