From b525531d2cdfa177548c458ed64b92f6daeda1d0 Mon Sep 17 00:00:00 2001
From: Oliver Klee <typo3-coding@oliverklee.de>
Date: Sat, 26 Aug 2023 09:31:05 +0200
Subject: [PATCH] [BUGFIX] Do not try to parse null/empty flexforms in
 ReferenceIndex

This fixes an issue in the acceptance tests where `null` is passed
to `GeneralUtility::xml2array()` (which expects a `string`).

Having an early check for an empty string also avoids
pointless XML parsing (which should help performance a bit).

Resolves: #101757
Releases: main, 12.4, 11.5
Change-Id: Ifc4406536c273baca9acdda7a0af7a91594f57bf
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80680
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 typo3/sysext/core/Classes/Database/ReferenceIndex.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/Database/ReferenceIndex.php b/typo3/sysext/core/Classes/Database/ReferenceIndex.php
index d56bdcf2c08e..20571f3f581c 100644
--- a/typo3/sysext/core/Classes/Database/ReferenceIndex.php
+++ b/typo3/sysext/core/Classes/Database/ReferenceIndex.php
@@ -463,7 +463,7 @@ class ReferenceIndex implements LoggerAwareInterface
                     ];
                 }
                 // For "flex" fieldtypes we need to traverse the structure looking for db references of course!
-                if ($conf['type'] === 'flex') {
+                if ($conf['type'] === 'flex' && is_string($value) && $value !== '') {
                     // Get current value array:
                     // NOTICE: failure to resolve Data Structures can lead to integrity problems with the reference index. Please look up
                     // the note in the JavaDoc documentation for the function FlexFormTools->getDataStructureIdentifier()
-- 
GitLab