Problem/Motivation

Since the recent upgrade from Version 1.3 to 1.4 the following error message appears by trying to log in:

Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in captcha_whitelist_ips_parse_values() (line 727 of modules/contrib/captcha/captcha.module).

Steps to reproduce

For the following system:
Ubuntu 20.04.4 LTS
Drupal 9.4.3
PHP 8.1.8
MariaDB 10.6.8
Upgrade using composer update. Present captcha Version 1.3 is upgraded to 1.4. Try to log in. => error message appears as mentioned above.

Proposed resolution

Fallback to captcha version 1.3

Remaining tasks

Check: line 727 of modules/contrib/captcha/captcha.module

Issue fork captcha-3298766

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kulturmensch created an issue. See original summary.

cobenash made their first commit to this issue’s fork.

cobenash’s picture

I have the same issue. Thanks for reporting.

cobenash’s picture

Patch file provided.

Kulturmensch’s picture

Great! The fix works in my case and the warning disappeared. Thanks for the quick response!

simgui8’s picture

#5 looks good to me. Thanks

simgui8’s picture

Title: Deprecated function: trim() » php8.1 deprecated function: trim()
Status: Active » Reviewed & tested by the community

I have tested on dev and production sites.

The deprecation warning only happened with php8.1 (php8.1 added to issue title).

No warning with php8.0 or php7.4

The #5 MR (patch #6) fixes the issues with php8.1 and is fully compatible with php8.0 and php7.4

Marking RTBC since the patch is a one-liner and two people have reported that it fixes the issue.

simgui8’s picture

Title: php8.1 deprecated function: trim() » php8.1 deprecation warning function: trim(): Passing null to parameter #1

And making it clear that passing null to parameter #1 is deprecated (not the trim function).

lapurddrupal’s picture

Patch #6 works fine. Thanks. Drupal Version 9.4.3 , PHP 8.1.7

Anonymous’s picture

#6 works here also. Drupal 9.4.3, PHP 8.1.8.

Thanks!

rymcveigh’s picture

Patch #6 works for us as well. Drupal Version 9.4.3, PHP 8.0.21

bserem’s picture

Patch #6 tested with D9.4.3 and PHP 8.1.7, all good

webfaqtory’s picture

Patch #6 tested with D9.4.5 and PHP 8.1.7, all good

pguillard’s picture

Patch #6 tested with D9.3.21 and PHP 8.1.7, all good too

Eduardo Morales Alberti’s picture

Patch #6 working, Drupal Version 9.4.5, PHP 8.1.7

KlemenDEV’s picture

I think this is ready to be merged and released

zcht’s picture

Drupal 9.4.5, PHP 8.1.9 - patch #6 works again everything without problems and notice.

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Fixed. it also highlighted an issue a line below, since we aren't checking nulls in line 731.

  • japerry committed 5f32a34 on 8.x-1.x
    Issue #3298766 by cobenash, japerry: php8.1 deprecation warning function...

Status: Fixed » Closed (fixed)

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

KlemenDEV’s picture

Using version 1.9, I still get this error logged:

Passing null to parameter #1 ($string) of type string is deprecated in captcha_whitelist_ips_parse_values()

EDIT: Reading old log, my mistake, all good :)