From eb0b4e102fbf639e455e36dfd5aa4fe665b50854 Mon Sep 17 00:00:00 2001 From: Sybille Peters <sypets@gmx.de> Date: Tue, 6 Dec 2022 21:07:29 +0100 Subject: [PATCH] [BUGFIX] Fix exception with PHP 8.1 in ItemProcessingService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pageId is already passed to the functon ItemProcessingService::getProcessingItems(). This is now used instead of retrieving the uid / pid from the row array. The previous behaviour could result in an exception with PHP 8.1 since the uid in the row might not be initialized if a new page is created. If a field with itemProcFunc existed for a field in the pages table. The page id which was passed to the function already handled the case of empty uid by passing the uid of the parent page. Resolves: #99295 Releases: main, 11.5 Change-Id: I9c72189c6f80e0a45cb9abfcc80541b091c126b8 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77277 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Stefan Bürk <stefan@buerk.tech> --- .../core/Classes/DataHandling/ItemProcessingService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/typo3/sysext/core/Classes/DataHandling/ItemProcessingService.php b/typo3/sysext/core/Classes/DataHandling/ItemProcessingService.php index 4fa9d11f9e9f..1096ea127de0 100644 --- a/typo3/sysext/core/Classes/DataHandling/ItemProcessingService.php +++ b/typo3/sysext/core/Classes/DataHandling/ItemProcessingService.php @@ -30,16 +30,16 @@ class ItemProcessingService * Executes an itemsProcFunc if defined in TCA and returns the combined result (predefined + processed items) * * @param string $table - * @param int $pageId + * @param int $realPid Record pid. This is the pid of the record. * @param string $field * @param array $row * @param array $tcaConfig The TCA configuration of $field * @param array $selectedItems The items already defined in the TCA configuration * @return array The processed items (including the predefined items) */ - public function getProcessingItems($table, $pageId, $field, $row, $tcaConfig, $selectedItems) + public function getProcessingItems($table, $realPid, $field, $row, $tcaConfig, $selectedItems) { - $pageId = $table === 'pages' ? $row['uid'] : $row['pid']; + $pageId = (int)($table === 'pages' ? ($row['uid'] ?? $realPid) : ($row['pid'] ?? $realPid)); $TSconfig = BackendUtility::getPagesTSconfig($pageId); $fieldTSconfig = $TSconfig['TCEFORM.'][$table . '.'][$field . '.'] ?? []; @@ -52,7 +52,7 @@ class ItemProcessingService $params['field'] = $field; // The itemsProcFunc method may throw an exception. - // If it does display an error message and return items unchanged. + // If it does, display an error message and return items unchanged. try { GeneralUtility::callUserFunction($tcaConfig['itemsProcFunc'], $params, $this); } catch (\Exception $exception) { -- GitLab