#111491ComponentGroup::remove() does not remove empty (null) actions
Description
ComponentGroup::add() accepts ?ComponentInterface, and DatabaseRecordList::makeControl() adds null on purpose as a placeholder for actions that are not available for a record, e.g. moveUp for the first record of a sortable table, moveDown for the last one, or delete when deleting is not allowed. When the primary actions are rendered, getItems($emptyAction) turns each of these null entries into an empty placeholder button, so that all rows keep the same number of action slots.
ComponentGroup::remove() checks with isset(), which is false for a null value, so a null entry is never removed:
public function remove(string $identifier): true
{
if (isset($this->items[$identifier])) {
unset($this->items[$identifier]);
}
return true;
}
has() uses array_key_exists() and still reports the action as present after it was removed.
As a consequence, ModifyRecordListRecordActionsEvent::removeAction() (and the same method of ProcessFileListActionsEvent) silently keeps an action if it is empty for the current record. moveActionTo() is affected as well: for an empty action it leaves the entry in the original group and adds a second one to the target group.
How to reproduce
Register a listener that removes the sorting actions from the record list:
use TYPO3\CMS\Backend\RecordList\Event\ModifyRecordListRecordActionsEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener]
final class RemoveSortingActions
{
public function __invoke(ModifyRecordListRecordActionsEvent $event): void
{
$event->removeAction('moveUp');
$event->removeAction('moveDown');
}
}
Open the “Records” module on a page with at least three records of a table with sortby (e.g. tt_content), sorted by the default sorting.
Expected: all rows show the same primary actions, without move up/down.
Actual: the first row (empty moveUp) and the last row (empty moveDown) render one empty placeholder slot more than the other rows, so their actions are misaligned. After removeAction('moveUp'), hasAction('moveUp') still returns true for the first record.
In the file list the primary actions are rendered with getItems() without a placeholder, so nothing is visible there, but hasAction() is wrong after removeAction() in the same way.
Cause
remove() uses isset(), while add() allows null and has() uses array_key_exists().
Possible fix
unset() on a missing key is a no-op, so the check can simply be dropped:
public function remove(string $identifier): true
{
- if (isset($this->items[$identifier])) {
- unset($this->items[$identifier]);
- }
+ unset($this->items[$identifier]);
return true;
}
A unit test that adds an item as null, calls remove() and asserts has() is false fails on 14.3 and main without the change and passes with it; the existing unit tests of EXT:backend Template and RecordList and of EXT:filelist keep passing.
The param array<string componentinterface> $items@ annotation on the <code>$items</code> property could be corrected to <code></code>var array<string>@ at the same time.</string></string>
Affects 14.3 and main (the code was introduced with #107884).
Reviews 1
History 01
-
Gerrit Code Review pushed patch set 1 for main to change 97791 status
NewUnder Review <span data-processor="relativetime" data-value="2026-11-18T12:54:35+00:00" > 11/18/26, 12:54 </span>