Issue Bug Closed

#107491DataHandler: Warning: Undefined array key "pid"

Christian Weiske 09/19/25, 11:54 updated 09/19/25, 18:25

Description

When TYPO3 data handler stores records in the database in insertDB(), the checkStoredRecord() method loads the stored record from database and compares the values.
When loading this record fails, checkStoredRecord() returns null which is then replaced with [].

insertDB() then logs the change into the database, accessing ['pid'] on the empty array – leading to the warning:
> Warning: Undefined array key “pid”

This only happens irregularly and is most likely some timing problem within the MySQL database.

Nevertheless should TYPO3 not throw a warning.
I think that checkStoredRecord() should not return NULL but the original record when loading fails, and create a log entry that fetching the stored record failed.

This is with TYPO3 12.4.37 and PHP 8.3.24.

Details

The broken log record looks so:

{"title":"[Kein Titel]","table":"pages","uid":6698,"pageTitle":"[root-level]","pid":null} 

The log() call was this:

$this->log(
    [...]
    'Record "{title}" ({table}:{uid}) was inserted on page "{pageTitle}" ({pid})',
    10,
    [
        'title' => $propArr['header'],             // wrong: "[No title]"
        'table' => $table,                         // correctly filled
        'uid' => $id,                              // correctly filled
        'pageTitle' => $page_propArr['header'],    // wrong: "[root-level]"
        'pid' => $newRow['pid']                    // wrong: null
    ],
    $newRow['pid'],                                // wrong: 0
    $NEW_id                                        // correct: NEW_1
)

Stacktrace

ErrorException: Warning: Undefined array key "pid"
#41 /vendor/typo3/cms-core/Classes/DataHandling/DataHandler.php(7839): TYPO3\CMS\Core\DataHandling\DataHandler::insertDB
#40 /vendor/typo3/cms-core/Classes/DataHandling/DataHandler.php(1152): TYPO3\CMS\Core\DataHandling\DataHandler::process_datamap
#39 /vendor/typo3/cms-backend/Classes/Controller/SimpleDataHandlerController.php(225): TYPO3\CMS\Backend\Controller\SimpleDataHandlerController::processRequest
#38 /vendor/typo3/cms-backend/Classes/Controller/SimpleDataHandlerController.php(132): TYPO3\CMS\Backend\Controller\SimpleDataHandlerController::processAjaxRequest
#37 /vendor/typo3/cms-backend/Classes/Http/RouteDispatcher.php(82): TYPO3\CMS\Backend\Http\RouteDispatcher::dispatch
#36 /vendor/typo3/cms-backend/Classes/Http/RequestHandler.php(104): TYPO3\CMS\Backend\Http\RequestHandler::handle
#35 /vendor/typo3/cms-core/Classes/Middleware/ResponsePropagation.php(34): TYPO3\CMS\Core\Middleware\ResponsePropagation::process

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.