#109621NewRecordController: PHP Warning "Undefined array key url" when single item uses TCA sub-types
Description
File: typo3/cms-backend/Classes/Controller/NewRecordController.php
—-
Problem Description
In NewRecordController::mainAction(), when exactly one record control group with exactly one item is present, the code performs an automatic redirect:
if (count($recordControls) === 1) {
$items = current($recordControls)['items'] ?? [];
if (count($items) === 1) {
$item = current($items);
return new RedirectResponse($item['url'], 301); // line 131
}
}
However, getNewRecordControls() produces two distinct item structures depending on whether the table uses TCA sub-types (supportsSubSchema()):
- Without sub-types: [‘url’ => ‘…’, ‘icon’ => …, ‘label’ => ‘…’]
- With sub-types: [‘label’ => ‘…’, ‘icon’ => …, ‘types’ => […]] — no url key
When a table with sub-types (e.g. tx_news_domain_model_news from EXT:news, which has the types News, Internal link, External page) is the only available record type on a page, the redirect code accesses $item[‘url’] on an item that does not have this key, triggering:
PHP Warning: Undefined array key “url” in NewRecordController.php line 131
Steps to Reproduce
- Install EXT:news (georgringer/news ^14)
- Configure a page where tx_news_domain_model_news is the only allowed/visible record type
- Open the New Record wizard for that page in the backend
Expected Behavior
No PHP warning. If the single item has sub-types, the wizard should render the selection page to let the editor choose a sub-type.
Actual Behavior
PHP Warning is triggered. The redirect is attempted with an undefined array key.
Suggested Fix
Add an isset() guard before the redirect:
if (isset($item['url'])) {
return new RedirectResponse($item['url'], 301);
}Reviews 2
Related issues 1
History 35
-
Christian Kuhn changed Related to #50360 <span data-processor="relativetime" data-value="2026-04-23T01:29:33+00:00" > 04/23/26, 01:29 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 93811 status
NewUnder Review <span data-processor="relativetime" data-value="2026-04-23T01:31:55+00:00" > 04/23/26, 01:31 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 93821 <span data-processor="relativetime" data-value="2026-04-23T09:37:12+00:00" > 04/23/26, 09:37 </span>
-
Christian Kuhn commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-04-23T10:05:08+00:00" > 04/23/26, 10:05 </span> -
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2026-08-11T08:46:49+00:00" > 08/11/26, 08:46 </span>
Applied in changeset commit:d139044fa83971ed304cde534f5fd0cad9b30cb6.