Review main Merged

77535[BUGFIX] Verify early for valid auto redirect creation or slug update

Stefan Bürk CR +2 V +2 Normal +145 −2 updated 01/23/23, 18:10

Commit message

Automatically creating redirects on page slug changes and/or
updating children page slugs is bound to a SiteConfiguration.
This means that only pages which has a proper SiteConfiguration
up in the rootline and the corresponding configuration options
set should lead to processing them.

In the past this has been checked and handled late in the service
class `TYPO3\CMS\Redirects\Service\SlugService`. These checks are
still there for proper workflow determination.

With #99188 the `ext:redirects` auto create workflow has been
streamlined as a preparatin for upcoming features and events,
which introduced the `SlugRedirectChangeItem` as a modern data
transport container. This item is created by a corresponding
factory, which als determined and set the corresponding Site
and SiteLanguage object to the change item.

If no site configuration can be found, a `SiteNotFoundException`
is thrown and not properly handled. Some instances may use
`SysFolder` beneath root point (pid === 0) with subpages without
a proper site configuration created on the `SysFolder`. Through
the streamlining in #99188 this is not properly covered and the
`SiteNotFoundException` not properly handled.

This change catches the `SiteNotFoundException` in the factory
service and additionally verify the configuration options early
if a change should be handled or not. If no handling needed or
no SiteConfiguration found, the factory now returns null instead
of a `SlugRedirectChangeItem`.

Review

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

Issues 2

Files 5

Review log 1317

  1. Stefan Bürk uploaded patch set 1 01/23/23, 13:01

  2. Stefan Bürk updated the commit message in patch set 2 01/23/23, 13:05

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

  4. Oli Bartsch commented on patch set 2 01/23/23, 13:20

    Could we please cover this with a simple test?
  5. Stefan Bürk commented on patch set 2 CR -1 01/23/23, 13:32

    Reply

    will try ...
  6. core-ci voted on patch set 2 V +1 01/23/23, 13:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36466

  7. Stefan Bürk uploaded patch set 3 CR -1 V +1 01/23/23, 14:10

  8. Stefan Bürk commented on patch set 3 01/23/23, 14:17

    Reply

    Added some simple tests for the SlugRedirectChangeItemFactory to cover this. Decided against doing that in the SlugServiceTest class which is meant for directly testing the SlugService. However, SlugServiceTests does not really tests the "hook" itself in the complete working state. Added a @todo to the SlugServiceTest class that this should be changed or added as additional Hook tests. Had that on my todo list already to refactor the testing in ext:redirects a bit, and mabye that was the reason why not having tests for this bugfix in first place. So thank you for asking for them. Hope you are fine with these tests.
  9. core-ci voted on patch set 3 V +1 01/23/23, 14:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36471

  10. Christian Kuhn commented on patch set 3 01/23/23, 14:29

    SlugServiceTest.php:39

    clumsy ;)
  11. Stefan Bürk commented on patch set 4 V +1 01/23/23, 15:11

    Published edit on patch set 3.
  12. Stefan Bürk commented on patch set 4 01/23/23, 15:12

    Reply

    Done

    SlugServiceTest.php:39 Reply

    Done
  13. core-ci voted on patch set 4 V +1 01/23/23, 15:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36477

  14. Christian Kuhn voted on patch set 4 V +1 CR +1 01/23/23, 17:36

  15. Oli Bartsch voted on patch set 4 V +1 CR +1 01/23/23, 18:10

  16. Stefan Bürk voted on patch set 4 V +2 CR +2 01/23/23, 18:10

  17. Stefan Bürk merged patch set 5 01/23/23, 18:10