Review main Abandoned

72761[BUGFIX] Avoid calling methods on nullable `DataMapItem::getState()`

Florian Rival CR 0 V 0 Easy +7 −2 updated 12/17/24, 20:28

Commit message

`\TYPO3\CMS\Core\DataHandling\Localization\DataMapItem::getState()`
may be null. Calling directly method on the `getState()` emits a
native php error.

This patch adds proper checks before usage to avoid calling methods
on a non existant object.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 1

Review log 2027

Show 12 earlier messages
  1. Florian Rival uploaded patch set 1 12/21/21, 15:03

  2. core-ci voted on patch set 1 V -1 12/21/21, 15:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21356

  1. Benni Mack updated the commit message in patch set 2 12/22/21, 09:23

  2. core-ci voted on patch set 2 V -1 12/22/21, 09:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21385

  3. Anja Leichsenring rebased onto patch set 3 05/08/22, 10:31

  4. core-ci voted on patch set 3 V -1 05/08/22, 10:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26994

  5. Stefan Bürk uploaded patch set 4 05/10/22, 16:05

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

  7. Stefan Bürk voted on patch set 4 CR +1 05/10/22, 16:13

  8. Stefan Bürk wrote 05/10/22, 16:17

    Removed Code-Review+1 by Stefan Bürk
  9. Stefan Bürk commented on patch set 4 05/10/22, 16:19

    DataMapProcessor.php:407 Unresolved

    Maybe this should be more "$this->isApplicable()" instead - which additional checks if the table is translatable and has fields etc .... maybe we should have a deeper look into that.

    DataMapProcessor.php:1382 Unresolved

    Maybe this should be more "$this->isApplicable()" instead - which additional checks if the table is translatable and has fields etc .... maybe we should have a deeper look into that.
  10. Oliver Klee commented on patch set 4 05/10/22, 16:28

    DataMapProcessor.php:414

    From reading the code, $item->getState() returns a nullable object, not a boolean. So the check should be like this: $itemState = $item->getState() instanceOf … ? $item->getState()->export() : null; (Using non-booleans in a boolean condition is not so explicit and less clean.)
  11. Stefan Bürk commented on patch set 4 05/10/22, 16:33

    DataMapProcessor.php:414 Reply

    Ack.
  12. Stefan Bürk uploaded patch set 5 05/10/22, 23:33

  13. core-ci voted on patch set 5 V +1 05/10/22, 23:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27106

  14. Stefan Bürk commented on patch set 5 05/13/22, 01:31

    DataMapProcessor.php:414 Reply

    Done
  15. Oliver Klee voted on patch set 5 CR +1 05/13/22, 13:03

  16. crell commented on patch set 5 05/13/22, 17:28

    DataMapProcessor.php:414

    For main/v12, this can be simplified to `$item->getState()?->export();`, which also avoids double-calling getState().
  17. Stefan Bürk commented on patch set 5 05/13/22, 17:39

    DataMapProcessor.php:414 Reply

    I know. Can be done afterwards. This makes backporting a little bit easier. But right. will push a two version compatible version without the need to change it during the bootstrap.
  18. Stefan Bürk commented on patch set 5 CR -1 05/13/22, 17:47

    need to recheck something ...

    DataMapProcessor.php:414 Reply Unresolved

    Together with eventually other things. Have to research/look something more up here.
  19. Benni Mack updated the commit message in patch set 6 CR +1 V +1 05/03/23, 09:17

  20. core-ci voted on patch set 6 V -1 05/03/23, 09:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41391

  21. Oliver Hader rebased onto patch set 7 V -1 05/03/23, 11:53

  22. core-ci voted on patch set 7 V +1 05/03/23, 12:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41520

  23. Oliver Klee commented on patch set 7 10/08/23, 13:32

    How should we proceed here?
  24. Oliver Hader updated the commit message in patch set 8 V +1 10/18/24, 14:10

  25. Benni Mack abandoned the change 12/17/24, 20:28

    abandoning this change due to lack of feedback, can be revived once the issue is tackled again.