Review main Merged

25249[TASK] Streamline usage of BackendUtility::getPagesTSconfig()

Philipp Gampe CR +2 V +2 Easy +4 −4 updated 01/20/14, 19:29

Commit message

Avoid calling BackendUtility::getPagesTSconfig() with default or useless
parameters.

Review

  • Code review CR +2
    • Benni Mack +2
    • Markus Klein +1
  • Verified V +2
    • Benni Mack +2
    • Markus Klein +1

Issues 1

Files 3

Review log 32

Show 7 earlier messages
  1. Mr. Jenkins commented on patch set 1 11/10/13, 13:02

  2. Wouter Wolters voted on patch set 1 CR +1 11/10/13, 13:14

  3. Markus Klein uploaded patch set 2 11/29/13, 16:57

  4. Markus Klein commented on patch set 2 CR -1 11/29/13, 16:58

    Sorry cherry picked wrong patch!!
  5. Markus Klein uploaded patch set 3 11/29/13, 16:59

  6. Markus Klein commented on patch set 3 CR -1 11/29/13, 17:02

    BackendUtility.php:1140

    no need for the else if you return above
  7. Mr. Jenkins commented on patch set 2 11/29/13, 17:11

  1. Mr. Jenkins commented on patch set 3 11/29/13, 17:11

  2. Philipp Gampe commented on patch set 3 11/29/13, 17:23

    BackendUtility.php:1140 Reply

    that would be another patch
  3. Markus Klein commented on patch set 3 11/29/13, 23:38

    I was wrong with my first comment, see there. But I have some doubts with the other changes.

    InlineElement.php:1613

    Hm, I'm not sure about this. The TRUE actually forces to recreate the TSconfig in getPagesTSconfig(). Maybe this was intended here?

    BackendUtility.php:1140 Reply

    Indeed, I was looking at the diff between set 1 and 3 (unintentionally) and it shows that this area was touched. So I thought let's change that too. But I now see that this area isn't touched at all.

    BackendUtility.php:3255

    Hm, this is actually a speed decrease. The BEgetRootLine is called twice now. Once inside getPageTSconfig and here again.

    InfoPageTyposcriptConfigController.php:91

    The empty string enforces to skip the caching in getPageTSconfig. Is this intended?
  4. Philipp Gampe commented on patch set 3 12/02/13, 16:07

    answered the comments Please keep in mind that this is a follow-up to the cache parsed pages TSconfig patch. I discovered those issues while checking all calls to getPagesTSconfig() in core.

    InlineElement.php:1613 Reply

    The cache in getPagesTSconfig was introduced just lately. The second value is checked with is_array() which evaluates to false which makes it use the default rootline which is just the same as used inside the cache. Thus also before the cache patch, this parameter was useless and did not have any effect. I guess this is just the result of copy pasting, because this is wrong in many extensions too.

    BackendUtility.php:3255 Reply

    No, because the return value of BEgetRootLine is cached, therefore this is as fast as a simple getter. However, getPagesTSconfig will parse the TS again if you provide the rootline (the default rootline). Calling the function without a rootline will make it serve the TSconfig from cache which is way faster than the extra function call. Note: Providing a rootline to getPagesTSconfig will make it ignore the cache.

    InfoPageTyposcriptConfigController.php:91 Reply

    The caching was just implemented lately. Before, the empty string just made is_array evaluate to false which means to use the default rootline. You may either pass an array (rootline) or NULL to the second parameter.
  5. Markus Klein commented on patch set 3 CR 0 12/02/13, 16:30

    InlineElement.php:1613 Reply

    fine, if the cached and the generated rootline match. ;-)

    BackendUtility.php:3255 Reply

    Ok, bust still moving this line, does not change anything. The rootline is either calculated inside of getPagesTSconfig and is then fetched from cache here, or, if the line stays were it was, it will be calculated in this call and will be fetched from cache in getPagesTSconfig.

    InfoPageTyposcriptConfigController.php:91 Reply

    Same here. If you say that the cached version at this point is fine and no recalculation is necessary the parameter can be changed.
  6. Philipp Gampe commented on patch set 3 12/02/13, 17:22

    InlineElement.php:1613 Reply

    Should do, because the call to get the rootline match.

    BackendUtility.php:3255 Reply

    Yes, but now getPagesTSconfig can make use of its internal cache, while I could not know about this fact before. Providing a rootline makes getPagesTSconfig ignore the cache.

    InfoPageTyposcriptConfigController.php:91 Reply

    Well, the parameter is about a custom (faked) rootline. Neither an empty string nor NULL are a rootline (in form of an array). Providing the NULL here just makes the function detect, that no rootline is used. Basically, an empty string is the wrong value for the second parameter; it must be either array or NULL.
  7. Markus Klein commented on patch set 3 CR +1 12/02/13, 18:55

    InfoPageTyposcriptConfigController.php:91 Reply

    Yes I know that. That's why I say: Since an empty string was specified formerly and only array|NULL is excepted now, this empty string triggers two things: First the cache of getPagesTSconfig is omitted and second the rootline is required (although the rootline might be cached already in will return quickly hence). Changing the parameter to NULL now, will enable getPagesTSconfig to use the internal cache, but this might be wrong, if the '' was done on purpose to force the skipping of the cache. So, if you know that the cache should be used here, it is obligatory to change the parameter to NULL. But if you don't know whether the cache is outdated at this point in the code and it has to be refreshed (by providing something else than NULL or array), then this must not be changed. But I assume you know what you did, so I give a +1 finally.
  8. Markus Klein rebased onto patch set 3 01/15/14, 14:36

  9. Markus Klein voted on patch set 4 CR +1 01/15/14, 14:37

  10. Markus Klein voted on patch set 4 V +1 01/15/14, 14:37

  11. Mr. Jenkins commented on patch set 4 01/15/14, 14:59

  12. Benni Mack commented on patch set 4 CR +2 01/15/14, 17:13

    any good idea on how to test this?
  13. Markus Klein commented on patch set 4 01/15/14, 17:32

    I fear you've to debug and see if the cache is being used or not.
  14. Markus Klein commented on patch set 4 V 0 01/15/14, 17:32

    Have to remove my v+1, forgot to run the functional tests
  15. Philipp Gampe commented on patch set 4 01/16/14, 08:46

    I cannot really test this. You have to take a look at the API before the cache introduction and how was used. Then you can verify (by reading) the the logic did not change. This is just a cleanup that makes sure that the API is not called with wrong parameters in order to make use of the cache logic (which kicks in only if not extra parameters are given).
  16. Stefan Neufeind commented on patch set 4 01/16/14, 22:48

    BackendUtility.php:3250

    Might that make a difference here? Is rootLine maybe empty (casted to false?) if $TScID is the root of a site?
  17. Markus Klein commented on patch set 4 01/16/14, 23:10

    BackendUtility.php:3250 Reply

    If $TScID is the root page then the rootline is NOT empty, but contains only the root page.
  18. Stefan Neufeind voted on patch set 4 CR +1 01/16/14, 23:24

  19. Philipp Gampe commented on patch set 4 01/18/14, 23:17

    BackendUtility.php:3250 Reply

    no the call in getPagesTSconfig() is the same: self::BEgetRootLine($id, '', TRUE) while $id is the value of $TScID The reason why I want to skip passing the rootline here is that the cache will be skipped if a rootline is given. Thus by not passing the rootline, we get the pageTS from the runtime cache. The rootline comes from cache too, therefore it is no problem to call BEgetRootLine in both functions.
  20. Markus Klein commented on patch set 4 V +1 01/19/14, 12:44

    Tests are running fine. I'd opt to merge this now, we'll see until beta5 if we get regressions or not.
  21. Markus Klein uploaded patch set 5 01/19/14, 13:00

  22. Mr. Jenkins commented on patch set 5 01/19/14, 13:14

  23. Markus Klein commented on patch set 5 V +1 CR +1 01/19/14, 13:28

    Sorry, I accidentally pushed a new version.
  24. Benni Mack commented on patch set 5 V +2 CR +2 01/20/14, 19:29

    Agreed, let's get it in. Had it running and it worked in my use-cases.
  25. Benni Mack merged patch set 6 01/20/14, 19:29