From: This, that and the other Date: Tue, 19 Jan 2016 23:30:32 +0000 (+1100) Subject: Prevent revisions with rev_page = 0 from being inserted into the DB X-Git-Tag: 1.31.0-rc.0~8282^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=8fc9222c7ea2f7df12e4c67564058050364a6ea7;p=lhc%2Fweb%2Fwiklou.git Prevent revisions with rev_page = 0 from being inserted into the DB There's no good reason to ever do this, or to write code that lets it happen. The revisions are just going to sit around in the DB, not connected to anything (except maybe in some page's page_latest field, if you're lucky). Any operations that do this should fail fast instead of spamming the DB and appearing to "succeed". Bug: T18674 Change-Id: I8219153a09adb1c556d0159a4fb0799895370a94 --- diff --git a/includes/Revision.php b/includes/Revision.php index 1d7ac72542..bce9781173 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1366,6 +1366,17 @@ class Revision implements IDBAccessObject { public function insertOn( $dbw ) { global $wgDefaultExternalStore, $wgContentHandlerUseDB; + // Not allowed to have rev_page equal to 0, false, etc. + if ( !$this->mPage ) { + $title = $this->getTitle(); + if ( $title instanceof Title ) { + $titleText = ' for page ' . $title->getPrefixedText(); + } else { + $titleText = ''; + } + throw new MWException( "Cannot insert revision$titleText: page ID must be nonzero" ); + } + $this->checkContentModel(); $data = $this->mText;