Project

General

Profile

Actions

Bug #105195

closed

Flexform configuration already resolved to array causes errors in form rendering

Added by André Buchmann about 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Category:
Form Framework
Target version:
-
Start date:
2024-10-04
Due date:
% Done:

100%

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

Description

Error Message:

(1/1) TypeError
TYPO3\CMS\Core\Utility\GeneralUtility::xml2array(): Argument #1 ($string) must be of type string, array given, called in /var/www/html/vendor/typo3/cms-form/Classes/Controller/FormFrontendController.php on line 94

in /var/www/html/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php line 1264

     * @return array|string If the parsing had errors, a string with the error message is returned. Otherwise an array with the content.
     * @see array2xml()
     * @see xml2arrayProcess()
     */
    public static function xml2array(string $string, string $NSprefix = '', bool $reportDocTag = false): array|string
    {
        $runtimeCache = static::makeInstance(CacheManager::class)->getCache('runtime');
        $firstLevelCache = $runtimeCache->get('generalUtilityXml2Array') ?: [];
        $identifier = md5($string . $NSprefix . ($reportDocTag ? '1' : '0'));

at TYPO3\CMS\Core\Utility\GeneralUtility::xml2array(array('settings' => array('persistenceIdentifier' => '1:/form_definitions/exampleofallFields.form.yaml')))
in /var/www/html/vendor/typo3/cms-form/Classes/Controller/FormFrontendController.php line 94

     * settings. For now, only finisher settings are overridable.
     */
    protected function overrideByFlexFormSettings(array $formDefinition): array
    {
        $flexFormData = GeneralUtility::xml2array($this->request->getAttribute('currentContentObject')?->data['pi_flexform'] ?? '');
        if (!is_array($flexFormData)) {
            return $formDefinition;
        }
        if (isset($formDefinition['finishers'])) {

I think the cause is rooted in the newly introduced record resolving, as the error just came up after updating TYPO3 in my test project from 13.2 to 13.3.x. The pi_flexform field data is now already parsed to an array, but the form still expects a string here.


Files

clipboard-202410071102-r22ry.png (241 KB) clipboard-202410071102-r22ry.png xdebug screenshot Modern André Buchmann, 2024-10-07 09:02
clipboard-202410071122-e4ivi.png (237 KB) clipboard-202410071122-e4ivi.png xdebug André Buchmann, 2024-10-07 09:22
form_xml2array_test.zip (11.2 KB) form_xml2array_test.zip Test scenarios André Buchmann, 2024-10-07 09:26
Actions #1

Updated by André Buchmann about 2 months ago

  • Related to Task #104514: Tame extbase ConfigurationManager added
Actions #2

Updated by Gerrit Code Review about 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86417

Actions #3

Updated by André Buchmann about 2 months ago

  • Related to deleted (Task #104514: Tame extbase ConfigurationManager)
Actions #4

Updated by André Buchmann about 2 months ago

  • Description updated (diff)

Updated by André Buchmann about 2 months ago

Test Setup

  1. Install this test extension
  2. Include Site-Set "schliesser/form-xml2array-modern" (it's designed to run without fluid_styled_content) instead of any db-based Typoscript record
  3. Create a form (e.g. from preset: Simple contact form (ext:form example))
  4. Add form-content element to your page and select the form
  5. We have now an array instead of an string here (see xdebug screenshot): https://github.com/typo3/typo3/blob/1179dd00c7ee735a53fa0e4a4d111892fb741ee4/typo3/sysext/form/Classes/Controller/FormFrontendController.php#L94-L94
  6. Switch to Site-Set "schliesser/form-xml2array-classic" to check the classic behavior based on fluid_styled_content

Result "Modern"
xdebug screenshot Modern

Result "Classic"
xdebug

Actions #6

Updated by Gerrit Code Review about 2 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86417

Actions #7

Updated by Gerrit Code Review about 2 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86512

Actions #8

Updated by André Buchmann about 2 months ago

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

Updated by Benni Mack about 1 month ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF