From: Aryeh Gregor Date: Thu, 24 Jul 2008 18:02:20 +0000 (+0000) Subject: Instead of last commit, use $wgExemptFromUserRobotsControl to control __INDEX__/__NOI... X-Git-Tag: 1.31.0-rc.0~46387 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=386fb2ba9c4495fd072c2448bb9861c1a28f90ed;p=lhc%2Fweb%2Fwiklou.git Instead of last commit, use $wgExemptFromUserRobotsControl to control __INDEX__/__NOINDEX__. This defaults to null, which means $wgContentNamespaces. Pages whose namespaces are in the array will be unaffected by __INDEX__/__NOINDEX__. This will prevent serious vandalism, so the feature is again enabled by default (with content namespaces exempted). As was pointed out, it's probably better anyway that the vandal noindex a page and have nothing turn up in searches if the search engine arrives at that exact time, than to have the vandal replace the page with "ARTICLE SUBJECT IS A POOPY-HEAD" and have that turn up in searches if the search engine arrives at that exact time. :) At any rate, this should solve the issue. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 841c37eba6..0195a95a0b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -20,13 +20,14 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN === Configuration changes in 1.14 === -* (bug 8068) $wgAllowUserRobotsControl (false by default) can enable new - __INDEX__ and __NOINDEX__ magic words, which allow user control of search en- - gine indexing on a per-article basis. +* $wgExemptFromUserRobotsControl is an array of namespaces to be exempt from + the effect of the new __INDEX__/__NOINDEX__ magic words. (Default: null, ex- + empt all content namespaces.) === New features in 1.14 === -None yet +* (bug 8068) New __INDEX__ and __NOINDEX__ magic words allow user control of + search engine indexing on a per-article basis. === Bug fixes in 1.14 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3cbc409f31..44fe55a49e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2824,11 +2824,13 @@ $wgNamespaceRobotPolicies = array(); $wgArticleRobotPolicies = array(); /** - * Set to true to allow the __INDEX__ and __NOINDEX__ magic words to function. - * These will allow users to control whether any page they can edit is indexed - * by search engines. + * An array of namespace keys in which the __INDEX__/__NOINDEX__ magic words + * will not function, so users can't decide whether pages in that namespace are + * indexed by search engines. If set to null, default to $wgContentNamespaces. + * Example: + * $wgExemptFromUserRobotsControl = array( NS_MAIN, NS_TALK, NS_PROJECT ); */ -$wgAllowUserRobotsControl = false; +$wgExemptFromUserRobotsControl = null; /** * Specifies the minimal length of a user password. If set to diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 7fc00adbed..6c4b7483d2 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -472,15 +472,23 @@ class OutputPage { * @param ParserOutput object &$parserOutput */ public function addParserOutputNoText( &$parserOutput ) { - global $wgAllowUserRobotsControl; + global $wgTitle, $wgExemptFromUserRobotsControl, $wgContentNamespaces; $this->mLanguageLinks += $parserOutput->getLanguageLinks(); $this->addCategoryLinks( $parserOutput->getCategories() ); $this->mNewSectionLink = $parserOutput->getNewSection(); - if( $wgAllowUserRobotsControl ) { - # FIXME: This probably overrides $wgArticleRobotPolicies, is that wise? + + if( is_null( $wgExemptFromUserRobotsControl ) ) { + $bannedNamespaces = $wgContentNamespaces; + } else { + $bannedNamespaces = $wgExemptFromUserRobotsControl; + } + if( !in_array( $wgTitle->getNamespace(), $bannedNamespaces ) ) { + # FIXME (bug 14900): This overrides $wgArticleRobotPolicies, and it + # shouldn't $this->setIndexPolicy( $parserOutput->getIndexPolicy() ); } + $this->addKeywords( $parserOutput ); $this->mParseWarnings = $parserOutput->getWarnings(); if ( $parserOutput->getCacheTime() == -1 ) {