Skip to content

Use '0' instead of '1' as TCA default type definition key #448

@georg-tiefenbrunn

Description

@georg-tiefenbrunn

I recently stumbled into a 'Type value 0 from database record not defined in TCA' exception after importing records into a ContentBlocks/RecordTypes table using multiple types.

While fixing the issue I noticed that CB currently uses 1 as TCA default type, but TYPO3 nowadays uses 0:

TCA Reference

At least one type has to be configured before any field will show up, the default type is 0.

EXT:backend/Classes/Form/FormDataProvider/DatabaseRecordTypeValue.php

        if (empty($result['processedTca']['types'][$recordTypeValue])
            && empty($result['processedTca']['types']['0'])
            && empty($result['processedTca']['types']['1'])
        ) {
...
        // Check the determined value actually exists as types key, otherwise fall back to 0 or 1, 1 for "historical reasons"
        if (empty($result['processedTca']['types'][$recordTypeValue])) {
            $recordTypeValue = !empty($result['processedTca']['types']['0']) ? '0' : '1';
        }

Affected Code

  • TYPO3\CMS\ContentBlocks\Definition\TableDefinition->getDefaultTypeDefinition() only checks for type 1
  • TYPO3\CMS\ContentBlocks\Loader\ContentBlockLoader->createTypeName() always returns 1 for records without typeName definition
  • Comment in TYPO3\CMS\ContentBlocks\Generator\TcaGenerator->fillTypeFieldSelectItems() (the default type "1")
  • TYPO3\CMS\ContentBlocks\Definition\Factory\Processing\ProcessingInput->resolveTypeName() ignores typeName definition if no typeField is defined and always returns 1

Nice to have

  • CB should ensure type 0 exists (copy the default type definition) so you don't have to use typeName: 0 for the record definition with highest priority.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DiscussionGather different opinions on a topic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions