Make WordPress Core


Ignore:
Timestamp:
06/24/2014 12:23:09 AM (11 years ago)
Author:
wonderboymusic
Message:

In $wpdb->update(), prevent explosions when $where is empty.

Adds unit tests.

Props UmeshSingla, wonderboymusic.
Fixes #26106

File:
1 edited

Legend:

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

    r28711 r28814  
    17861786        }
    17871787
    1788         $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres );
     1788        $wheres = empty( $where ) ? '' : ( ' WHERE ' . implode( ' AND ', $wheres ) );
     1789
     1790        $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . $wheres;
    17891791        return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) );
    17901792    }
Note: See TracChangeset for help on using the changeset viewer.