Review main Merged

38852[BUGFIX] Store page title information in cache

Markus Klein CR +2 V +2 Easy +14 −3 updated 04/27/15, 13:18

Commit message

Store page title information in page cache as well,
so we have a proper state when rendering partially cached pages.

On those pages *_INT objects might be present, which modify
the title and this has to be handled correctly.

Review

  • Code review CR +2
    • Andreas Kienast +2
    • Andreas Allacher +1
  • Verified V +2
    • Andreas Kienast +2
    • Andreas Allacher +1

Issues 1

Files 1

Review log 34

Show 9 earlier messages
  1. Markus Klein uploaded patch set 1 04/21/15, 16:36

  2. Markus Klein commented on patch set 1 CR -2 04/21/15, 16:39

    This is work in progress.
  3. Tilo Baller commented on patch set 1 04/21/15, 16:46

    TypoScriptFrontendController.php:3414

    what about just using if (empty($this->config['INTincScript_ext']['pageRenderer'])) instead? IMHO this revers condition exactly matches the case, when the several titles are overwritten by $pageRenderer->getTitle();
  4. Markus Klein commented on patch set 1 CR 0 04/21/15, 17:00

    seems to work for me now

    TypoScriptFrontendController.php:3414 Reply

    No the problem is that _INT objects may override this in line 3410 or 3412. At this point we do not know what happened to those values. The title might be changed by those objects on a partially cached page: * USER object (eg. tx_news), the title is already in the pageRenderer and must not be overwritten. * USER_INT object which must be able to override * no object that overrides the title, so the title has to be retained, similar to first case though.
  5. Markus Klein commented on patch set 1 04/21/15, 17:04

    I'll try another approach
  6. Markus Klein commented on patch set 1 04/21/15, 17:04

    No I'll not.
  7. Markus Klein uploaded patch set 2 04/21/15, 17:16

  8. Markus Klein commented on patch set 2 04/21/15, 17:18

    Testing instructions will be added to the forge ticket
  9. Tilo Baller commented on patch set 2 CR +1 V +1 04/22/15, 10:07

    Tested with 6.2.12. Thanks Markus!
  1. Alex Borodinov voted on patch set 2 CR +1 V +1 04/22/15, 12:32

  2. Alex Borodinov commented on patch set 2 04/22/15, 12:34

    TYPO3 6.2.12, title generation works as expected now, thnks Markus.
  3. Wouter Wolters voted on patch set 2 CR +1 04/22/15, 16:56

  4. Helmut Hummel commented on patch set 2 04/23/15, 15:13

    I can't really tell code wise, thus I suggest to write rendering tests that confirm that this bug is fixed and the bug that initially triggered action in this area is also fixed I tried to do so in my extension: https://github.com/helhum/typoscript_rendering/blob/master/Tests/Functional/RenderingTest.php I would like to help with that, but I'm currently not that much into concrete expectations what should work in what way. Maybe we can work together o that?

    TypoScriptFrontendController.php:3407

    I don't really understand this code, but what about $this->indexedDocTitle ?
  5. Markus Klein commented on patch set 2 04/23/15, 15:43

    TypoScriptFrontendController.php:3407 Reply

    $this->indexedDocTitle is actually not needed here, because it is not evaluated anymore. It is used a lot earlier only, hence _INT can't change this property in a useful manner. Maybe that's a bug on its own. The code itself was loading back the title into the two members in order to be able to regenerate the page title based on this information.
  6. Andreas Allacher commented on patch set 2 04/23/15, 17:09

    TypoScriptFrontendController.php:3381

    Not that important but above we are checking wether the page title or the alt page title has been modified, so it would be nice to have the correct comment here.

    TypoScriptFrontendController.php:3407 Reply

    What about non-core extensions that use indexedDocTitle, e.g. EXT:solr uses it during indexing. At least it is there: https://git.typo3.org/TYPO3CMS/Extensions/solr.git/blob/HEAD:/Classes/Typo3PageContentExtractor.php#l88 I don't think it bypasses cache either during indexing. However, I believe that ext is not yet compatible with current master anyway but might not be the only one.
  7. Andreas Allacher commented on patch set 2 04/23/15, 17:14

    TypoScriptFrontendController.php:3407 Reply

    On the other hand, even if it was changed it shouldn't matter for the title tag if it is not evaluated (did not check) I thought about it wrongly, when writing the previous comment. Because the indexedDocTitle shouldn'T be modified by regeneratePageTitle method.
  8. Andreas Allacher commented on patch set 2 04/23/15, 17:19

    TypoScriptFrontendController.php:3407 Reply

    What about other properties that are evaluated by the PageGenerator::generatePageTitle method like $tsfe->config['config']['noPageTitle'] $tsfe->config['config']['pageTitleFirst'] I mean it is unlikely a USER_INT will modify those values but... Regarding indexedDocTitle: $tsfe->config['config']['titleTagFunction'] is called by PageGenerator::generatePageTitle which means a userfunction can do basically anything at that point like reading a indexedDocTitle etc.
  9. Andreas Allacher commented on patch set 2 04/23/15, 17:22

    Wouldn't it be easier to avoid issues to not create the page title in the cachable section, if _INT objects are used, instead of checking whether we need to regenerate because as mentioned other extensions can do quite a lot at that point by e.g. using titleTagFunction.
  10. Andreas Allacher commented on patch set 2 04/23/15, 17:34

    Ok. I could be wrong but I think in this way it is actually breaking because e.g. one could set any global variable like $GLOBALS['__TEMP'] in a _INT object and then have a titleTagFunction which reads that variable and overrides the title if it is set. It might not be a likely scenario but it is possible. Even if not this scenario, I think it is possible that something else might be done by e.g. the titleTagFunction that fails. Btw. what do you mean with sitename is duplicated? Is the title tag set twice? If so, it might be easier to not create any titletag in the cached version if _INT objects are set.
  11. Markus Klein commented on patch set 2 04/23/15, 17:47

    TypoScriptFrontendController.php:3381 Reply

    The comment is still correct, just that it is only called if the title has indeed been modified.

    TypoScriptFrontendController.php:3407 Reply

    Generally any userfunc (be it _INT or not) might manipulate anything, yes. But actually it does not get the real information as the state of the system is only stored in the page renderer. The TSFE is not in the same state as it would be for an uncached page. TSFE is initialized "from scratch" at this point and misses all changes that might have been done by a cached userfunc (USER object). That was why I introduced the present code that pulled back some information from the page renderer into TSFE. Obviously this wrong in the sense that the title inside is actually the end-result after printing the title with all the possible options for it. That's also the reason why we get a double sitename currently. With the current patch the titleTagFunction will not be called again, this is true. This function is actually real PITA. While I consider it to be cached generally. It is the final function that would be able to modify the pageTitle again. So to make the perfect solution we need to call that userfunc again after dealing with _INT objects. This is indeed a flaw of this patch. Again, the _INT concept is broken in the sense of providing full and correct state to of the system to the _INT objects. We would actually need to capture the state of all global objects and rebuild that state here. The whole page-title fixing (which happened over 2 or 3 patches now btw) is just cosmetics as the actual problem - the wrong state - can't be tackled that easily. So the patch is correct in a sense that it captures a possible change of a page title by an _INT object and rebuilds the page title in such a case. Fixing the titleTagFunction is not so easy here as well, as we would need more parameters on the functions to control its execution. I'll try to take a look.
  12. Markus Klein commented on patch set 2 04/23/15, 18:06

    While I dislike the solution now myself again, it solves the issue for most cases I guess. In order to get the correct page title in all cases, we need to: * store all dependencies of the PageGenerator::generatePageTitle into the cache as well. (altPageTitle, various TS configs, which might have been modified by USER script) * reestablish this state again when processing the _INT scripts * generate the page title again with generatePageTitle
  13. Andreas Allacher commented on patch set 2 04/23/15, 18:08

    TypoScriptFrontendController.php:3381 Reply

    No I meant it is also called if the ->page['title'] is modified. Actually the original comment was wrong, just pointed it out.

    TypoScriptFrontendController.php:3407 Reply

    Hmm. OK. True the pageTitle function should be cached. Of course, with _INT objects that might not make that much sense. I agree with the whole _INT state. I had some issues there already, e.g. wanted to print the page title somehwere in the content after it was modified elsewhere. At the beginning I tried a marker replacement that worked fine because it happened after the plugins were rendered. Of course, it still didn't work if the corresponding plugin uses _INT. It is possible with the correct hooks, however, so although it is additional work it can be done. Thanks for the explanation. ---------------------- Something else does your change avoid a double sitename if the title was changed by _INT objects? Because that should result in the original title and the modified title to have been set if I understand the issue correctly. I am still a bit confused about it :) Not really tested anything yet, just looked at code change.
  14. Markus Klein voted on patch set 2 CR -1 04/23/15, 20:36

  15. Markus Klein uploaded patch set 3 04/23/15, 20:54

  16. Markus Klein commented on patch set 3 04/23/15, 21:18

    Ok, I like that one now best. (for the record: $tsfe->config is already restored from cache, so that works correctly.) Full testing instructions and test extension: https://forge.typo3.org/issues/66499#note-25
  17. Andreas Allacher commented on patch set 3 04/24/15, 05:51

    One thing that might still be problematic, will test sometime this afternoon If there is a USER and USER_INT plugin and a titleTagFunc that modifies the page title via e $GLOBALS value and now the USER plugin modifies the title by setting $GLOBALS but the USER_INT does not, this change most likely will be lost. However, this is not an issue as long as the USER_INT plugin modifies the title or there is no USER_INT plugin. It also is no problem as long as the plugin modifies the title correctly via e.g. setting ->altPageTitle. It is unlikely that if there is a USER_INT plugin and the cached one modifies the title but the USER_INT does not, especially in combination with using $GLOBALS instead of e.g. ->altPageTitle so I don't think it will affect many systems but maybe we should provide a corresponding .rst Otherwise this looks nice, but have to verify yet.
  18. Andreas Allacher commented on patch set 3 04/24/15, 17:05

    Will test tomorrow. Wanted to test today but spent more time with the locking change patch.
  19. Andreas Allacher commented on patch set 3 CR +1 V +1 04/26/15, 15:10

    No double stdWraps for page title now. Cached and _INT plugins can override page title with altPageTite titleTagFunction will also work all the time. If titlteTagFunction wants to access a $GLOBALS variable to modify the title and that variable was set using a cached plugin, it will fail if there is a _INT plugin. However, that didn't work previously anyway (at least to my checks, so nothing breaks) and the plugin should modify altPageTitle instead.
  20. Andreas Allacher commented on patch set 3 04/26/15, 15:13

    Furthermore, i prefer this patchset to the previous one, because the titleTagFunction and I also think this solution is more elegant in general.
  21. Andreas Kienast commented on patch set 3 V -1 04/27/15, 12:40

    I installed the provided plugin (see Forge ticket) and pasted the test TypoScript by Markus into a blanked page. "Cached plugin" and "Uncached plugin" are both active, the "title killer" is disabled. When I clear the FE cache, I switch to a browser that's not logged in in the backend. The first (uncached) load of the page shows the pageTitleSeparator as "::::". A reload of that page changes the pageTitleSeparator to ":". The page title itself stays "Un-Cached Plugin has modified Title".
  22. Markus Klein commented on patch set 3 04/27/15, 12:59

    The pageTitleSeparator problem is not related to this issue, but is a separate issue. See forge.
  23. Andreas Kienast commented on patch set 3 CR +2 V +2 04/27/15, 13:01

    As described in Forge, my found issue is not related to the patch.
  24. Andreas Kienast merged patch set 3 04/27/15, 13:01

  25. Andreas Kienast commented on patch set 4 04/27/15, 13:18

    Cherry Picked This patchset was cherry picked to branch TYPO3_6-2 as commit 004ab47c271a6b6bccc86d2d05f9801d31bb2a72