Reset $wpdb->insert_id on a failed INSERT or REPLACE. See [24459] [24494].

git-svn-id: http://core.svn.wordpress.org/trunk@24872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-07-29 18:14:05 +00:00
parent 7f12e16e47
commit f39e2c28ce

View File

@ -1204,6 +1204,10 @@ class wpdb {
// If there is an error then take note of it..
if ( $this->last_error = mysql_error( $this->dbh ) ) {
// Clear insert_id on a subsequent failed insert.
if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) )
$this->insert_id = 0;
$this->print_error();
return false;
}