Review main Abandoned

71153[BUGFIX] Create auto-redirects after slug change using DataHandler

Stefan Bürk CR 0 V 0 Easy +15 −17 updated 02/10/23, 16:44

Commit message

In TYPO3 v10 creation of auto-redirects after slug change has been
added using database queries. Thus neither TCA defaults
have been respected nor hooks are implemented to achieve instance
specific adjustments.

Furthermore, the current implementation does not check if redirect
records are allowed to be created for (default) pages. This would
be done by DataHandler.

This patch adds 'sys_redirect' to allowedTables for default
pages, as they are created with pid if the slug has changed.
In addition, now DataHandler is used to create auto-redirects,
thus respecting TCA defaults, if not overridden by required
values or extension configuration.

Furthermore redirect cache is rebuild after creating auto-redirect
through the usage of datahandler.

Review

  • Code review CR 0
  • Verified V 0

Issues 2

Files 2

Review log 3241

Show 1216 earlier messages
  1. Stefan Bürk uploaded patch set 1 09/21/21, 07:28

  2. Mathias Brodala commented on patch set 1 CR -1 09/21/21, 07:37

    SlugService.php:163

    Can you use the more common "NEW" instead?

    SlugService.php:164

    There are spaces missing around the "=" here. Also you don't need to initialize $data like this, you can directly create it with the lone "sys_redirect" entry.

    SlugService.php:169

    These three can be dropped since they are set by the DataHandler already.

    SlugService.php:179

    Never seen such a check. Is there a case where the DataHandler would silently fail and make this check necessary?
  3. Stefan Bürk commented on patch set 1 09/21/21, 07:43

    SlugService.php:163 Reply

    Sry, what do you mean exactly ? Without the "_" or another Utillity/Method ?

    SlugService.php:179 Reply

    Yes, if backend user is not allowed to add records on that page - or recordes are not allowed on that page/doktype. Then it holds an error in the errorLog property and substNEWwithIDs is empty/not set. Have added sys_record to alllow for default pages - should we really ommit here a check ? Or is another kind of check prefered ?
  4. core-ci voted on patch set 1 V +1 09/21/21, 07:47 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16968

  5. Mathias Brodala commented on patch set 1 09/21/21, 07:47

    SlugService.php:163 Reply

    Yes, just drop the "_". It's minor but consistent with 90% of the remaining places. (In fact I only found 2 occurrences of "NEW_".)

    SlugService.php:179 Reply

    I just had another look and it looks like quite a few places more or less do the same check. So it should be fine.
  6. Stefan Bürk uploaded patch set 2 09/21/21, 08:04

  7. Stefan Bürk commented on patch set 2 09/21/21, 08:05

    SlugService.php:163 Reply

    done

    SlugService.php:164 Reply

    done (removed)

    SlugService.php:169 Reply

    done (dropped)
  8. Mathias Brodala commented on patch set 2 CR +1 09/21/21, 08:17

    SlugService.php:163 Reply

    Done

    SlugService.php:164 Reply

    Done

    SlugService.php:169 Reply

    Done
  9. core-ci voted on patch set 2 V +1 09/21/21, 08:26 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16971

  10. Johannes Seipelt voted on patch set 2 CR +1 09/21/21, 08:36

  11. Simon Schaufelberger updated the commit message in patch set 3 09/22/21, 01:18

  12. core-ci voted on patch set 3 V +1 09/22/21, 01:33 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17011

  13. Björn Jacob commented on patch set 3 CR -1 09/22/21, 09:02

    I do not understand the commit message. It is very hard to read. Here is my proposal: --- In TYPO3 v10 creation of auto-redirects after slug change has been added using database queries. Thus neither TCA defaults have been respected nor hooks are implemented to achieve instance specific manipulations. Furthermore, the current implementation does not check if redirect records are allowed to be created for (default) pages. This would be done by DataHandler. The patch adds 'sys_redirect' to allowedTables for default pages, as they are created with pid if the slug has changed. In addition, now DataHandler is used to create auto-redirects, thus respecting TCA defaults, if not overridden by required values or extension configuration. --- Do you like it?
  14. Stefan Bürk updated the commit message in patch set 4 09/22/21, 10:54

  15. Stefan Bürk commented on patch set 4 09/22/21, 10:55

    Reply

    Changed.
  16. core-ci voted on patch set 4 V +1 09/22/21, 11:08 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17025

  1. Johannes Seipelt voted on patch set 4 CR +1 09/22/21, 12:18

  2. Stefan Bürk commented on patch set 4 CR -1 09/27/21, 08:16

    This patch is blocked for now. We get two other patches in first, one with backport. Doing this and the and, as it will be master/v11 only.
  3. Stefan Bürk uploaded patch set 5 10/03/21, 17:02

  4. core-ci voted on patch set 5 V +1 10/03/21, 17:21 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17517

  5. Guido Schmechel commented on patch set 5 10/04/21, 19:06

    Tested in current master: - Setup an editor role without access for sys_redirect table and fields - Change a pagetitle with editor role ("Simulate user"), not a direct login - Failed in PHP 7.4 with "Cannot unpack array with string keys" / PHP 8 with "sprintf() does not accept unknown named parameters" Seems to be a problem after this patch: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70858 Why do we suddenly have too many arguments for logging? https://github.com/TYPO3/typo3/blob/master/typo3/sysext/core/Classes/Error/ErrorHandler.php#L254 (1/1) Error Cannot unpack array with string keys in /var/www/html/typo3/sysext/core/Classes/DataHandling/DataHandler.php line 8859 at TYPO3\CMS\Core\DataHandling\DataHandler->printLogErrorMessages() in /var/www/html/typo3/sysext/backend/Classes/Controller/EditDocumentController.php line 752
  6. Oli Bartsch rebased onto patch set 6 10/04/21, 20:53

  7. Helmut Hummel voted on patch set 6 CR +1 10/04/21, 21:08

  8. Andreas Kienast voted on patch set 6 CR +1 10/04/21, 21:12

  9. core-ci voted on patch set 6 V +1 10/04/21, 21:15 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17592

  10. Oli Bartsch commented on patch set 6 CR -1 10/04/21, 21:28

    Will update

    SlugService.php:185

    This is the default value

    SlugService.php:189

    This is the default value

    SlugService.php:190

    Will lead to a TypeError in case $record is NULL.
  11. Oli Bartsch uploaded patch set 7 10/04/21, 21:30

  12. Oli Bartsch commented on patch set 7 V +1 CR +1 10/04/21, 21:31

    SlugService.php:185 Reply

    Done

    SlugService.php:189 Reply

    Done

    SlugService.php:190 Reply

    Done
  13. Oli Bartsch commented on patch set 7 V 0 CR 0 10/04/21, 21:39

    With this patch, the automatic redirect creation only works in case the current user has permissions to create redirects. Is this intended?
  14. core-ci voted on patch set 7 V +1 10/04/21, 21:43 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17593

  15. Helmut Hummel voted on patch set 6 CR 0 10/04/21, 21:47

  16. Oli Bartsch commented on patch set 7 10/04/21, 22:06

    Reply

    This also relates to https://forge.typo3.org/issues/93370. The whole "automatic redirect generation" topic IMO needs some more conceptual work. For example, should automatic slug generation work for users not having necessary table modify permission? Should the "revert" option always work? If not, then the corresponding notification action should not be displayed, right?
  17. Stefan Bürk commented on patch set 7 CR -1 10/05/21, 05:22

    Thx Oliver and others for the review and the changes. -1 for now.

    Reply Unresolved

    No, this was not intended. The original intend was to use the defaults and implemented ways to define these defaults (TCA, ...) and give the possibility to hook into it. Secondly there was a todo to use DataHandler. And now I know why. Simply oversight of the permissions. Even if the decision is to go down to respect permissions, this patch has to be chaned to give propper feedback. Ack. We should work on the conceptual for "automatic redirects" first instead of nit-changing on several places without concept. Let's talk about this ... after lts and getting some breathings. Anywayy - saw that permission issue yesterday but shutdown the computer to fast, and forgot to give this patch myself -1 for now.
  18. Benni Mack wrote 11/29/21, 10:12

    Change destination moved from master to main
  19. Benni Mack updated the commit message in patch set 8 11/29/21, 13:37

  20. core-ci voted on patch set 8 V +1 11/29/21, 15:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20053

  21. Andreas Kienast rebased onto patch set 9 01/30/22, 10:58

  22. Andreas Kienast voted on patch set 9 CR +1 01/30/22, 10:58

  23. core-ci voted on patch set 9 V +1 01/30/22, 11:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22709

  24. Stefan Bürk commented on patch set 9 CR -1 01/30/22, 13:00

    Reply Unresolved

    reopening this -1 comment. this still stands
    Permission issue still exists as reported by Oliver. Has still be relooked and thought about that all. Thus reputting block -1.
  25. Stefan Bürk abandoned the change 02/10/23, 16:44

    There are some events in the making to circumence the permission issue. Will retry this at a later point, not feasonable right now.