Review main Abandoned

74633[BUGFIX] Resolve SlugHelper base-case is never called

crell CR 0 V 0 Easy +1 −9 updated 05/13/22, 16:39

Commit message

Per PHPStan, the $counter === 100 case never happens as
the while loop stops before that. That's technically a bug,
and fixing the bug also resolves the PHPStan issue.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 2

Review log 810

  1. crell uploaded patch set 1 05/12/22, 17:30

  2. core-ci voted on patch set 1 V -1 05/12/22, 17:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27146

  3. crell rebased onto patch set 2 05/12/22, 19:58

  4. core-ci voted on patch set 2 V +1 05/12/22, 20:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27149

  5. Oli Bartsch commented on patch set 2 05/12/22, 22:14

    I'm actually quite sure this case happened, since there are test which cover the behaviour. The current patch is a change in this behaviour since the while loop is now also called for $counter=100, which did not happen before and also makes no sense because the result of $newValue is directly overwritten in the `$counter === 100` case.
  6. Oli Bartsch voted on patch set 2 CR -1 05/12/22, 22:15

  7. Stefan Bürk commented on patch set 2 CR -2 05/12/22, 23:49

    Reply

    Ack. For lookup, this is the corresponding test: https://github.com/TYPO3/typo3/blob/a8fd1882b4bce1b9c2e6ec50589cb987b985a5f9/typo3/sysext/core/Tests/Functional/DataHandling/Slug/SlugHelperUniqueTest.php#L43 This checks, that a uniqueId is appended instead of "-100". This is a bug in phpstan itself. So this should rather reported there. If it is fixed there, baseline entry will vanish after corresponding phpstan raise. See also: https://phpstan.org/r/8d530e31-7d7f-4c82-b2c9-576c80fd95e5 https://3v4l.org/i1DTZ (current) phpstan complains about it, but execution shows that current code is correct. Due the additional "isUnique()" callable check, the counter would not get "increased" to `101`, thus overriding the generated `-100` with the wanted uniqueid anyway. But in the end, it's one "needless" loop execition. Given the simplyfied code example without the check, changing the condition in the while shows that (and then making the if condition not called at all): https://3v4l.org/4nsO2 > That's technically a bug So yes, you are right. But not the core code, it's a phpstan bug. May you up to report it there ? (eventually using the two code example shared above for demonstration) ?
  8. crell commented on patch set 2 05/13/22, 14:40

    Reply

    Hm. I stepped through the code in Xdebug manually and it appears you are correct. PHPStan bug here: https://github.com/phpstan/phpstan/issues/7230 I guess we just close this issue then?
  9. Stefan Bürk commented on patch set 2 05/13/22, 16:33

    Reply Unresolved

    I would suggst, let's close/abandon this patch and close the issue on forge (with a comment that this has to be fixed in phpstan).
  10. crell abandoned the change 05/13/22, 16:39

    PHPStan bug, filed.