#106697TCA: Default record type is removed if (int) 0
Description
From this Bug report in EXT:news https://github.com/georgringer/news/issues/2641
I found, that this commit https://github.com/TYPO3/typo3/commit/0d81d8f43788ab40f73e9d4ea62923fa6addf293 introduced the following problem:
Staying with the example of EXT:news, there a 3 valid types (0,1,2)
However, the array_filter function in TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRecordTypeValue::getValidTypeValues() removes the record type with value 0
The result is, that the news record always shows the TCA showitem of for type 1, if the selected type is 0 or 1.
Test: Remove the array_filter()
protected function getValidTypeValues(array $items): array
{
$test = array_map(static function (array $item) {
$type = $item['value'] ?? '';
return $type !== '--div--' ? $type : '';
}, $items);
$result_of_array_filter = array_filter($test);
return $result_of_array_filter;
}
clipboard-202505141849-5lyma.png
If we return $test early, the form is correct. Type 0 showitem is displayed.
If we return $result_of_array_filter the form shows the fields, that are configured in showitem for type 1
array_filter() removes values that are considered falsey by default — including 0 (integer), ‘’ (empty string), false, and null
Possible solution:
add a callback to array_filter that explicitly checks for what you want to keep.
e.g.
$filtered = array_filter($array, function($value) {
return !empty($value) || $value === 0;;
});
Reviews 2
Related issues 2
Files 1
History 913
-
Česlav Przywara changed Duplicated by #106709 <span data-processor="relativetime" data-value="2025-05-15T12:42:41+00:00" > 05/15/25, 12:42 </span>
-
Česlav Przywara changed Duplicated by #106708 <span data-processor="relativetime" data-value="2025-05-15T12:43:00+00:00" > 05/15/25, 12:43 </span>
-
Georg Ringer changed status
NewAccepted <span data-processor="relativetime" data-value="2025-05-15T20:32:04+00:00" > 05/15/25, 20:32 </span> -
Gerrit Code Review pushed patch set 1 for main to change 89411 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2025-05-15T20:45:03+00:00" > 05/15/25, 20:45 </span> -
Oliver Hader changed Is Regression 1 <span data-processor="relativetime" data-value="2025-05-15T22:36:01+00:00" > 05/15/25, 22:36 </span>
-
Oliver Hader changed Related to #94408 <span data-processor="relativetime" data-value="2025-05-15T22:37:06+00:00" > 05/15/25, 22:37 </span>
-
Gerrit Code Review pushed patch set 2 for main to change 89411 <span data-processor="relativetime" data-value="2025-05-15T22:58:48+00:00" > 05/15/25, 22:58 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 89437 <span data-processor="relativetime" data-value="2025-05-19T06:18:48+00:00" > 05/19/25, 06:18 </span>
-
Gerrit Code Review pushed patch set 2 for 13.4 to change 89437 <span data-processor="relativetime" data-value="2025-05-19T06:30:01+00:00" > 05/19/25, 06:30 </span>
-
Georg Ringer commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-05-19T06:45:09+00:00" > 05/19/25, 06:45 </span> -
Georg Ringer changed Duplicated by #106730 <span data-processor="relativetime" data-value="2025-05-19T17:33:22+00:00" > 05/19/25, 17:33 </span>
-
Oliver Bartsch changed Related to #106789 <span data-processor="relativetime" data-value="2025-05-28T09:49:32+00:00" > 05/28/25, 09:49 </span>
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:21:24+00:00" > 12/02/25, 14:21 </span>
Applied in changeset commit:cbdd06b6b0a60a64c559aab9b5dfa10ebacd07ca.