Problem/Motivation
Steps to reproduce
When exporting feedback, for every feedback entry without a message, a deprecation warning, as follows is logged:
Deprecated function: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\admin_feedback\Controller\AdminFeedbackController->exportDbFeedback() (line 296 of /opt/drupal/web/modules/contrib/admin_feedback/src/Controller/AdminFeedbackController.php)
Proposed resolution
The issue can be easily mitigated by using a null coalescing operator to provide a blank string. Implementing this as suggested would change Line 296 from:
$message_formatted = trim(preg_replace('/\s+/', ' ', $row->feedback_message));
to:
$message_formatted = trim(preg_replace('/\s+/', ' ', $row->feedback_message ?? ''));
Remaining tasks
Create a merge request to ensure that null is not passed to the third argument of the preg_replace function.
Issue fork admin_feedback-3437584
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 #5
immaculatexavier commentedThe above MR is to ensure that null is not passed to the third argument of the preg_replace function.
Comment #8
manish-31 commented@immaculatexavier Thanks for the MR.
I have udated the MR and verified that the warning is no longer triggered. Needs review.
MR Updates: Replaced
nullwithNULL, replaced if/else statement with ternary operator.Comment #9
manish-31 commentedComment #10
vivek panicker commentedComment #11
manish-31 commentedThanks @Vivek Panicker
Updated the MR. Needs review.
Comment #12
kalash-j commentedI have tested this on my local and after applying the MR , it doesnt show any error msg.
Comment #14
bserem commentedThanks for the work and the test.
Merged
Comment #15
bserem commented