strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in template_preprocess_footable_view()

Created on 22 February 2023, almost 2 years ago
Updated 31 March 2023, over 1 year ago

On updating to PHP 8.1, I get the following report.

Deprecated function: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in template_preprocess_footable_view() (line 206 of /home/ipmsusa3/public_html/drupal7/sites/all/modules/contrib/footable/footable.module).

This look similar to https://www.drupal.org/project/lagoon_logs/issues/3334327 🐛 PHP 8.1 - PHP Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in LagoonLogger.php on line 162 RTBC and applying that type of fix to

    elseif (drupal_strlen($field_handler->last_render) != drupal_strlen(strip_tags($field_handler->last_render))) {

to this

    elseif (drupal_strlen($field_handler->last_render) != drupal_strlen(strip_tags($field_handler->last_render ?? ''))) {

seems to work.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇸United States aitala

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

  • Issue created by @aitala
  • Status changed to Needs review almost 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work almost 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -    elseif (drupal_strlen($field_handler->last_render) != drupal_strlen(strip_tags($field_handler->last_render))) {
    +    elseif (drupal_strlen($field_handler->last_render) != drupal_strlen(strip_tags((string) $field_handler->last_render ?? ''))) {
    

    If $field_handler->last_render is not a string, it is pointless to execute that code, as zero (drupal_strlen($field_handler->last_render)) is equal to zero (drupal_strlen(strip_tags((string) $field_handler->last_render ?? '')).

  • First commit to issue fork.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sahil.goyal

    Addressed the comment #4, So to address this issue modified the code to check if $field_handler->last_render is a string before executing the drupal_strlen and strip_tags functions.
    Before attempting to check here its length and strip out any tags, If $field_handler->last_render is not a string, the code inside the if statement will not be executed.

    So updating the patch and attaching Interdiff.

Production build 0.71.5 2024