Generated with the help of an LLM.

Problem/Motivation

On PHP 8.5, visiting /admin/config/regional/translate logs:

  • Deprecated function: Using null as an array offset is deprecated, use an empty string instead in Drupal\locale\Form\TranslateFilterForm->buildForm() (line 47 of core/modules/locale/src/Form/TranslateFilterForm.php)
  • A follow-on deprecation in Drupal\Core\Render\Element\Select::processSelect() (line 156).

Line 47 is $empty_option = $filter['options'][$filter['default']] ?? '- None -'; and $filter['default'] is NULL for a filter without a default. Seen with the langcode and status filters on a site with one language (Drupal 11.4.12, PHP 8.5.12). The code is unchanged on 11.x and main.

Steps to reproduce

  1. Use PHP 8.5.
  2. Install Drupal and enable the Interface Translation (locale) module.
  3. Visit /admin/config/regional/translate.
  4. Check Reports, Recent log messages.

Proposed resolution

Only look up the empty option when the filter has a default:

$empty_option = isset($filter['default']) ? ($filter['options'][$filter['default']] ?? '- None -') : '- None -';

Make sure the select gets a non-NULL #default_value and #empty_value, and add kernel or functional test coverage.

Remaining tasks

  • Fix
  • Test coverage
  • Review

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

Issue fork drupal-3639007

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Status: Active » Needs review