[PHP 8.0] Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in _views_bulk_operations_rules_get_field() (line 278 of views_bulk_operations.rules.inc)

Created on 15 November 2022, over 1 year ago
Updated 18 November 2023, 7 months ago

Problem/Motivation

I get this error when certain VBO rules are run.

[PHP 8.0] Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in _views_bulk_operations_rules_get_field() (line 278 of views_bulk_operations.rules.inc)

Steps to reproduce

The $args variable is NULL. Here's a rules config. After saving a taxonomy term of a certain bundle, it loops through them all to ensure only one of them has a certain boolean field checked.

function my_module_features_default_rules_configuration() {
  $items = array();
  $items['rules_set_single_term'] = entity_import('rules_config', '{ "rules_set_single_term" : {
      "LABEL" : "Set single term",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "rules", "views_bulk_operations", "taxonomy" ],
      "ON" : {
        "taxonomy_term_update--my_terms" : { "bundle" : "my_terms" },
        "taxonomy_term_insert--my_terms" : { "bundle" : "my_terms" }
      },
      "IF" : [ { "data_is" : { "data" : [ "term:field-boolean" ], "value" : "1" } } ],
      "DO" : [
        { "views_bulk_operations_action_load_list" : {
            "USING" : { "view" : "my_terms|attachment_1", "args" : [ "" ] },
            "PROVIDE" : { "entity_list" : { "my_terms_terms" : "My Terms Terms" } }
          }
        },
        { "LOOP" : {
            "USING" : { "list" : [ "my-term-terms" ] },
            "ITEM" : { "my_term_term" : "My Term Term" },
            "DO" : [
              { "component_unset_my_term_field" : {
                  "designated_term" : [ "term" ],
                  "other_term" : [ "my-term-term" ]
                }
              }
            ]
          }
        }
      ]
    }
  }');
  return $items;
}

Proposed resolution

Change the line to

  $args = ($args === NULL) ? '' : $args;
  $view_arguments = explode("\n", $args);

Which maintains compatibility with PHP < 8

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

RTBC

Version

3.0

Component

Core

Created by

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

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

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to RTBC 7 months ago
  • πŸ‡¬πŸ‡§United Kingdom SteveWilson

    I too was seeing this issue. The patch referenced at #5 works for me so marking as RTBC.

Production build 0.69.0 2024