Make WordPress Core

Changeset 52206


Ignore:
Timestamp:
11/18/2021 02:35:22 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Database: Check if the $args[0] value exists in wpdb::prepare() before accessing it.

This avoids an Undefined array key 0 PHP warning if no values are passed to the method besides the query string.

Follow-up to [41470].

Props mjaschen.
Fixes #54453.

File:
1 edited

Legend:

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

    r52195 r52206  
    13961396        // If args were passed as an array (as in vsprintf), move them up.
    13971397        $passed_as_array = false;
    1398         if ( is_array( $args[0] ) && count( $args ) === 1 ) {
     1398        if ( isset( $args[0] ) && is_array( $args[0] ) && 1 === count( $args ) ) {
    13991399            $passed_as_array = true;
    14001400            $args            = $args[0];
Note: See TracChangeset for help on using the changeset viewer.