From 7fb4d441c945b7b7c36cf025bca7324615677ec3 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Wed, 6 Feb 2008 00:55:52 +0000 Subject: [PATCH] Make the default robot policy a configurable option. Also replace some odd hardcoded robot policies (for Special:Specialpages and for nonexistent images) with 'noindex,nofollow', which seems more appropriate at least for the latter. I'm not quite sure _why_ Special:Specialpages was marked as 'index,nofollow' before; it's been that way since r1284. It might be safe to just leave it at the default setting, but I don't really think it makes much difference either way. --- RELEASE-NOTES | 2 ++ includes/Article.php | 4 ++-- includes/DefaultSettings.php | 9 ++++++++- includes/ImagePage.php | 2 +- includes/SpecialSpecialpages.php | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a63aedd956..37954e8ee1 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -155,6 +155,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 10365) Localization of Special:Version * When installing using Postgres, the Pl/Pgsql language is now checked for and installed when at the superuser level. +* The default robot policy for the entire wiki is now configurable via the + $wgDefaultRobotPolicy setting. === Bug fixes in 1.12 === diff --git a/includes/Article.php b/includes/Article.php index 69fc053812..7197a32f97 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -613,6 +613,7 @@ class Article { global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgParser; global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies; + global $wgDefaultRobotPolicy; $sk = $wgUser->getSkin(); wfProfileIn( __METHOD__ ); @@ -647,8 +648,7 @@ class Article { # Honour customised robot policies for this namespace $policy = $wgNamespaceRobotPolicies[$ns]; } else { - # Default to encourage indexing and following links - $policy = 'index,follow'; + $policy = $wgDefaultRobotPolicy; } $wgOut->setRobotPolicy( $policy ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1679c303f1..d9c7c26579 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2484,9 +2484,16 @@ $wgNoFollowLinks = true; */ $wgNoFollowNsExceptions = array(); +/** + * Default robot policy. + * The default policy is to encourage indexing and following of links. + * It may be overridden on a per-namespace and/or per-page basis. + */ +$wgDefaultRobotPolicy = 'index,follow'; + /** * Robot policies per namespaces. - * The default policy is 'index,follow', the array is made of namespace + * The default policy is given above, the array is made of namespace * constants as defined in includes/Defines.php * Example: * $wgNamespaceRobotPolicies = array( NS_TALK => 'noindex' ); diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 846f0d9ab2..83368373fb 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -69,7 +69,7 @@ class ImagePage extends Article { } else { # Just need to set the right headers $wgOut->setArticleFlag( true ); - $wgOut->setRobotpolicy( 'index,follow' ); + $wgOut->setRobotpolicy( 'noindex,nofollow' ); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); $this->viewUpdates(); } diff --git a/includes/SpecialSpecialpages.php b/includes/SpecialSpecialpages.php index a893966cdc..4ea956b899 100644 --- a/includes/SpecialSpecialpages.php +++ b/includes/SpecialSpecialpages.php @@ -12,7 +12,7 @@ function wfSpecialSpecialpages() { $wgMessageCache->loadAllMessages(); - $wgOut->setRobotpolicy( 'index,nofollow' ); + $wgOut->setRobotpolicy( 'noindex,nofollow' ); # Is this really needed? $sk = $wgUser->getSkin(); /** Pages available to all */ -- 2.20.1