WordPress.org

Make WordPress Core

Changeset 51806


Ignore:
Timestamp:
09/13/2021 06:53:57 PM (4 months ago)
Author:
hellofromTonya
Message:

Code Modernization: Fix "passing null to non-nullable" deprecation notice in WP_Comment_Query::get_comment_ids().

The WP_Comment_Query::get_comment_ids() method is supposed to handle null as a search query, but was throwing a strlen(): Passing null to parameter #1 ($string) of type string is deprecated notice on PHP 8.1.

Discovered via and already covered via the pre-existing Tests_Comment_Query::test_search_null_should_be_ignored() test method.

Follow-up to [36345], [48275].

Props jrf, hellofromTonya.
See #53635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-comment-query.php

    r51518 r51806  
    802802
    803803        // Falsey search strings are ignored.
    804         if ( strlen( $this->query_vars['search'] ) ) {
     804        if ( isset( $this->query_vars['search'] ) && strlen( $this->query_vars['search'] ) ) {
    805805            $search_sql = $this->get_search_sql(
    806806                $this->query_vars['search'],
Note: See TracChangeset for help on using the changeset viewer.