From: daniel Date: Thu, 24 May 2012 14:48:46 +0000 (+0200) Subject: Adding sanity check to the LinksUpdate() constructor. X-Git-Tag: 1.31.0-rc.0~23441^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=a6c9dcc13e1ae0b03d804a34fa79be230813f776;p=lhc%2Fweb%2Fwiklou.git Adding sanity check to the LinksUpdate() constructor. 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 --- diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 8b403fcd85..0712ac807b 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -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();