WordPress.org

Make WordPress Core

Changeset 48980


Ignore:
Timestamp:
09/16/2020 01:46:25 AM (2 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Return an empty string from wpdb::_real_escape() if a non-scalar value is passed.

This avoids a fatal error on PHP 8 caused by passing a non-string value to mysqli_real_escape_string(), and maintains the current behaviour.

See #50913, #50639.

File:
1 edited

Legend:

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

    r48591 r48980  
    11601160     */
    11611161    function _real_escape( $string ) {
     1162        if ( ! is_scalar( $string ) && ! is_null( $string ) ) {
     1163            return '';
     1164        }
     1165
    11621166        if ( $this->dbh ) {
    11631167            if ( $this->use_mysqli ) {
Note: See TracChangeset for help on using the changeset viewer.