Make WordPress Core

Changeset 51396


Ignore:
Timestamp:
07/10/2021 11:14:46 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Only check collation in wpdb methods if the query is not empty.

This avoids a deprecation notice on PHP 8.1 caused by passing null instead of a string to ltrim() in wpdb::check_safe_collation(), and maintains the current behaviour.

Follow-up to [30345], [32162], [33455].

See #53635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/wp-db.php

    r51298 r51396  
    25742574        $this->func_call = "\$db->get_var(\"$query\", $x, $y)";
    25752575
    2576         if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
    2577             $this->check_current_query = false;
    2578         }
    2579 
    25802576        if ( $query ) {
     2577            if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
     2578                $this->check_current_query = false;
     2579            }
     2580
    25812581            $this->query( $query );
    25822582        }
     
    26082608        $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
    26092609
    2610         if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
    2611             $this->check_current_query = false;
    2612         }
    2613 
    26142610        if ( $query ) {
     2611            if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
     2612                $this->check_current_query = false;
     2613            }
     2614
    26152615            $this->query( $query );
    26162616        } else {
     
    26502650     */
    26512651    public function get_col( $query = null, $x = 0 ) {
    2652         if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
    2653             $this->check_current_query = false;
    2654         }
    2655 
    26562652        if ( $query ) {
     2653            if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
     2654                $this->check_current_query = false;
     2655            }
     2656
    26572657            $this->query( $query );
    26582658        }
     
    26882688        $this->func_call = "\$db->get_results(\"$query\", $output)";
    26892689
    2690         if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
    2691             $this->check_current_query = false;
    2692         }
    2693 
    26942690        if ( $query ) {
     2691            if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
     2692                $this->check_current_query = false;
     2693            }
     2694
    26952695            $this->query( $query );
    26962696        } else {
Note: See TracChangeset for help on using the changeset viewer.