[BUGFIX] Fix keepItems and removeItems handling with 0 values 23/54623/2
authorHelmut Hummel <typo3@helhum.io>
Sun, 12 Nov 2017 18:27:49 +0000 (19:27 +0100)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Thu, 16 Nov 2017 20:22:37 +0000 (21:22 +0100)
commitc1543fc2d69dd40c22cc18df55f9b7db95006654
tree8e8c3ea4b27cdb6e1be63e844b73e0e44b3ce513
parentbb9c7729fab4cc24fcced55958f303374f571ade
[BUGFIX] Fix keepItems and removeItems handling with 0 values

TSConfig properties keepItems and removeItems are checked
with a weak in_array() test (third argument not set to true),
which leads to the situation, that arbitrary string values
are treated equal to integer 0

This is now fixed by flipping the array and check for the
array index. This works nicely because PHP silently
converts strings which look like integer to integer for the keys.

Tests are added which cover these cases and demonstrate
the failure before the change.

Resolves: #82980
Releases: 8.7, master
Change-Id: I544a221674fa89d302cb6c1bcca506847c6f7f0f
Reviewed-on: https://review.typo3.org/54623
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Jan Stockfisch <jan.stockfisch@googlemail.com>
Tested-by: Jan Stockfisch <jan.stockfisch@googlemail.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
typo3/sysext/core/Classes/Utility/ArrayUtility.php
typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php