Project

General

Profile

Actions

Bug #70972

closed

Story #69617: FormEngine bugs

translated CE with FAL-relation throws error within flexform

Added by Patrick Astor over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2015-10-23
Due date:
% Done:

100%

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

Description

Related file: typo3_src/typo3/sysext/backend/Classes/Form/InlineRelatedRecordResolver.php

When trying to edit a translation-copy of a content-element with an fal-relation inside a flexform, we get an error,
because the core is trying to transform an xml to an array twice.

Example to reproduce:
- create Content-Element
- add an flexform which contains an element of type 'inline'
- add the CE to a page
- translate it
- try to edit the translation.

Uncaught TYPO3 Exception
#1: PHP Warning: substr() expects parameter 1 to be string, array given in /var/www/sources/typo3_src-7.5.0/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 2146 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/var/www/sources/typo3_src-7.5.0/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 107.

25 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "substr() expects parameter 1 to be string, array given", "/var/www/sources/typo3_src-7.5.0/typo3/sysext/core/Classes/Utility/GeneralUtility.php", 2146, array)
24 substr(array, 0, 200)

/var/www/sources/typo3_src-7.5.0/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
02144:   // Default output charset is UTF-8, only ASCII, ISO-8859-1 and UTF-8 are supported!!!
02145:   $match = array();
02146:   preg_match('/^[[:space:]]*<\\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/', substr($string, 0, 200), $match);
02147:   $theCharset = $match[1] ?: 'utf-8';
02148:   // us-ascii / utf-8 / iso-8859-1

23 TYPO3\CMS\Core\Utility\GeneralUtility::xml2arrayProcess(array, "", boolean)

/var/www/sources/typo3_src-7.5.0/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
02116:    $array = PageRepository::getHash($identifier, 0);
02117:    if (!is_array($array)) {
02118:     $array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
02119:     PageRepository::storeHash($identifier, $array, 'ident_xml2array');
02120:    }

22 TYPO3\CMS\Core\Utility\GeneralUtility::xml2array(array)

/var/www/sources/typo3_src-7.5.0/typo3/sysext/backend/Classes/Form/InlineRelatedRecordResolver.php:
00080:      if ($GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] === 'flex') {
00081:       $flexFormParts = FormEngineUtility::extractFlexFormParts($PA['itemFormElName']);
00082:       $flexData = GeneralUtility::xml2array($fieldValue);
00083:       /** @var  $flexFormTools  FlexFormTools */
00084:       $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);

Fix in the core helped:

typo3_src/typo3/sysext/backend/Classes/Form/InlineRelatedRecordResolver.php Row 82:
Old:
```
$flexData = GeneralUtility::xml2array($fieldValue);
```

New:
```
if (!is_array($fieldValue)) {
$flexData = GeneralUtility::xml2array($fieldValue);
} else {
$flexData = $fieldValue;
}
```

Actions

Also available in: Atom PDF