Review main Merged

61445[BUGFIX] Use `strpos()` over `strstr()`

Andreas Kienast CR +2 V +2 Normal +65 −73 updated 08/23/19, 09:54

Commit message

This patch replaces all usages of `strstr()` and its friends where the
existence of a certain substring is checked, but the result isn't used at
all with `strpos()`, which uses less memory.

Review

  • Code review CR +2 Done
    • Frank Nägler +2
    • Oliver Klee +1
    • Anja Leichsenring +1
  • Verified V +2 Done
    • Frank Nägler +2
    • Anja Leichsenring +1
    • TYPO3com +1 CI

Issues 1

Files 34

Show 14 more files

Review log 1314

  1. Andreas Kienast uploaded patch set 1 08/05/19, 14:36

  2. TYPO3com voted on patch set 1 V +1 08/05/19, 14:48 Completed build in 11m 45s on Mon, 5 Aug, 02:48 PM Test Summary: 47172 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35598

  3. Oliver Klee commented on patch set 1 CR -1 08/05/19, 17:02

    LinkService.php:118

    Here, we also need the comparison with false.
  4. Andreas Kienast commented on patch set 1 08/05/19, 17:21

    LinkService.php:118 Reply

    I'm not sure, since both "false" and "0" are not valid in an URN. I don't want to change too much of the original code to avoid nasty regressions.
  5. Oliver Klee commented on patch set 1 08/06/19, 11:14

    LinkService.php:118 Reply

    I think you might have misunderstood my comment. I was referring to change the code like this: strpos($urn, '://') -> strpos($urn, '://') !== false
  6. Andreas Kienast commented on patch set 1 08/06/19, 11:32

    LinkService.php:118 Reply

    No, I understood you correctly. This very change interchanges stripos() with strpos(), where the `!== false` check was missing as well. Again, an adjustment is a change of behavior of the code block which I refrain to do.
  7. Oliver Klee commented on patch set 1 08/06/19, 13:17

    LinkService.php:118 Reply

    If I see this correctly, you have added the === false or !== false in all other occurrences as well. Why add it in the other places, and not here?
  8. Andreas Kienast commented on patch set 1 08/06/19, 13:31

    LinkService.php:118 Reply

    Because those were calls to `strstr()` and alike before, that behave completely differently than strpos() does.
  9. Oliver Klee commented on patch set 1 CR +1 08/06/19, 15:11

    LinkService.php:118 Reply Unresolved

    Ah, now I see. Thanks.
  10. Claus Due commented on patch set 1 08/15/19, 07:13

    Nearly all cases of "stripos" can just as well be "strpos" which might be easier for people to understand; whenever "stripos() !== false" is used it is interchangeable with "strpos() !== false". For clarity and convention it might be best to homogenise every call that simply scans for presence of a byte, to use "strpos", and only ever use "stripos" when there is a performance concern, e.g. likelihood of encountering match in huge string is higher from end than start of string.
  11. Claus Due commented on patch set 1 08/15/19, 07:15

    > Patch Set 1: > > Nearly all cases of "stripos" can just as well be "strpos" which might be easier for people to understand; whenever "stripos() !== false" is used it is interchangeable with "strpos() !== false". > > For clarity and convention it might be best to homogenise every call that simply scans for presence of a byte, to use "strpos", and only ever use "stripos" when there is a performance concern, e.g. likelihood of encountering match in huge string is higher from end than start of string. Nevermind, I was thinking of strrpos.
  12. Anja Leichsenring voted on patch set 1 V +1 CR +1 08/19/19, 07:22

  13. Frank Nägler voted on patch set 1 V +2 CR +2 08/23/19, 09:54

  14. Frank Nägler merged patch set 2 08/23/19, 09:54