From a6c9dcc13e1ae0b03d804a34fa79be230813f776 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 24 May 2012 16:48:46 +0200 Subject: [PATCH] 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 --- includes/LinksUpdate.php | 4 ++++ 1 file changed, 4 insertions(+) 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(); -- 2.20.1