From: Brad Jorsch Date: Wed, 10 May 2017 21:28:24 +0000 (-0400) Subject: Fix usage of $db->nextSequenceValue() X-Git-Tag: 1.31.0-rc.0~3277^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=9ca6b0f64cc58efd2a132f8b08fca8758ce1ab1f;p=lhc%2Fweb%2Fwiklou.git Fix usage of $db->nextSequenceValue() The return value from the method is only suitable for passing to $db->insert(). To get the inserted ID, you need to call $db->insertId() even if $db->nextSequenceValue() returned non-null. Bug: T164900 Change-Id: I6beb6243ccb9425372623307ef23ae6571ce8c0d --- diff --git a/includes/Revision.php b/includes/Revision.php index b20f843497..c3782ba18a 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1496,7 +1496,10 @@ class Revision implements IDBAccessObject { $dbw->insert( 'revision', $row, __METHOD__ ); - $this->mId = $rev_id !== null ? $rev_id : $dbw->insertId(); + if ( $this->mId === null ) { + // Only if nextSequenceValue() was called + $this->mId = $dbw->insertId(); + } // Assertion to try to catch T92046 if ( (int)$this->mId === 0 ) { diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 1c5899ba85..e7095f0b39 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -634,7 +634,7 @@ class ManualLogEntry extends LogEntryBase { } $dbw->insert( 'logging', $data, __METHOD__ ); - $this->id = !is_null( $id ) ? $id : $dbw->insertId(); + $this->id = $dbw->insertId(); $rows = []; foreach ( $relations as $tag => $values ) { diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index 64102b7ec9..f2b16705c7 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -110,7 +110,7 @@ class LogPage { 'log_params' => $this->params ]; $dbw->insert( 'logging', $data, __METHOD__ ); - $newId = !is_null( $log_id ) ? $log_id : $dbw->insertId(); + $newId = $dbw->insertId(); # And update recentchanges if ( $this->updateRecentChanges ) {