Problem/Motivation
On PHP 8.5 deprecation warning is triggered in Drupal\webform\Controller\WebformPluginElementController:
Deprecated function: Using null as an array offset is deprecated, use an empty string instead
In the formats section, getItemDefaultFormat() can return NULL, and that value is used as an array key in isset($formats[$default_format]). Using NULL as an array offset is deprecated in newer PHP versions.
Steps to reproduce
1. Install and enable Webform on a Drupal site running PHP 8.5
2. Open the page that builds the Webform element plugin listing (the code path that executes index() in the controller).
3. Ensure at least one element/plugin returns NULL from getItemDefaultFormat().
4. Check logs/output for the deprecation warning.
Proposed resolution
Normalize NULL to an empty string before using it as an array key.
Update:
$default_format = $webform_element->getItemDefaultFormat();
to:
$default_format = $webform_element->getItemDefaultFormat() ?? '';
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork webform-3589901
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 #9
liam morlandThanks!