Project

General

Profile

Actions

Bug #56405

closed

GeneralUtility::revExplode returns unexpected result to getSingleField_typeFlex_draw()

Added by Georg Tiefenbrunn about 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend User Interface
Target version:
Start date:
2014-02-28
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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];


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #55564: Improve GeneralUtility::revExplode performanceClosedAndreas Wolf2014-02-01

Actions
Related to TYPO3 Core - Bug #55838: revExplode returns invalid values if no delimiter in stringClosedAlexander Stehlik2014-02-10

Actions
Actions #1

Updated by Georg Tiefenbrunn about 10 years ago

Related to Task #55564

Actions #2

Updated by Markus Klein about 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.

Actions #3

Updated by Gerrit Code Review about 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

Actions #4

Updated by Gerrit Code Review about 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

Actions #5

Updated by Gerrit Code Review about 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

Actions #6

Updated by Gerrit Code Review about 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

Actions #7

Updated by Markus Klein about 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #8

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF