Problem/Motivation

Getting this warning sporadically on D9 with PHP 8.1.

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in ajax_comments_preprocess_status_messages() (line 395 of modules/contrib/ajax_comments/ajax_comments.module).

Steps to reproduce

Edit a node with the following path
/node/1/edit?destination=/404-not-found
In order to trigger a 404 since 404s pages have no route.

Save the node and you will see a status message.
The dblog will register the warning or the next page will show the error as a status message

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

chucksimply created an issue. See original summary.

Siddhraj’s picture

Assigned: Unassigned » Siddhraj
FileSize
590 bytes

Hello
passing empty string in the strpos() method resolved this issue.
Instead of passing null in the method strpos() pass an empty string if the variable is null.

Thanks

Kosa Ilma’s picture

Tested patch with core 9.4.8 and AJAX Comments 8.x-1.0-beta4. Works for me.

Kosa Ilma’s picture

Status: Active » Reviewed & tested by the community

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

rodrigoaguilera’s picture

Version: 8.x-1.0-beta4 » 8.x-1.x-dev
Assigned: Siddhraj » Unassigned
Issue summary: View changes
Status: Reviewed & tested by the community » Needs review

I proposed a similar solution that I find more readable as MR for easy merging.
Added steps to reproduce to issue summary.

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

idebr’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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