Issue Bug Closed

#94607TcaMigration for special-value type-field in sys_file_reference triggers exception

Stefan Neufeind 07/21/21, 10:56 updated 10/22/26, 19:52

Description

For sys_file_reference the type-field does not point to a configured field directly. So TcaMigration complains with an exception.

I don’t exactly know why in my special case the TCA-migration triggered checks. But imho it might simply skip checking such “special values”?

Uncaught TYPO3 Exception #1482394401: Missing “type” in TCA of field “[‘sys_file_reference’][‘uid_local:type’][‘config’]”.
thrown in file /var/www/typo3_src-10.4.17/typo3/sysext/core/Classes/Migrations/TcaMigration.php
in line 87

Definition in: typo3/sysext/core/Configuration/TCA/sys_file_reference.php

Reviews 0

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

History 4

  1. Stefan Neufeind commented <span data-processor="relativetime" data-value="2021-07-21T10:57:49+00:00" > 07/21/21, 10:57 </span>

    Can we skip those special values?

    In validateTcaType() possibly add check for ‘:’ indicating this is no fieldName directly but points to a “sub-field”.

    foreach ($tableDefinition[‘columns’] as $fieldName => $fieldConfig) {
    if ((strpos($fieldName, ‘:’) === false) && isset($fieldConfig[‘config’]) && is_array($fieldConfig[‘config’]) && empty($fieldConfig[‘config’][‘type’])) {
  2. Kevin Chileong Lee commented <span data-processor="relativetime" data-value="2023-06-02T09:24:11+00:00" > 06/02/23, 09:24 </span>

    A Workaround that worked for me is to XClass the \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper and override the method: getTargetType. What needs to be done is to check if the array key is present in the $row before using it:

    /**
         * Returns the target type for the given row.
         *
         * @param string $className The name of the class
         * @param array $row A single array with field_name => value pairs
         * @return string The target type (a class name)
         */
        public function getTargetType($className, array $row)
        {
            $dataMap = $this->getDataMap($className);
    
            $targetType = $className;
            if ($dataMap->getRecordTypeColumnName() !== null) {
                foreach ($dataMap->getSubclasses() as $subclassName) {
                    $recordSubtype = $this->getDataMap($subclassName)->getRecordType();
    
                    // Check if column is present in the row
                    if (array_key_exists($dataMap->getRecordTypeColumnName(), $row) && (string)$row[$dataMap->getRecordTypeColumnName()] === (string)$recordSubtype) {
                        $targetType = $subclassName;
                        break;
                    }
                }
            }
            return $targetType;
        }

    The method is based on TYPO3 V11.5.27

  3. Mathias Brodala commented <span data-processor="relativetime" data-value="2023-10-05T07:31:30+00:00" > 10/05/23, 07:31 </span>

    Seems like Extbase never did support the <relation-field>:<related-table-field> notation.

    In the backend the BackendUtility::getTCAtypeValue() method can be used to resolve this. Thus a possible fix in DataMapper::getTargetType() could be using this:

    +use TYPO3\CMS\Backend\Utility\BackendUtility;
    -                if ((string)$row[$dataMap->getRecordTypeColumnName()] === (string)$recordSubtype) {
    +                if (BackendUtility::getTCAtypeValue($this->convertClassNameToTableName($className), $row) === (string)$recordSubtype) {
  4. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-10-22T19:52:24+00:00" > 10/22/26, 19:52 </span>

    I checked this on current main (v14):

    • The Extbase part (DataMapper::getTargetType() reading a non-existing row key for the special type pointer uid_local:type of sys_file_reference) is handled since v14.0: with #106840 (d344a00a164), DataMapFactory no longer sets a record type column for type fields that point to a field in a foreign table, so the lookup is skipped.
    • For the TcaMigration exception: uid_local:type is only the value of ctrl.type in sys_file_reference, not a column. validateTcaType() iterates over columns only, so the core TCA cannot trigger “Missing type” for it. I could not reproduce this.

    Closing as outdated.

    If this is still valid for you in v14, please open a new issue and provide information how to reproduce it. Thanks!