Project

General

Profile

Actions

Bug #87750

closed

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

Added by Christian Eßl almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2019-02-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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);


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #84236: Uncaught exception in DataHandlerClosed2018-03-13

Actions
Actions #1

Updated by Christian Eßl almost 6 years ago

This appears to happen with new records ($id = 0). In this case, checkStoredRecord() returns null:
checkStoredRecord

public function checkStoredRecord($table, $id, $fieldArray, $action)
{
   $id = (int)$id;
   if (is_array($GLOBALS['TCA'][$table]) && $id) {
      ...
   }
   return null;
}
Actions #2

Updated by Christian Eßl almost 6 years ago

Nevermind.
A colleague just messed up the primary keys of some database tables a few minutes ago, which lead to the problem, that $connection->lastInsertId() always returned '0' as uid.
With a functioning db structure everything appears to be fine.

Actions #3

Updated by Georg Ringer almost 6 years ago

  • Status changed from New to Closed

closing this issue as it is not an issue in the core

Actions #4

Updated by Tymoteusz Motylewski over 4 years ago

  • Related to Bug #84236: Uncaught exception in DataHandler added
Actions

Also available in: Atom PDF