Review main Merged

77633[FEATURE] Introduce SlugRedirectChangeItemCreatedEvent

Stefan Bürk CR +2 V +2 Hard +421 −17 updated 02/02/23, 22:40

Commit message

A new PSR-14 based event "SlugRedirectChangeItemCreatedEvent"
is introduced, allowing extension authors to create additional
redirects for a changed page slug or to remove redirect source
candidates. This is especially useful to ensure creation of
related redirects. This can be used to create redirects for
special page types or sources build by fully respecting
configured route enhancers and decorators.

Custom source implementation must be provided based on already
available `RedirectSourceInterface`. Further events in later
steps of the process with dedicated follow-up changes will
reveal the full-power, which has been kicked-off with the
streamlining of #99188 and this change.

Current behaviour of creating redirects only based on the raw
slug value are kept by implementing a specific EventListener
for it. Extensions can replace the plain slug replacment source
by registering their listeners after the core listener.

TYPO3 core may implement and ship an additional source listener
for building source uri using the page router for page type "0",
therefore repspecting configured enhancers and decorators in a
dedicated patch.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Oli Bartsch +1
    • Benni Mack +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Oli Bartsch +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 9

Review log 2130

Show 35 earlier messages
  1. Stefan Bürk uploaded patch set 1 01/30/23, 05:37

  2. core-ci voted on patch set 1 V +1 01/30/23, 05:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36747

  3. Stefan Bürk uploaded patch set 2 V +1 01/30/23, 07:18

  4. Stefan Bürk uploaded patch set 3 01/30/23, 07:20

  5. core-ci voted on patch set 3 V +1 01/30/23, 07:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36751

  1. core-ci voted on patch set 2 V +1 01/30/23, 07:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36750

  2. Georg Ringer voted on patch set 3 V +1 CR +1 01/30/23, 07:44

  3. Oli Bartsch commented on patch set 3 01/30/23, 10:42

    I would like to see two additional tests for the new Event. 1. A test for the factory which ensures, the event is called properly 2. A test for the events' methods. You can have a look at latest introduced events for examples: E.g. https://review.typo3.org/c/Packages/TYPO3.CMS/+/77606/5/typo3/sysext/lowlevel/Tests/Functional/ConfigurationModuleProvider/GlobalVariableProviderTest.php and https://review.typo3.org/c/Packages/TYPO3.CMS/+/77606/5/typo3/sysext/lowlevel/Tests/Unit/Event/ModifyBlindedConfigurationOptionsEventTest.php
    or to remove
    useful to ensure
    by
    on
    available
    Further events
    registering their listeners after the core listener
    an
    building?

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:14

    This can IMO be skipped as it's include in the class name.

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:29

    when their listeners are registered and executed afterwards. See the example below.

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:33

    Can we skip this sentence and add replace the "it is recommended" with "it is required" in the previous sentence?

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:35

    I think this is far to technical for an RST. Also i tend to avoid terms like "easy" and similar.

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:110

    The new Event With the new :php:`SlugRedirectChangeItemCreatedEvent`, it's possible to manage the redirect sources for which redirects should be created. It furthermore allows to influence existing Core functionality.

    AddPlainSlugReplacementSource.php:25

    Lets mark this listener as @internal
  4. Stefan Bürk commented on patch set 3 CR -1 01/30/23, 10:47

    Reply

    Thanks for the example .. searched not long enough, just took the RedirectWasHit Event and listener tests as kind of example. Will extend them later.

    AddPlainSlugReplacementSource.php:25 Reply

    Missed that, ack.
  5. Stefan Bürk uploaded patch set 4 CR +1 V +1 01/31/23, 10:52

  6. Stefan Bürk updated the commit message in patch set 5 01/31/23, 10:54

  7. Stefan Bürk commented on patch set 5 01/31/23, 10:55

    Reply

    Done. Hope I fully tackled what you ment.

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:14 Reply

    Done

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:29 Reply

    Done

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:33 Reply

    Done

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:35 Reply

    Done

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:110 Reply

    Done

    AddPlainSlugReplacementSource.php:25 Reply

    Done
  8. core-ci voted on patch set 4 V +1 01/31/23, 11:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36812

  9. core-ci voted on patch set 5 V +1 01/31/23, 11:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36813

  10. Lina Wolf commented on patch set 5 01/31/23, 11:47

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:25

    Please use FQN when ever class is first mentioned in one file

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:31

    I have trouble understanding this sentence, it is a bit confusing

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:46

    I would maybe first show the implementation of the event listener and then the RedirectSourceImplementation. Also, do you need to implement it or is an anonymous class enough?
  11. Lina Wolf commented on patch set 5 01/31/23, 11:48

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:22

    This does not really give more information then the method name and parameters?

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:23

    How to unset? By setting it to null? This should be mentioned
  12. Stefan Bürk uploaded patch set 6 V +1 02/02/23, 07:39

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

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:22 Reply

    I cloned this basically from other event introduction changelog entries. Sure, it may be useless to state - if someone would lookup directly in the code. But than, why are we stating the methods here and in other places when people can lookup the code itself ?. And as it can be `null` it raises the wareness here, as the name of the getter alone would not reflect this. The descrtipn at least states that it can be null which the method name does not express. (and having a "getXXXorNull()" method name seems to be odd - codewise with the native type hints thats okay, for a changelog it's ok to express it here. Hope that's fine with you. However, changed that a bit along with the setter.

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:23 Reply

    Done

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:25 Reply

    Done

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:31 Reply

    Let's have a call on that - maybe I can explain it and you can help me with a better fitting description here than. Instead of having a long "try-to-explain-and-find-correct-wording" tree here.

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:46 Reply

    Ack on moving the example below the listener. Basically it's "ok" to add a anonymous class as source - however, it's still a kind of "custom implementation" as the anonymous class must implement the interface and therefor the defined methods doing something "usefull". I would put anonymous classes more into "advanced knowledge", especially in proper usage and knowing the pro/cons of it. Thus, I would say a "concrete" example here is better fit instead of a anonymous class. Looking forwared, I have plans to add further events to `ext:redirects` - and there it would be hard to proberly identify a "concrete" anonymous class (or it must add some kind of identification) whereas with concrete implementation of the source that can be done with a "simple" `instanceof check`. For know, core only implements the plain source - which can be removed deting by the class (as in the example). With anouter patch I plan to introduce a additional concrete core source implementation (which may be reused) for a specific source type. Still, using a concrete implementation here showcases, in addition to the later event, how do define here a concrete class and identify it later (for controlling the redirect record and data set based on that). I would advice against using a anonymous class here.
  14. core-ci voted on patch set 6 V +1 02/02/23, 07:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36916

  15. Lina Wolf commented on patch set 6 V +1 CR +1 02/02/23, 07:58

    Reviewed the Changelogentry, otherhave to review the patch

    Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.rst:31 Reply

    Ack Let as spoken let it keep like this for now
  16. Stefan Bürk uploaded patch set 7 CR +1 V +1 02/02/23, 20:20

  17. Oli Bartsch uploaded patch set 8 02/02/23, 20:43

  18. Oli Bartsch updated the commit message in patch set 9 02/02/23, 20:45

  19. Oli Bartsch voted on patch set 9 V +1 CR +1 02/02/23, 20:45

  20. core-ci voted on patch set 7 V -1 02/02/23, 20:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36934

  21. core-ci voted on patch set 8 V +1 02/02/23, 20:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36935

  22. core-ci voted on patch set 9 V +1 02/02/23, 20:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36936

  23. Benni Mack voted on patch set 9 V +1 CR +1 02/02/23, 21:46

  24. Stefan Bürk voted on patch set 9 V +2 CR +2 02/02/23, 22:40

  25. Stefan Bürk merged patch set 10 02/02/23, 22:40