From: umherirrender Date: Fri, 24 May 2013 14:17:12 +0000 (+0200) Subject: Apply default robot policy for non-existing user pages X-Git-Tag: 1.31.0-rc.0~19591 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=669e9fc31c19d349668cbe30064402be5c71bb89;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ) {