From 938871aa5615f81701fc36aaa7ba72a3d9469b0f Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Mon, 13 Feb 2012 22:32:44 +0000 Subject: [PATCH] Port (with changes) r110866 to trunk. Reviewed by Brion before commit. --- docs/hooks.txt | 5 +++++ includes/Article.php | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 70fe6396fb..209ff2ee37 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -587,6 +587,11 @@ $name: Image name being checked Change $bad and return false to override. If an image is "bad", it is not rendered inline in wiki pages or galleries in category pages. +'BeforeDisplayNoArticleText': before displaying noarticletext or noarticletext-nopermission +at Article::showMissingArticle() + +$article: article object + 'BeforeInitialize': before anything is initialized in MediaWiki::performRequest() &$title: Title being used for request $unused: null diff --git a/includes/Article.php b/includes/Article.php index 99997c86b1..6356f1a654 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -988,6 +988,18 @@ class Article extends Page { 'msgKey' => array( 'moveddeleted-notice' ) ) ); + if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) { + // If there's no backing content, send a 404 Not Found + // for better machine handling of broken links. + $wgRequest->response()->header( "HTTP/1.1 404 Not Found" ); + } + + $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) ); + + if ( ! $hookResult ) { + return; + } + # Show error message $oldid = $this->getOldID(); if ( $oldid ) { @@ -1010,12 +1022,6 @@ class Article extends Page { } $text = "
\n$text\n
"; - if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) { - // If there's no backing content, send a 404 Not Found - // for better machine handling of broken links. - $wgRequest->response()->header( "HTTP/1.1 404 Not Found" ); - } - $wgOut->addWikiText( $text ); } -- 2.20.1