Adding sanity check to the LinksUpdate() constructor.
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 24 May 2012 14:48:46 +0000 (16:48 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 29 May 2012 13:44:58 +0000 (15:44 +0200)
The check makes sure that the page id is known for the title
passed to the constructor. LinksUpdate needs to know this id in
order to update the various links tables. If the page id is not
known to the title (e.g. because the page doesn't actually exist)
something is wrong, and LinksUpdate can't operate.

Amend: use MWException instead of assert()

Change-Id: I4873211a71099fe3563b52a53532c95b6a2ff30f

includes/LinksUpdate.php

index 8b403fc..0712ac8 100644 (file)
@@ -66,6 +66,10 @@ class LinksUpdate extends SqlDataUpdate {
                $this->mTitle = $title;
                $this->mId = $title->getArticleID();
 
+               if ( !$this->mId ) {
+                       throw new MWException( "The Title object did not provide an article ID. Perhaps the page doesn't exist?" );
+               }
+
                $this->mParserOutput = $parserOutput;
                $this->mLinks = $parserOutput->getLinks();
                $this->mImages = $parserOutput->getImages();