Review main Merged

64623[BUGFIX] Fix unique slug when counter suffix fails

filigivuji filigivuji CR +2 V +2 Hard +251 −38 updated 02/03/21, 11:52

Commit message

A loop in the Slug "uniqueIn*" check is broken because
the comparison uses post-increment, and in case no valid
slug with a counter suffix is found, $counter will be 101,
not 100.

Review

  • Code review CR +2 Done
    • Anja Leichsenring +2
    • Christian Kuhn +1
  • Verified V +2 Done
    • Anja Leichsenring +2
    • Christian Kuhn +1
    • TYPO3com +1 CI

Issues 1

Files 3

Review log 2027

Show 12 earlier messages
  1. filigivuji filigivuji uploaded patch set 1 05/30/20, 23:12

  2. TYPO3com voted on patch set 1 V +1 05/30/20, 23:26 Completed build in 13m 31s on Sat, 30 May, 11:26 PM Test Summary: 73007 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3713

  1. Andreas Kienast voted on patch set 1 CR +1 05/31/20, 07:18

  2. Anja Leichsenring uploaded patch set 2 05/31/20, 13:48

  3. TYPO3com voted on patch set 2 V +1 05/31/20, 14:02 Completed build in 14m 13s on Sun, 31 May, 02:02 PM Test Summary: 72907 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3720

  4. filigivuji filigivuji commented on patch set 2 05/31/20, 14:32

    SlugHelper.php:391

    I don't quite get the fallback -- wouldn't this only work once? So if $rawValue is 'abc', and repeatedly creating slugs would yield in slugs 'abc', 'abc-0', 'abc-1', ..., 'abc-99', 'abc-<md5 of abc>', 'abc-<md5 of abc>', ... Shouldn't rather a random suffix be used?
  5. Stefan P commented on patch set 2 07/24/20, 07:45

    SlugHelper.php:391 Reply

    Yes, you are right. I have this in a real setup where we happen to have (way) more than 100 pages with the same name. All over 100 get the same slug because of this. This is a major issue. This should be something like $rawValue . microtime() . rand()
  6. Christian Kuhn commented on patch set 2 CR -1 07/30/20, 20:00

    If we add this additional param to the methods (which is then public api), we should have tests for what happens if it is set to 0 (expectation: an md5 suffix at first dubplicate match), and add exceptions if argument <0 (and test for the exception being thrown), and have an @param hint that reasonable low values should be set only (10.000.000 would create huge db load).

    SlugHelper.php:391 Reply Unresolved

    shordMD5(uniqid(mt_rand(), true)) should do (this is from getUniqId() of testing-framework BaseTestCase)
  7. Anja Leichsenring uploaded patch set 3 08/01/20, 09:47

  8. TYPO3com voted on patch set 3 V -1 08/01/20, 09:58 Completed build in 11m 05s on Sat, 1 Aug, 09:58 AM Test Summary: 3 of 73498 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4346

  9. Simon Gilli uploaded patch set 4 08/04/20, 20:17

  10. TYPO3com voted on patch set 4 V +1 08/04/20, 20:30 Completed build in 12m 30s on Tue, 4 Aug, 08:30 PM Test Summary: 72966 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4413

  11. Stefan P commented on patch set 4 08/05/20, 05:04

    SlugHelper.php:432

    buildSlugForUniqueInTable and buildSlugForUniqueInPid are basically identical (only the while check differs). Both logics should be merged into one to have a common mechanism that does not have code duplication.
  12. Simon Gilli uploaded patch set 5 08/05/20, 10:22

  13. Simon Gilli commented on patch set 5 08/05/20, 10:24

    SlugHelper.php:432 Reply

    Done
  14. TYPO3com voted on patch set 5 V +1 08/05/20, 10:34 Completed build in 11m 14s on Wed, 5 Aug, 10:34 AM Test Summary: 72966 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4416

  15. Anja Leichsenring voted on patch set 5 V +1 CR +1 08/12/20, 18:33

  16. Benni Mack updated the commit message in patch set 6 08/13/20, 12:01

  17. Benni Mack updated the commit message in patch set 7 08/13/20, 12:01

  18. TYPO3com voted on patch set 6 V +1 08/13/20, 12:13 Completed build in 12m 18s on Thu, 13 Aug, 12:13 PM Test Summary: 72995 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4619

  19. TYPO3com voted on patch set 7 V +1 08/13/20, 12:16 Completed build in 14m 30s on Thu, 13 Aug, 12:16 PM Test Summary: 72995 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4620

  20. Christian Kuhn voted on patch set 7 V +1 CR +1 08/25/20, 17:19

  21. Anja Leichsenring voted on patch set 7 V +2 CR +2 08/25/20, 17:20

  22. Anja Leichsenring merged patch set 8 08/25/20, 17:20

  23. Torben Hansen commented on patch set 8 02/03/21, 10:20

    IMO this patch should also have been backported to TYPO3 9.5, since it contains a critical bugfix (see comment from Stefan). The function buildSlugForUniqueInSite will return a non unique slug, when the iteration has reached 100 resulting in duplicate slug entries in the database.
  24. Benni Mack commented on patch set 8 02/03/21, 11:44

    I guess this is then related to https://forge.typo3.org/issues/92563 ?
  25. Torben Hansen commented on patch set 8 02/03/21, 11:52

    Reply

    Yes, it is. Problem starts at this line https://github.com/TYPO3/TYPO3.CMS/blob/9.5/typo3/sysext/core/Classes/DataHandling/SlugHelper.php#L404 All slugs generated after 100 iterations will get the same slug, because the shortMD5 will always return a non unique value.