From 669e9fc31c19d349668cbe30064402be5c71bb89 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 24 May 2013 16:17:12 +0200 Subject: [PATCH] Apply default robot policy for non-existing user pages MediaWiki is sending HTTP 200 for every user page, this can result in search engine indexing user pages with block hint. This is not happen, when the page exists (even it is empty), so applying the default robot policy also for non-existing user pages to avoid this. Change-Id: Ia62b977b3488d6b002c7b129d9308b7887e4f42d --- includes/Article.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index a0d4438222..dc5791189e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -855,11 +855,11 @@ class Article implements Page { /** * Get the robot policy to be used for the current view * @param string $action the action= GET parameter - * @param $pOutput ParserOutput + * @param $pOutput ParserOutput|null * @return Array the policy that should be set * TODO: actions other than 'view' */ - public function getRobotPolicy( $action, $pOutput ) { + public function getRobotPolicy( $action, $pOutput = null ) { global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy; $ns = $this->getTitle()->getNamespace(); @@ -1142,6 +1142,13 @@ class Article implements Page { $this->getContext()->getRequest()->response()->header( "HTTP/1.1 404 Not Found" ); } + if ( $validUserPage ) { + // Also apply the robot policy for nonexisting user pages (as those aren't served as 404) + $policy = $this->getRobotPolicy( 'view' ); + $outputPage->setIndexPolicy( $policy['index'] ); + $outputPage->setFollowPolicy( $policy['follow'] ); + } + $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) ); if ( ! $hookResult ) { -- 2.20.1