Bug #56405
closedGeneralUtility::revExplode returns unexpected result to getSingleField_typeFlex_draw()
100%
Description
While testing fluid_content with the latest TYPO3 6.2 master from GIT I noticed that containers (add multiple objects) in flexforms do not work. This is caused by malformed IDs in hidden input fields and the JS-Code.
As a working reference I used 'Bootstrap: Tabs' from http://bootstrap.typo3cms.demo.typo3.org/ (Page id=110, tt_content uid=344) running with TYPO3 6.1.7. An equal element is rendered in TYPO3 6.2 as
<input ... name="_ACTION_FLEX_FORMdata[tt_content][...][pi_flexform][data][tabs][lDEF][tabs][el][2]][_ACTION][" value="">
The malformed part is at the end: [el][2]][_ACTION]["
I tracked the problems down to \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode() which is called in
\TYPO3\CMS\Backend\Form\FormEngine::getSingleField_typeFlex_draw().
For $formPrefix = [data][tabs][lDEF][tabs][el][2]
` the call $s = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('[]', $formPrefix, 2);
in TYPO3 6.1 returns
$s = array 0 => '[data][tabs][lDEF][tabs][el' 1 => '2]'
TYPO3 6.2 returns
$s = array 0 => '[data][tabs][lDEF][columns][el][2]'
Since https://git.typo3.org/Packages/TYPO3.CMS.git/commit/7da40c0b10057128c9c5e691cd155c7f255d537e there are two problems:
1) revExplode() behaves inconsitent if $string has more than one character. If $count === 2 we do not use strrev() (which is what I would expect). If $count <> 2 multicharacter delimiters break at other positions. Imho we should to distinguish between strlen($delimiter) == 1 and > 1.
2) getSingleField_typeFlex_draw() explodes string as [a][b][c]
but defines []
as delimiter which ist totally misleading. Imho we should use the correct delimiter ][
(which at the moment only works with $count = 2).
After three hours of debugging I finally changed only three characters in \TYPO3\CMS\Backend\Form\FormEngine::getSingleField_typeFlex_draw() to get this working again:
- $s = GeneralUtility::revExplode('[]', $formPrefix, 2); - $actionFieldName = '_ACTION_FLEX_FORM' . $PA['itemFormElName'] . $s[0] . '][_ACTION][' . $s[1]; + $s = GeneralUtility::revExplode('][', $formPrefix, 2); + $actionFieldName = '_ACTION_FLEX_FORM' . $PA['itemFormElName'] . $s[0] . '][_ACTION]' . $s[1];
Updated by Markus Klein over 10 years ago
This is indeed a regression to the patch for revExplode().
And it is a lack of documentation that the delimiter has to be given "reversed" as well.
Updated by Gerrit Code Review over 10 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27926
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27926
Updated by Gerrit Code Review over 10 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27926
Updated by Gerrit Code Review over 10 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27926
Updated by Markus Klein over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset da36a43db93c917f3af203c20af3ce977ba33c4f.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed