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?

Issue fork drupal-3312931

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:

  • 3312931-d9-php-8.1 Comparecompare

Comments

drupal_developer2022 created an issue. See original summary.

drupal_developer2022’s picture

Priority: Normal » Critical
heni_deepak’s picture

Could you share some steps to reproduce this issue.

drupal_developer2022’s picture

My 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.

heni_deepak’s picture

I 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.

heni_deepak’s picture

Category: Bug report » Support request
Priority: Critical » Normal
walii’s picture

Kindly use PHP version 8.0

longwave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

It 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?

drupal_developer2022’s picture

Yes! 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!

drupal_developer2022’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

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

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

olegrymar’s picture

olegrymar’s picture

Version: 9.4.x-dev » 9.5.x-dev
olegrymar’s picture

olegrymar’s picture