Review main Merged

74353[BUGFIX] Avoid returning invalid return type in AbstractOEmbedHelper

Florian Rival CR +2 V +2 Easy +13 −8 updated 05/04/22, 21:43

Commit message

"AbstractOEmbedHelper::getOEmbedData()" requests data and
decode it as json. json_decode() may fail and thus having
a invalid type decoded. In the complete chain this lead to
a "access array offset on value type bool" warning.

This patch checks the decoded value before returning, thus
ensure valid return type is "array" or "null". Furthermore
this avoids a signature change of the corresponding method
"AbstractOEmbedHelper::getOEmbedData()". Additionally this
paves the way for adding proper return type in a dedicated
patch. Streamline usage in VimeoHelper along the way.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Oli Bartsch +1
    • Oliver Klee +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2629

Show 34 earlier messages
  1. Florian Rival uploaded patch set 1 04/19/22, 09:37

  2. core-ci voted on patch set 1 V -1 04/19/22, 10:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26177

  3. Oliver Klee commented on patch set 1 04/19/22, 10:24

    AbstractOEmbedHelper.php:64

    I think we can make this more specific: bool -> false
  4. Christian Efthimoglou commented on patch set 1 V +1 CR +1 04/27/22, 12:01

    Works for me with TYPO3 11.5.9.
  1. Oliver Klee commented on patch set 1 CR -1 04/27/22, 12:26

    VimeoHelper.php:57

    We need to fix the indentation of this block of code. (And there also seems to be a tab in the first changed line.)
  2. Florian Rival commented on patch set 2 04/27/22, 13:59

    Published edit on patch set 1.
  3. core-ci voted on patch set 2 V -1 04/27/22, 14:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26511

  4. Florian Rival commented on patch set 2 04/27/22, 14:13

    AbstractOEmbedHelper.php:64 Reply

    No because json_decode can return NULL, true or false.

    VimeoHelper.php:57 Reply

    Done
  5. Oliver Klee commented on patch set 2 04/27/22, 14:13

    VimeoHelper.php:53

    Do we also need to check whether $oEmbedData['thumbnail_url'] isset?

    VimeoHelper.php:57 Reply

    Done
  6. Oliver Klee commented on patch set 2 04/27/22, 14:26

    AbstractOEmbedHelper.php:64 Reply

    Done
  7. Florian Rival commented on patch set 2 04/27/22, 14:30

    Don't know if it's necessary but should be better. I've done it.
  8. Christian Efthimoglou voted on patch set 2 V +1 CR +1 04/28/22, 07:47

  9. Oli Bartsch commented on patch set 2 04/28/22, 10:45

    AbstractOEmbedHelper.php:64

    What do you think about ensuring the currently declared return types instead of adding even more?
  10. Oliver Klee commented on patch set 2 04/28/22, 11:56

    AbstractOEmbedHelper.php:64 Reply

    I'd be fine either way, but would prefer ensuring the declared types.
  11. Oli Bartsch commented on patch set 2 05/04/22, 21:06

    AbstractOEmbedHelper.php:90

    This is a change in behaviour because the if is true as soon as $oEmbed is an array, even if it's an empty array.
  12. Oli Bartsch commented on patch set 2 05/04/22, 21:07

    AbstractOEmbedHelper.php:50

    Since we only access $embed['title'] in the magic "empty()" method, the is_array check is superfluous.
  13. Stefan Bürk uploaded patch set 3 05/04/22, 21:07

  14. Oli Bartsch commented on patch set 2 05/04/22, 21:08

    VimeoHelper.php:53 Reply

    Actually I would just check for this field being not empty, like done for the "title" property in transformMediaIdToFile().
  15. Stefan Bürk uploaded patch set 4 05/04/22, 21:20

  16. Stefan Bürk uploaded patch set 5 05/04/22, 21:23

  17. Stefan Bürk updated the commit message in patch set 6 05/04/22, 21:25

  18. Oliver Klee voted on patch set 6 CR +1 05/04/22, 21:27

  19. Stefan Bürk uploaded patch set 7 05/04/22, 21:30

  20. Stefan Bürk commented on patch set 7 05/04/22, 21:32

    cancelled pipeline runs for patchset 3 to 6 .. so do not wonder why votings are missing for them.
  21. Oliver Klee voted on patch set 7 CR +1 05/04/22, 21:37

  22. core-ci voted on patch set 7 V +1 05/04/22, 21:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26848

  23. Oli Bartsch commented on patch set 7 V +1 CR +1 05/04/22, 21:41

    AbstractOEmbedHelper.php:50 Reply

    Done

    AbstractOEmbedHelper.php:64 Reply

    Done

    AbstractOEmbedHelper.php:90 Reply

    Done

    VimeoHelper.php:53 Reply

    Done
  24. Stefan Bürk voted on patch set 7 V +2 CR +2 05/04/22, 21:43

  25. Stefan Bürk merged patch set 8 05/04/22, 21:43