Review main Merged

79575[BUGFIX] Consider more TMENU a-tag related config for runtime cache

Nikita Hovratov CR +2 V +2 Easy +13 −1 updated 07/04/23, 07:31

Commit message

Since the swap to LinkResult, the ATagParams and some more attributes
are cached independent of different configuration. This is now fixed by
adding the following configuration options to the md5 hash:

- TMENUITEM: ATagParams
- TMENUITEM: additionalParams
- TMENU: addParams
- TMENU: target

Note: Doing this weakens the usefulness of the runtime cache again
(especially for old-school TypoScript based menus). Another option would
be to add the attributes after the LinkResult generation (how it was
done before), but this would bypass possible Event manipulation.

Review

  • Code review CR +2 Done
    • Nikita Hovratov +2
    • Garvin Hicking +1
    • Stefan Bürk +1
    • Benni Mack +1
  • Verified V +2 Done
    • Nikita Hovratov +2
    • Garvin Hicking +1
    • Stefan Bürk +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 1

Review log 2127

Show 12 earlier messages
  1. Nikita Hovratov uploaded patch set 1 06/30/23, 21:13

  2. core-ci voted on patch set 1 V -1 06/30/23, 21:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43168

  1. Nikita Hovratov uploaded patch set 2 V -1 06/30/23, 21:29

  2. Nikita Hovratov uploaded patch set 3 06/30/23, 21:38

  3. core-ci voted on patch set 2 V -1 06/30/23, 21:43 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43169

  4. core-ci voted on patch set 3 V +1 06/30/23, 21:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43170

  5. Benni Mack commented on patch set 3 07/02/23, 18:54

    AbstractMenuContentObject.php:1202

    please also take "$this->mconf[showAccessRestrictedPages.]" (subarray) into account
  6. Benni Mack commented on patch set 3 07/02/23, 18:55

    I think we should proceed how it is now, and consider a cache at the LinkBuilder level, instead of this HMENU speciality.
  7. Nikita Hovratov uploaded patch set 4 V +1 07/03/23, 08:59

  8. Nikita Hovratov commented on patch set 4 07/03/23, 09:00

    AbstractMenuContentObject.php:1202 Reply

    Done
  9. Nikita Hovratov commented on patch set 4 07/03/23, 09:00

    Reply

    Yes, that's what I have thought as well.
  10. core-ci voted on patch set 4 V +1 07/03/23, 09:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43204

  11. Benni Mack voted on patch set 4 V +1 CR +1 07/03/23, 09:58

  12. Garvin Hicking commented on patch set 4 07/03/23, 12:17

    Thank you! Works for us, please see inline comment about maybe using serialize(), and only using it if necessary?

    AbstractMenuContentObject.php:1206

    May I suggest two changes to this; one being to use serialize() instead of json_encode() (should be roughly 50% faster), the other not calling those methods if an empty array is used. That would result in this code: $cacheId = 'menu-generated-links-' . md5( $key . ($altTarget ?: ($this->mconf['target'] ?? '') . (isset($this->mconf['target.']) ? serialize($this->mconf['target.']) : '')) . $typeOverride . $MP_var . ($this->mconf['addParams'] ?? '') . ($this->I['val']['additionalParams'] ?? '') . ((string)($this->mconf['showAccessRestrictedPages'] ?? '_')) . (isset($this->mconf['showAccessRestrictedPages.']) ? serialize($this->mconf['showAccessRestrictedPages.']) : '') . serialize($this->menuArr[$key]) . ($this->I['val']['ATagParams'] ?? '') . (isset($this->I['val']['ATagParams.']) ? serialize($this->I['val']['ATagParams.']) : '') );
  13. Nikita Hovratov commented on patch set 4 07/03/23, 12:41

    AbstractMenuContentObject.php:1206 Reply

    I'm ok with adding conditions to prevent unnecessary functional calls, but I'm not sure with using serialize. This was changed before to json_encode from serialize because of some reasons I'm not aware of. Maybe @benni knows it?
  14. Nikita Hovratov uploaded patch set 5 CR +1 V +1 07/03/23, 12:51

  15. Nikita Hovratov uploaded patch set 6 07/03/23, 12:52

  16. core-ci voted on patch set 6 V +1 07/03/23, 13:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43229

  17. core-ci voted on patch set 5 V -1 07/03/23, 13:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43228

  18. Stefan Bürk commented on patch set 6 07/03/23, 13:18

    AbstractMenuContentObject.php:1206 Reply

    > (should be roughly 50% faster) Do you have some benchmarks or resources baking this statement? I remember that Larry had done benchmarks, and I read quite some also which says bascially the opossit. For a pure encoding the json_encode() is faster, specially with raising data sizes. As we do not need a revert (decode). If decode would be an option it would be another point. That have changed over time, in earlier php versions the serialize() have been faster on a pure serialize()/encode() comparision, Sadly, I have the bookmark not with me atm. What I could found on a quick research: * https://medium.com/@moinuddinchowdhury/serialize-vs-json-67fe872a7755 * https://stackoverflow.com/questions/804045/preferred-method-to-store-php-arrays-json-encode-vs-serialize Other point would be to rething replacing `md5()` with `hash('xxh3', ...)` as this has is quicker on that level. (Not sure because of backport).
  19. Garvin Hicking commented on patch set 6 07/03/23, 15:46

    AbstractMenuContentObject.php:1206 Reply

    Hi Stefan, hehe. Never trust stackoverflow, I learned (again...). Actually I used the same stackoverflow post and saw multiple people report PHP8 having faster serialize(), i.e. https://stackoverflow.com/questions/804045/preferred-method-to-store-php-arrays-json-encode-vs-serialize#comment119151993_804089. Running that code on 3v4l.org with PHP 8.2.7 actually shows it performs roughly the same with a margin of 1% of difference. Then I tried a benchmark of 1k calls of json_encode vs. serialize on this actual patch and got similar results. Both json_encode and serialize take around 0.029 seconds for 1.000 calls. So I'm sorry for that part of the excursion, so yeah, just keep json_encode for the sake of earlier reasoning. However - trying to only do that serializing if an actual data input is there, and not call it with an empty array argument, that should save a few op calls, especially when many links may be generated on cache warmup. Thanks, Garvin
  20. Nikita Hovratov commented on patch set 6 07/03/23, 16:42

    AbstractMenuContentObject.php:1206 Reply

    Thanks! Do you want to vote then? Together with Bennis vote we could merge it right away.
  21. Stefan Bürk voted on patch set 6 V +1 CR +1 07/03/23, 19:26

  22. Benni Mack voted on patch set 6 V +1 CR +1 07/03/23, 19:54

  23. Garvin Hicking voted on patch set 6 V +1 CR +1 07/03/23, 20:04

  24. Nikita Hovratov voted on patch set 6 V +2 CR +2 07/04/23, 07:17

  25. Nikita Hovratov merged patch set 7 07/04/23, 07:31