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

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

  • liam morland committed e65313b8 on 6.3.x
    fix: #3589901 Correct documentation for WebformElementInterface::...

  • liam morland committed e65313b8 on 6.x
    fix: #3589901 Correct documentation for WebformElementInterface::...

  • liam morland committed a6e9bb11 on 6.2.x
    fix: #3589901 Correct documentation for WebformElementInterface::...

liam morland’s picture

Status: Active » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.