-
-
Notifications
You must be signed in to change notification settings - Fork 213
Cache fallback pages #8544
Cache fallback pages #8544
Conversation
|
Agreed. Nevertheless, the query should already be cached by MySQL, so I don't think this will have that big an impact. |
|
727 Queries times 0.3 ms. You do the math yourself. :) |
|
You are right, the impact is huge! Very good find! I have adopted the fix in contao/core-bundle@f9d926d for version 4.2.5. Will also merge the PR for Contao 3. |
|
Totally agree, but one thing is flawed: The array must only contain the ID of the model, not the actual object. And retrieve it from the registry using a |
|
Updated to use the registry for that stuff (which I was actually building the API for when improving fetching from unique fields, dunno how I could forget about that :D) |
| parent::onRegister($registry); | ||
|
|
||
| // Register this model as being the fallback page for a given dns | ||
| if ($this->fallback && !$registry->isRegisteredAlias($this, 'dns-fallback', $this->dns)) |
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.
it should never be possible that there is already an alias for that value?
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.
Additionally, you're not checking if this is the root page.
| parent::onUnregister($registry); | ||
|
|
||
| // Unregister the fallback page | ||
| if ($registry->isRegisteredAlias($this, 'dns-fallback', $this->dns)) |
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.
This would unregister the not-fallback root page.
### 4.2.5 (2016-10-27) * Unlock members after password change (see contao/core#8545). * Register an alias for the language fallback page model (see contao/core#8544). * Correctly calculate the maximum length of tl_files.name (see contao/core#8536). * Correctly add the headline if a content element is versionized (see contao/core#8502). * Optimize the DCA sorting filter for date fields (see contao/core#8485). * Do not show version entries of deleted files (see contao/core#8480). * Redirect the empty URL depending on language and alias name (see contao/core#8498). * Apply `specialchars()` to widget attributes (see contao/core#8505). * Queue the requests when rebuilding the search index (see contao/core#8449). * Correctly determine the form field names in the file manager (see #600). * Correctly show the maximum file size in the form upload widget (see #595). * Correctly encode e-mail addresses in the text element (see #594). * Do not parse front end templates twice (see #599). * Correctly set host and scheme in the URL generator (see #592). * Correctly reload the page and file trees in "edit multiple" mode. * Correctly normalize the paths in the symlink command.
|
Merged in 8e9bdd7. |
I noticed that
PageModel::findWithDetails()executes a lot of very identical queries. I figured it was the query to fetch the fallback page. As you can see, whenever you callfindWithDetails(), Contao works up the tree and calls the fallback page for every page again, even though the information is already there. I inspected an Isotope installation where there was some heavy querying going on because of that. To give you some numbers: With this fix, the number of queries dropped from 1121 for a page to 394 ;-) So I consider this a quite important bugfix that should go into 3.5.