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

Adds unit tests.

Props UmeshSingla, wonderboymusic.
Fixes #26106

Built from https://develop.svn.wordpress.org/trunk@28814


git-svn-id: http://core.svn.wordpress.org/trunk@28621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-06-24 00:24:14 +00:00
parent 919ff69120
commit 3ebd519a3e

View File

@ -1785,7 +1785,9 @@ class wpdb {
$wheres[] = "`$field` = {$form}";
}
$sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres );
$wheres = empty( $where ) ? '' : ( ' WHERE ' . implode( ' AND ', $wheres ) );
$sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . $wheres;
return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) );
}