From 58dba7d8b2a3c75b9f369dcb2def81a8d061a72d Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 31 Mar 2015 13:28:45 -0400 Subject: [PATCH] Add checks to try to catch T92046 Somehow, revisions are getting added to the database without issue but page_latest is being set to 0 rather than the newly-added revision ID. Grepping through the code, the only places page_latest gets set are WikiPage::insertOn() (which isn't relevant for an edit of an existing page) and WikiPage::updateRevisionOn(). And the only relevant-looking place WikiPage::updateRevisionOn() gets called seems to be WikiPage::doEditContent(), which calls Revision::insertOn() just before which *should* be setting the mId on the revision object. Since there's no obvious bug in the code, let's add some checks to make sure that the revision ID isn't 0. If we see exceptions being thrown, at least we'll have narrowed down the places we need to look more deeply. And if not (and the bug continues to be reported), we'll at least know this part is working right. Bug: T92046 Change-Id: I8cc60593fafb5702e29186ec14cb9d87f1767ef4 --- includes/Revision.php | 8 ++++++++ includes/page/WikiPage.php | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/includes/Revision.php b/includes/Revision.php index 356cd32ce9..7bea3bafad 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1411,6 +1411,14 @@ class Revision implements IDBAccessObject { $this->mId = $rev_id !== null ? $rev_id : $dbw->insertId(); + // Assertion to try to catch T92046 + if ( (int)$this->mId === 0 ) { + throw new UnexpectedValueException( + 'After insert, Revision mId is ' . var_export( $this->mId, 1 ) . ': ' . + var_export( $row, 1 ) + ); + } + Hooks::run( 'RevisionInsertComplete', array( &$this, $data, $flags ) ); return $this->mId; diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 0452c41500..360b4dee8b 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -1271,6 +1271,13 @@ class WikiPage implements Page, IDBAccessObject { ) { global $wgContentHandlerUseDB; + // Assertion to try to catch T92046 + if ( (int)$revision->getId() === 0 ) { + throw new InvalidArgumentException( + __METHOD__ . ': Revision has ID ' . var_export( $revision->getId(), 1 ) + ); + } + $content = $revision->getContent(); $len = $content ? $content->getSize() : 0; $rt = $content ? $content->getUltimateRedirectTarget() : null; -- 2.20.1