[BUGFIX] Fix keepItems and removeItems handling with 0 values 26/54626/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:24:25 +0000 (21:24 +0100)
commit2abc42447b3ac853885b411392f436f9460ef929
tree671721ae156384b94be4d8f2bb071a778d99fdfa
parent5657d12b2aeb2557115fc0ab0be37cd8971dd970
[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/54626
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
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