Issue Bug Closed

#87750Argument 3 passed to TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore::addRecord() must be of the type array

Christian Eßl 02/20/19, 13:50 updated 02/20/19, 16:22

Description

The function “TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore::*addRecord*()” expects $payload to be an array:

public function addRecord(string $table, int $uid, array $payload): string
{

However, when called in the DataHandler, $payload can be null from the checkStoredRecord function:

in /…/public_html/typo3/sysext/core/Classes/DataHandling/DataHandler.php line 7318


$newRow = [];
if ($this->enableLogging) {
   // Checking the record is properly saved if configured
   if ($this->checkStoredRecords) {
      // !!! checkStoredRecord(), depending on TCA configuration returns either an array or NULL
      $newRow = $this->checkStoredRecord($table, $id, $fieldArray, 1);
   } else {
      $newRow = $fieldArray;
      $newRow['uid'] = $id;
   }
}

...

// Store in history
// !!! this now triggers a TypeError, because $newRow is NULL
$this->getRecordHistoryStore()->addRecord($table, $id, $newRow);

Reviews 0

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