diff options
author | Brad Jorsch <bjorsch@wikimedia.org> | 2018-04-23 16:57:28 -0400 |
---|---|---|
committer | Legoktm <legoktm@member.fsf.org> | 2018-04-26 05:13:30 +0000 |
commit | aa54a4caa3d592bcae9f44549a46cd655388b79b (patch) | |
tree | 828d3c12e6603cd714be92a272e0853ef87356dc | |
parent | 1bd573752fcdc21f26780258029ed38b90093ed7 (diff) | |
download | mediawikicore-aa54a4caa3d592bcae9f44549a46cd655388b79b.tar.gz mediawikicore-aa54a4caa3d592bcae9f44549a46cd655388b79b.zip |
import: Don't try duplicate detection when the sha1 is unavailable
Trying to compare a string field with 0 (cast from false) raises an
error in PostgreSQL, and we're expecting it to not detect duplicates in
that situation anyway.
Change-Id: Ibff6daee6bbec00e37532e03c9ece041ba612de0
(cherry picked from commit f09d66de2ab88e3ed39fc21b3805cea90eee5bfe)
-rw-r--r-- | includes/import/ImportableOldRevisionImporter.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/includes/import/ImportableOldRevisionImporter.php b/includes/import/ImportableOldRevisionImporter.php index 33fad3e62693..066a3eacef53 100644 --- a/includes/import/ImportableOldRevisionImporter.php +++ b/includes/import/ImportableOldRevisionImporter.php @@ -68,18 +68,20 @@ class ImportableOldRevisionImporter implements OldRevisionImporter { // Note: sha1 has been in XML dumps since 2012. If you have an // older dump, the duplicate detection here won't work. - $prior = $dbw->selectField( 'revision', '1', - [ 'rev_page' => $pageId, + if ( $importableRevision->getSha1Base36() !== false ) { + $prior = $dbw->selectField( 'revision', '1', + [ 'rev_page' => $pageId, 'rev_timestamp' => $dbw->timestamp( $importableRevision->getTimestamp() ), 'rev_sha1' => $importableRevision->getSha1Base36() ], - __METHOD__ - ); - if ( $prior ) { - // @todo FIXME: This could fail slightly for multiple matches :P - $this->logger->debug( __METHOD__ . ": skipping existing revision for [[" . - $importableRevision->getTitle()->getPrefixedText() . "]], timestamp " . - $importableRevision->getTimestamp() . "\n" ); - return false; + __METHOD__ + ); + if ( $prior ) { + // @todo FIXME: This could fail slightly for multiple matches :P + $this->logger->debug( __METHOD__ . ": skipping existing revision for [[" . + $importableRevision->getTitle()->getPrefixedText() . "]], timestamp " . + $importableRevision->getTimestamp() . "\n" ); + return false; + } } } |