[PHP8.1] Deprecated function: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in apachesolr_clean_text()

Created on 28 July 2023, over 1 year ago
Updated 18 December 2023, about 1 year ago

Problem/Motivation

On php 8.1 I catched php warning. Deprecated function: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in apachesolr_clean_text().

Steps to reproduce:

1) Create node with empty field of Text filed type.
2) Run drush solr-mark-all.
3) Run drush solr-index.

Root cause:

1) In apachesolr_fields_default_indexing_callback null is passed to apachesolr_clean_text().
2) Also noticed that in apachesolr_index_add_tags_to_document() empty string can be passed.

Proposed resolution:

Add code to the apachesolr_clean_text() function at the beginning of execution:

if (empty($text)) {
    return '';
  }
🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇧🇾Belarus alena_stanul

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

Production build 0.71.5 2024