BackendConfigurationManager figures out wrong pid
For backend modules, in Configuration/BackendConfigurationManager.php:getCurrentPageId() we try to find the current pid. If we are in Web->, the id is readable via _GP('id'), everything is fine.
If we are outside Web->, there is no pid. The manager then tries to figure some useful pid out. It first looks for a page markes "is_siteroot" and then a sys_template marked "root". While the treeroot is id 0, the manager will usually use id 1, because this is, where the root template resides.
This causes problems with caching, because the core takes id 0 for "global" scope. For example the caches in "cf_cache_pagesection" are generated (and tagged) for pid 0, if no specific pid is given.
While the method is currently protected and I don't think too much people will have their configurationManager inherited, this still would be a breaking change. It's a bug, so breaking change would be ok, but some people mind find, it's not quiet the right time for that.
If that would be the case, I would propose deprecating this method and introducing a new one to deal with the pid correctly.
[BUGFIX] Assume pid 0 for global backend context
If outside from "Web", extbase modules try to figure out some pid,
while in reality there is just none. The core takes "0" in this
situations, for looking for typoscript templates and tagging
To enable extbase to use the core's cache entries, we should streamline
- Return 0, if no pid is set
- Remove needless unit-tests
Reviewed-by: Oliver Klee
Reviewed-by: Stefan Froemken
Tested-by: Stefan Froemken
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
#1 Updated by Ernesto Baschny almost 6 years ago
Felix, go ahead and change that, if it's wrong. This is internal and not API, so I doubt that extensions are extending it.
I don't understand what you mean with "While the treeroot is id 0, the manager will usually use id 1, because this is, where the root template resides". Maybe a patch in Gerrit will help us understand how you suggest to solve the problem.
Thanks for working on that!
#2 Updated by Felix Oertel almost 6 years ago
if we call a backend module outside "Web", it does not have a page selected. The core then assumes the pid "0", for example to look for typoscript templates or to tag the caches (cf_cache_pagesection e.g.).
Extbase instead looks for the first page with "Use as Root Page" set and, if there is none, for the page where the first typoscript template with "Rootlevel" set and takes that pid.
While I understand that intention, I don't think that makes any sense, because if no page is selected, it might be as wrong to take the first root-page / -template as it might to take the last one or any other page.
I would go for the cores approach ... if the pid is set, good, if not, use 0.