Problem/Motivation

When using PHP 8.1 I was getting the following warning.

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in webform_requirements() (line 176 of modules/contrib/webform/includes/webform.install.requirements.inc).
webform_requirements('runtime')
call_user_func_array('webform_requirements', Array) (Line: 403)

Steps to reproduce

  1. Using Drupal 9.3.12
  2. With PHP 8.1
  3. Install webform module
  4. Create a new webform - but don't add any fields
  5. When viewing the config page (/admin/config) a warning is displayed

Proposed resolution

Check that $data['elements']is not null before using strpos

Comments

3li created an issue. See original summary.

3li’s picture

Status: Active » Needs review
StatusFileSize
new672 bytes
liam morland’s picture

Status: Needs review » Reviewed & tested by the community

This will fix it with no side-effects.

Perhaps the isset() is not needed since $data['elements'] is always set (it just might be NULL).

  • 3li authored 1448e01 on 6.2.x
    Issue #3279930 by 3li: Deprecated function: strpos(): Passing null to...

  • 3li authored 6694eb9 on 6.2.x
    Issue #3279930 by 3li: Deprecated function: strpos(): Passing null to...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed
drumm’s picture

(disregard, updating to fix issue mis-indexing)

Status: Fixed » Closed (fixed)

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

joseph.olstad’s picture

Version: 6.2.x-dev » 6.1.x-dev

patch applies cleanly to 6.1.x also

mxr576’s picture

Since 6.1.x is the current stable, supported, and covered by Drupal Security release, can we please have this fix backported to that version too?

jrockowitz’s picture

Done!

mxr576’s picture

Thank you!

norman.lol’s picture

Can't we get a tag for 6.1, please? 🙂