Issue Bug Closed

#109621NewRecordController: PHP Warning "Undefined array key url" when single item uses TCA sub-types

David Zach 04/17/26, 08:50 updated 08/11/26, 08:46

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

  1. Install EXT:news (georgringer/news ^14)
  2. Configure a page where tx_news_domain_model_news is the only allowed/visible record type
  3. 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

History 35

  1. Christian Kuhn commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-04-23T10:05:08+00:00" > 04/23/26, 10:05 </span>

    Applied in changeset commit:d139044fa83971ed304cde534f5fd0cad9b30cb6.