Review main Merged

72904[BUGFIX] Avoid evaluating all regexp redirects if early match found

Stefan Bürk CR +2 V +2 Easy +34 −16 updated 01/14/22, 18:37

Commit message

ext:redirects middleware collected all possible redirects,
thus evaluating all regexp redirects to find possible matches.
These collected possible redirects are looped afterwards and
checked, if redirect is active, meaning not having any start
and/or end time constraints or if time constrain is in the active
timespan, returning the first feasible redirect. However this
evaluated all regexp redirects, even if flat redirects with query
arguments, flat redirects without query arguments or a regexp
redirect is found.

This patch changes this behaviour and checks early for found subset
of possible redirects to avoid evaluating at least all regexp
redirects even if an early one would be used anyway.

This is a minor performance improvement in case an early redirect
can be matched, without any effect if no match could be found.

Further performance improvements may be possible but should be done
in dedicated follow up patches.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Nikita Hovratov +1
    • Oliver Hader +1
    • Benni Mack +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1315

  1. Stefan Bürk uploaded patch set 1 01/07/22, 14:21

  2. Stefan Bürk marked it work in progress 01/07/22, 14:26

  3. core-ci voted on patch set 1 V +1 01/07/22, 14:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21776

  4. Stefan Bürk marked it ready for review 01/07/22, 14:55

  5. Stefan Bürk wrote 01/07/22, 14:56

    Topic set to Redirects
  6. Benni Mack updated the commit message in patch set 2 01/09/22, 12:57

  7. Benni Mack voted on patch set 2 CR +1 01/09/22, 12:57

  8. core-ci voted on patch set 2 V +1 01/09/22, 13:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21821

  9. Oliver Hader commented on patch set 2 CR +1 01/14/22, 14:07

    RedirectService.php:80

    `getFirstActiveRedirectFromPossibleRedirects` only uses active redirects. Maybe it's worth to extract `$activeRedirects` from `$allRedirects` here already and use those active items instead...
  10. Stefan Bürk commented on patch set 2 01/14/22, 14:31

    RedirectService.php:80 Reply

    Generally yes, but I had decided against that as this would end up in reading the whole cached multidimensional array, lopping over the whole structure and kicking off all "inactive" redirects and return a "cleanuped" copy of the orginial cached structure. ``` [ 'domain1' => [ 'flat' => ['key' => [...], 'key2' => [...]], 'respect_queryparameters => ['key' => [...], 'key2' => [...]], 'regexp' => ['key' => [...], 'key2' => [...]], ], 'domain2' => [ 'flat' => ['key' => [...], 'key2' => [...]], 'respect_queryparameters => ['key' => [...], 'key2' => [...]], 'regexp' => ['key' => [...], 'key2' => [...]], ], 'domain3' => [ 'flat' => ['key' => [...], 'key2' => [...]], 'respect_queryparameters => ['key' => [...], 'key2' => [...]], 'regexp' => ['key' => [...], 'key2' => [...]], ], 'domain4' => [ 'flat' => ['key' => [...], 'key2' => [...]], 'respect_queryparameters => ['key' => [...], 'key2' => [...]], 'regexp' => ['key' => [...], 'key2' => [...]], ], 'domain5' => [ 'flat' => ['key' => [...], 'key2' => [...]], 'respect_queryparameters => ['key' => [...], 'key2' => [...]], 'regexp' => ['key' => [...], 'key2' => [...]], ], 'domain6' => [ 'flat' => ['key' => [...], 'key2' => [...]], 'respect_queryparameters => ['key' => [...], 'key2' => [...]], 'regexp' => ['key' => [...], 'key2' => [...]], ], .... '*' => [ 'flat' => ['key' => [...], 'key2' => [...]], 'respect_queryparameters => ['key' => [...], 'key2' => [...]], 'regexp' => ['key' => [...], 'key2' => [...]], ], ] ``` Current solution would do this on matching "domain1" and "*", doing it as prposed beforehand it would do it for all of them. That would end up iteratating over the whole structure, and especially in installations with redirects of multiple also for all contained non-wildcard hosts, which on the otherhand would be a waste of "cleanup" time and task, as the current solution only takes current domain plus wildcard into account, iteratint them and stop on first active. I thought that this was the best compromise on each of these edge cases. Or did I missed a solution on here ?
  11. Nikita Hovratov voted on patch set 2 CR +1 01/14/22, 15:35

  12. Christian Kuhn commented on patch set 2 V +1 CR +1 01/14/22, 17:39

    RedirectService.php:80 Reply

    I'm fine with that. Since Lord Hader added +1 reading already, I guess he's fine, too.
  13. Nikita Hovratov voted on patch set 2 V +1 01/14/22, 18:18

  14. Christian Kuhn voted on patch set 2 V +2 CR +2 01/14/22, 18:37

  15. Christian Kuhn merged patch set 3 01/14/22, 18:37