Review main Merged

74828[BUGFIX] Work around type issues in Fluid

crell CR +2 V +2 Easy +2 −12 updated 07/07/22, 19:51

Commit message

Fluid's TagBuilder::getAttribute() is doc-typed as returning `string`,
but the description says it returns `?string`.  That meant PHPStan
believes the `$file !== null` check is unnecessary, when it actually is.
The TagBuilder class is not in core, though, but in the typo3fluid
vendored package, so it cannot be corrected from here.

However, the `$attributes` array is already requested above, and then
href/src is removed from it anyway because it's the same piece of data.
So just reading off of the array we already have and doing missing-value
handling there ourselves resolves the PHPStan issue, is slightly more
consistent with what the next line does (the unset() call), and is ever
so slightly faster as it skips a method call.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Vanessa Räbiger +1
    • Felix P. +1
    • Henning Liebe +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Vanessa Räbiger +1
    • Felix P. +1
    • Henning Liebe +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1415

  1. crell uploaded patch set 1 06/07/22, 22:43

  2. core-ci voted on patch set 1 V +1 06/07/22, 22:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27784

  3. Christian Kuhn commented on patch set 1 06/07/22, 22:59

    mmmh. let's better fix upstream. there are a couple of things fixed in fluid-main that will happify cores phpstan a bit more with next release.
  4. Christian Kuhn commented on patch set 1 06/07/22, 23:03

    or at least fix in fluid, too?
  5. crell commented on patch set 1 06/07/22, 23:06

    Reply

    Given the context of this code, I think doing both is a fine answer. (Since even without the type issue, calling getAttribute() right after getAttributes() is pointless.)
  6. Simon Schaufelberger voted on patch set 1 V +1 CR +1 06/20/22, 10:12

  7. Nikita Hovratov commented on patch set 1 06/24/22, 07:20

    no backport v11?
  8. Felix P. voted on patch set 1 V +1 CR +1 06/24/22, 09:53

  9. Henning Liebe voted on patch set 1 V +1 CR +1 06/24/22, 13:02

  10. Vanessa Räbiger voted on patch set 1 V +1 CR +1 06/24/22, 13:43

  11. Stefan Bürk commented on patch set 1 06/24/22, 17:12

    @larry: Maybe worth creating an issue at: https://github.com/TYPO3/Fluid/issues ? Would you take care of it in general ? (Would be up to @lolli/mbrodala to decide there then)
  12. crell commented on patch set 1 06/27/22, 16:58

    Reply

    Looks like it's already been fixed upstream: https://github.com/TYPO3/Fluid/blob/main/src/Core/ViewHelper/TagBuilder.php#L151 I still think this is a useful optimization here, though.
  13. Stefan Bürk voted on patch set 1 V +2 CR +2 07/07/22, 19:49

  14. Stefan Bürk commented on patch set 1 07/07/22, 19:51

    Normally not worth to mentioned it. This is normally such a small fraction in a request, even if it is technical correct. Not taking cached FE paged into account. Should only be mentioned if it is a real gain.
  15. Stefan Bürk merged patch set 2 07/07/22, 19:51