Port (with changes) r110866 to trunk. Reviewed by Brion before commit.
authorAndrew Garrett <werdna@users.mediawiki.org>
Mon, 13 Feb 2012 22:32:44 +0000 (22:32 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Mon, 13 Feb 2012 22:32:44 +0000 (22:32 +0000)
docs/hooks.txt
includes/Article.php

index 70fe639..209ff2e 100644 (file)
@@ -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
index 99997c8..6356f1a 100644 (file)
@@ -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 = "<div class='noarticletext'>\n$text\n</div>";
 
-               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 );
        }