#104962TypeError in xml2array if flexform is NULL
Description
If no flexform value has been entered, then it is stored as NULL in the database table.
This however leads to a TypeError in PHP 8.3.11.
(1/1) TypeError TYPO3\CMS\Core\Utility\GeneralUtility::xml2array(): Argument #1 ($string) must be of type string, null given, called in /path/typo3_src-13.2.1.test/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaFlexPrepare.php on line 104
in /path/typo3_src-13.2.1.test/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 1265
* 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(null)
in /path/typo3_src-13.2.1.test/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaFlexPrepare.php line 104
if (isset($result[‘databaseRow’][$fieldName])) {
$valueArray = $result[‘databaseRow’][$fieldName];
}
if (!is_array($result[‘databaseRow’][$fieldName])) {
$valueArray = GeneralUtility::xml2array($result[‘databaseRow’][$fieldName]);
}
if (!is_array($valueArray)) {
$valueArray = [];
}Reviews 2
History 811
-
Garvin Hicking commented and changed category status
NewNeeds Feedback Tags flexform <span data-processor="relativetime" data-value="2024-09-13T16:15:25+00:00" > 09/13/24, 16:15 </span> -
Franz Holzinger commented <span data-processor="relativetime" data-value="2024-09-13T18:23:28+00:00" > 09/13/24, 18:23 </span>
I am not able to write a new extension for this case. I just used tt_products where article records are created. One article has no graduated price configuration flexform: graduated_config
https://github.com/franzholz/tt_products/blob/master/Configuration/TCA/tt_products_articles.php
This flexform leads to the exception if the graduated config of an article is NULL.
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2024-09-13T18:48:34+00:00" > 09/13/24, 18:48 </span>
Thanks for the feedback. If you are able to provide a smaller, isolated example at some point, we might be able to help. tt_products is too big and loaded with dependencies we cannot properly debug within reasonable time.
-
Stefan Bürk commented <span data-processor="relativetime" data-value="2024-09-13T18:54:32+00:00" > 09/13/24, 18:54 </span>
@franzholz As a quick solution for you
- fix your database and ensure to have tt_content.pi_flexform set to at least an empty string and not null
- use proper api (DataHandler) to write records OR ensure to provide valid data, for example for the pi_flexform field
- if using for example QueryBuilder or connection lowlevel api ensure to at least write pi_flexform at least with an empty string.
TYPO3 core have a TCA default value which means that DataHandler / Backend formengine takes care of that.
With TYPO3 we could have a look into making pi_flexform a not nullable with a empty string db default field (database default) which was not possible in earlier version due to “db constraints” all supported databases.
check for beeing a string before using this method at this place may be added, however there should either be already an array or a string anyway.
-
Franz Holzinger commented <span data-processor="relativetime" data-value="2024-09-30T08:15:08+00:00" > 09/30/24, 08:15 </span>
1.) Is it really necessary to make such a change where the table field for flexforms must not be any more NULL but an empty string?
I ask this because the table tt_content has the column field pi_flexform which has many NULL entries. Shouldn’t then the same database table field state be allowed for all other flexforms as well?
-
Franz Holzinger commented <span data-processor="relativetime" data-value="2024-09-30T14:10:58+00:00" > 09/30/24, 14:10 </span>
The error message disappears if I change all NULL values of flexforms into empy strings ‘’.
UPDATE `tt_products_articles` SET graduated_config = ‘’ WHERE graduated_config IS NULLIf this is required for an upgrade to TYPO3 13 then an upgrade wizard in the Install Tool would be necessary. Is it planned to ship one with TYPO3?
-
Gerrit Code Review pushed patch set 1 for main to change 87684 status
Needs FeedbackUnder Review <span data-processor="relativetime" data-value="2025-01-09T20:50:31+00:00" > 01/09/25, 20:50 </span> -
Gerrit Code Review pushed patch set 2 for main to change 87684 <span data-processor="relativetime" data-value="2025-01-10T08:24:00+00:00" > 01/10/25, 08:24 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 87712 <span data-processor="relativetime" data-value="2025-01-13T12:53:01+00:00" > 01/13/25, 12:53 </span>
-
Georg Ringer commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-01-13T13:05:13+00:00" > 01/13/25, 13:05 </span>Applied in changeset commit:41a27751e0866a571f36fe930f570c89e6188b06.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:33:29+00:00" > 12/02/25, 14:33 </span>
Thanks for the report!
Can you please specify a minimal example of i.e. a flexform/tca config to reproduce this? Maybe using an EXT:styleguide is possible, can you tell steps to reproduce this?