From: This, that and the other Date: Sun, 3 Jan 2016 13:30:24 +0000 (+1100) Subject: Import: Try to stop revisions getting created with rev_page = 0 X-Git-Tag: 1.31.0-rc.0~8460 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/%7B%7B%20url_for%28%27vote%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=2cc10db0426d0181e9ffb4f73d050fb8068d4621;p=lhc%2Fweb%2Fwiklou.git Import: Try to stop revisions getting created with rev_page = 0 It seems that when two simultaneous imports of the same page are started, we get into the situation where $pageId is 0 (or at least something that is transformed to 0 when inserted into the DB). I can't reproduce this locally, so I can't tell you *why* this is happening. But what is important is to stop it from happening. Bug: T18674 Change-Id: I79406a1ef8e5db9a31f029438f8132ef590216fe --- diff --git a/includes/import/WikiRevision.php b/includes/import/WikiRevision.php index 6c238cf9f2..90b048a6bd 100644 --- a/includes/import/WikiRevision.php +++ b/includes/import/WikiRevision.php @@ -463,7 +463,7 @@ class WikiRevision { $page = WikiPage::factory( $this->title ); $page->loadPageData( 'fromdbmaster' ); if ( !$page->exists() ) { - # must create the page... + // must create the page... $pageId = $page->insertOn( $dbw ); $created = true; $oldcountable = null; @@ -486,7 +486,17 @@ class WikiRevision { } } + if ( !$pageId ) { + // This seems to happen if two clients simultaneously try to import the + // same page + wfDebug( __METHOD__ . ': got invalid $pageId when importing revision of [[' . + $this->title->getPrefixedText() . ']], timestamp ' . $this->timestamp . "\n" ); + return false; + } + // Select previous version to make size diffs correct + // @todo This assumes that multiple revisions of the same page are imported + // in order from oldest to newest. $prevId = $dbw->selectField( 'revision', 'rev_id', array( 'rev_page' => $pageId,