-
Notifications
You must be signed in to change notification settings - Fork 122
Array to string conversion when copying fe_users record with tx_femanager_log inline relation #702
Description
When copying a fe_users record in the TYPO3 backend, an exception is thrown if the user has related tx_femanager_domain_model_log records containing data in the additional_properties field.
Error
(1/1) #1476107295 TYPO3\CMS\Core\Error\Exception
PHP Warning: Array to string conversion
in /vendor/doctrine/dbal/src/Driver/Mysqli/Statement.php line 73
Root Cause
When TYPO3's DataHandler::copyRecord_raw() copies the log record, it reads the existing DB row directly via SQL. TYPO3 automatically decodes type = json TCA fields into PHP arrays during this process. The decoded array value is then passed directly into insertNewCopyVersion() → insertDB() without re-encoding it to a JSON string. The Extbase setter setAdditionalProperties(string $additionalProperties) is never invoked in this path.
As a result, Doctrine DBAL receives a raw PHP array instead of a JSON string and throws Array to string conversion.
The field is defined as:
// TCA
'additional_properties' => [
'config' => [
'type' => 'json',
'readOnly' => true,
],
],
// Model setter
public function setAdditionalProperties(string $additionalProperties): void
{
$this->additionalProperties = $additionalProperties;
}
Steps to Reproduce
- Have a fe_users record with at least one related tx_femanager_domain_model_log entry (e.g. after a successful frontend login)
- Copy the fe_users record in the TYPO3 backend list module
- Exception is thrown immediately
Expected Behavior
The fe_users record and its related log records are copied without error. The additional_properties JSON field is properly re-encoded to a string before the INSERT.
Suggested Fix
Before inserting the copied record, ensure additional_properties is JSON-encoded if it is an array:
if (is_array($this->additionalProperties)) {
$this->additionalProperties = json_encode(
$this->additionalProperties,
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE
);
}
Alternatively this should be handled generically in DataHandler::insertUpdateDB_preprocessBasedOnFieldType() for all type = json TCA fields.
Environment
- TYPO3 Version: 13.4.27
- femanager Version: 13.3.2
- PHP Version: 8.2
- Database: MariaDB