Actions
Bug #71256
closedCategoryRegistry::isRegistered() is broken by TCA caching.
Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Categorization API
Target version:
-
Start date:
2015-11-02
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
Description
Situation: Adding a custom category field to e.g. table 'pages
' in Configuration/TCA/Overrides/pages.php
.
The categorized field should be in the TCA cache, therefore ext_tables.php
would be the wrong place to add the category field.
The following will only work right after clearing system caches:
if(!CategoryRegistry::getInstance()->isRegistered($tableName, $fieldName)) { throw new \InvalidArgumentException($tableName . '.' . $fieldName . ' is no registered category field.'); }
Instead, a workaround is needed:
/** * Note: CategoryRegistry::getInstance()->isRegistered($tableName, $fieldName) only works after clearing * System Cache, since otherwise TCA is cached and makeCategorizable calls are ommitted during boot. * To use defined categorized fields from cache, we need to analyze TCA directly. */ if(!isset($GLOBALS['TCA'][$tableName]['columns'][$fieldName]) || $GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config']['foreign_table'] != 'sys_category') { throw new \InvalidArgumentException($tableName . '.' . $fieldName . ' is no registered category field in TCA.'); }
CategoryRegistry::getInstance()->isRegistered($tableName, $fieldName)
should always return TRUE if a categorized field has been registered and FALSE if no such field exists in TCA -- not only if makeCategorizable
has been called during bootup, adding categories as non-cached TCA parts.
Updated by Mathias Schreiber almost 9 years ago
- Target version deleted (
next-patchlevel)
Updated by Georg Ringer over 4 years ago
- Status changed from New to Closed
categorize api has fixed multiple times since then and should be fine now
Actions