Issue Bug Closed

#76141Problem with !empty() in makeCategorizable usage

Patrick Kroog 05/11/16, 12:11 updated 10/02/18, 11:13

Description

Steps to face this bug:

- Add a TCA-Definition for a table with 2 or more “types”.
- Try to ONLY add the category field to the first type, which is type “0” (using makeCategorizable and use “typesList” in option Array…)
For example:

// Add an extra categories selection field to the pages table
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
    'eventmanager',
    'tx_eventmanager_domain_model_event',
    'category',
    array(
        'typesList' => '0',
        'label' => 'LLL:EXT:eventmanager/Resources/Private/Language/locallang_db.xlf:tx_eventmanager_domain_model_event.category',
        'exclude' => true,
        'fieldConfiguration' => array(
           ...
           )
        ),
        'l10n_mode' => 'exclude',
        'l10n_display' => 'hideDiff',
    )
);

The typesList is now ignored, and the category field is added to ALL types as TYPO3\CMS\Core\Category\CategoryRegistry::addToAllTCAtypes checks the typesList option like this:

            $typesList = '';
            if (!empty($options['typesList'])) {
                $typesList = $options['typesList'];
            }

So, as a workaround one could use a typesList like this, but as it’s not documented, one wouldn’t understand why the default configuration doesn’t work:

// Add an extra categories selection field to the pages table
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
    'eventmanager',
    'tx_eventmanager_domain_model_event',
    'category',
    array(
        'typesList' => '0,999',
        'label' => 'LLL:EXT:eventmanager/Resources/Private/Language/locallang_db.xlf:tx_eventmanager_domain_model_event.category',
        'exclude' => true,
        'fieldConfiguration' => array(
           ...
           )
        ),
        'l10n_mode' => 'exclude',
        'l10n_display' => 'hideDiff',
    )
);

So this check should be corrected!

Reviews 2