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

git-svn-id: https://develop.svn.wordpress.org/trunk@24872 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-07-29 18:14:05 +00:00
parent 5a0e739cc7
commit 16adf7644b

View File

@ -1204,6 +1204,10 @@ class wpdb {
// If there is an error then take note of it.. // If there is an error then take note of it..
if ( $this->last_error = mysql_error( $this->dbh ) ) { 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(); $this->print_error();
return false; return false;
} }