diff --git a/typo3/sysext/core/Classes/DataHandling/ItemProcessingService.php b/typo3/sysext/core/Classes/DataHandling/ItemProcessingService.php
index 4fa9d11f9e9f91894ae84253ec81c9fce24a3fd5..1096ea127de07be7c8c5d9166c241d00e91b20f1 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) {