r38004 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38003‎ | r38004 | r38005 >
Date:18:02, 24 July 2008
Author:simetrical
Status:old
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -472,15 +472,23 @@
473473 * @param ParserOutput object &$parserOutput
474474 */
475475 public function addParserOutputNoText( &$parserOutput ) {
476 - global $wgAllowUserRobotsControl;
 476+ global $wgTitle, $wgExemptFromUserRobotsControl, $wgContentNamespaces;
477477
478478 $this->mLanguageLinks += $parserOutput->getLanguageLinks();
479479 $this->addCategoryLinks( $parserOutput->getCategories() );
480480 $this->mNewSectionLink = $parserOutput->getNewSection();
481 - if( $wgAllowUserRobotsControl ) {
482 - # FIXME: This probably overrides $wgArticleRobotPolicies, is that wise?
 481+
 482+ if( is_null( $wgExemptFromUserRobotsControl ) ) {
 483+ $bannedNamespaces = $wgContentNamespaces;
 484+ } else {
 485+ $bannedNamespaces = $wgExemptFromUserRobotsControl;
 486+ }
 487+ if( !in_array( $wgTitle->getNamespace(), $bannedNamespaces ) ) {
 488+ # FIXME (bug 14900): This overrides $wgArticleRobotPolicies, and it
 489+ # shouldn't
483490 $this->setIndexPolicy( $parserOutput->getIndexPolicy() );
484491 }
 492+
485493 $this->addKeywords( $parserOutput );
486494 $this->mParseWarnings = $parserOutput->getWarnings();
487495 if ( $parserOutput->getCacheTime() == -1 ) {
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2824,11 +2824,13 @@
28252825 $wgArticleRobotPolicies = array();
28262826
28272827 /**
2828 - * Set to true to allow the __INDEX__ and __NOINDEX__ magic words to function.
2829 - * These will allow users to control whether any page they can edit is indexed
2830 - * by search engines.
 2828+ * An array of namespace keys in which the __INDEX__/__NOINDEX__ magic words
 2829+ * will not function, so users can't decide whether pages in that namespace are
 2830+ * indexed by search engines. If set to null, default to $wgContentNamespaces.
 2831+ * Example:
 2832+ * $wgExemptFromUserRobotsControl = array( NS_MAIN, NS_TALK, NS_PROJECT );
28312833 */
2832 -$wgAllowUserRobotsControl = false;
 2834+$wgExemptFromUserRobotsControl = null;
28332835
28342836 /**
28352837 * Specifies the minimal length of a user password. If set to
Index: trunk/phase3/RELEASE-NOTES
@@ -20,13 +20,14 @@
2121
2222 === Configuration changes in 1.14 ===
2323
24 -* (bug 8068) $wgAllowUserRobotsControl (false by default) can enable new
25 - __INDEX__ and __NOINDEX__ magic words, which allow user control of search en-
26 - gine indexing on a per-article basis.
 24+* $wgExemptFromUserRobotsControl is an array of namespaces to be exempt from
 25+ the effect of the new __INDEX__/__NOINDEX__ magic words. (Default: null, ex-
 26+ empt all content namespaces.)
2727
2828 === New features in 1.14 ===
2929
30 -None yet
 30+* (bug 8068) New __INDEX__ and __NOINDEX__ magic words allow user control of
 31+ search engine indexing on a per-article basis.
3132
3233 === Bug fixes in 1.14 ===
3334

Status & tagging log