Après la migration vers le PHP 8.1, J'ai ces deux erreurs dans mon site.
Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in text_summary() (line 71 of core/modules/text/text.module).
Deprecated function: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in text_summary() (line 95 of core/modules/text/text.module).
Quelqu'un a une idée comment les corriger?
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | passing_null_to_first_parameter_of_strpos_is_deprecated.patch | 778 bytes | olegrymar |
Issue fork drupal-3312931
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 #2
drupal_developer2022 commentedComment #3
heni_deepak commentedCould you share some steps to reproduce this issue.
Comment #4
drupal_developer2022 commentedMy website is now with DrupalCore version 9.4.7 and PHP 8.1.
How to reproduce:
when i access to one of my page (views with filter and pagination) with content, the website return theses two error.
Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in text_summary() (line 71 of core/modules/text/text.module).And
Deprecated function: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in text_summary() (line 95 of core/modules/text/text.module).It seems calling the function text_summary() with null params, then the results is in this warning.
Comment #5
heni_deepak commentedI have tried but don't face it. I think you need to update your core with 9.5.
9.5 very much familiar with PHP 8.1
also we need to wait form another people if they face similar.
Comment #6
heni_deepak commentedComment #7
walii commentedKindly use PHP version 8.0
Comment #8
longwaveIt is possible this is caused by contrib modules or custom code. If you are seeing this deprecation notice, what did you do to trigger it?
Comment #9
drupal_developer2022 commentedYes! it caused by my custom module, in teaser of node
Indeed, I called the function
text_summary()like this :text_summary($node->get($field_name)->value, NULL, 50);when i have to call it like this
text_summary($node->get($field_name)->value ?? "", NULL, 50);then the error!
Now the error is gone!
Thanks for all!
Comment #10
drupal_developer2022 commentedComment #13
olegrymar commentedComment #14
olegrymar commentedComment #15
olegrymar commentedComment #16
olegrymar commented