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
- Use PHP 8.5.
- Install Drupal and enable the Interface Translation (locale) module.
- Visit
/admin/config/regional/translate. - 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
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
Comment #3
rajab natshah