#77284USERDEF2 ItemState set through a itemArrayProcFunc is ignored - USERDEF2 TypoScript Conf never used
Description
After setting menuItems in a itemArayProcFunc to ITEM_STATE USERDEF2, the items will be formatted as one of the other states.
USERDEF2 is fully ignored. USERDEF1 and all other states are working.
I looked into the core code, and found the Bug.
The bug sits in the procesItemStates method of TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject Class.
There is a wrong conditional used in the USERDEF2 handling:
// Prepare Userdefined settings
if (!empty($this->mconf['USERDEF2'])) {
$USERDEF2conf = null;
$USERDEF2ROconf = null;
// Find active
foreach ($NOconf as $key => $val) {
if ($this->isItemState('USERDEF2', $key)) {
// If this is the first active, we must generate USERDEF2.
if ($USERDEF2conf) {
$USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'], $splitCount);
// Prepare active rollOver settings, overriding normal active settings
if (!empty($this->mconf['USERDEF2RO'])) {
$USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'], $splitCount);
}
}
// Substitute normal with active
if (isset($USERDEF2conf[$key])) {
$NOconf[$key] = $USERDEF2conf[$key];
}
// If rollOver on normal, we must apply a state for rollOver on the active
if ($ROconf) {
// If RollOver on active then apply this
$ROconf[$key] = !empty($USERDEF2ROconf[$key]) ? $USERDEF2ROconf[$key] : $USERDEF2conf[$key];
}
}
}
}
The buggy condition is:
if ($USERDEF2conf) {
This condition is wrong, because
NULL === TRUE ==> FALSE
This condition should be changed to
if ($USERDEF2conf === null) {
Found in 7.6.9, but still in the master branch.