* Currently __INDEX__ will override __NOINDEX__ regardless of their relative positions, due to the way things are written. Instead, the last one on the page should win. This should be pretty easy to fix.
* __INDEX__ and __NOINDEX__ override $wgArticleRobotPolicies. This is almost certainly incorrect, but it's not totally obvious how to fix it, because of the way the code is structured. Probably not a big deal, but should probably be fixed at some point.
* Anyone can add and remove the magic words, and there's no config option to disable them. It's not obvious whether this is okay or not. It would be a one-line change to OutputPage.php to have a config option to ignore the magic words, maybe per-namespace or who knows what.
=== New features in 1.14 ===
-None yet
+* (bug 8068) New __INDEX__ and __NOINDEX__ magic words allow control of search
+engine indexing on a per-article basis.
=== Bug fixes in 1.14 ===
'numberofadmins',
'defaultsort',
'pagesincategory',
+ 'index',
+ 'noindex',
);
/* Array of caching hints for ParserCache */
'noeditsection',
'newsectionlink',
'hiddencat',
+ 'index',
+ 'noindex',
);
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->mNewSectionLink = $parserOutput->getNewSection();
+ # FIXME: This probably overrides $wgArticleRobotPolicies, is that wise?
+ $this->setIndexPolicy( $parserOutput->getIndexPolicy() );
$this->addKeywords( $parserOutput );
$this->mParseWarnings = $parserOutput->getWarnings();
if ( $parserOutput->getCacheTime() == -1 ) {
wfDebug( __METHOD__.": [[MediaWiki:hidden-category-category]] is not a valid title!\n" );
}
}
+ # (bug 8068) Allow control over whether robots index a page. FIXME:
+ # __INDEX__ always overrides __NOINDEX__ here! This is not desirable,
+ # the last one on the page should win.
+ if( isset( $this->mDoubleUnderscores['noindex'] ) ) {
+ $this->mOutput->setIndexPolicy( 'noindex' );
+ } elseif( isset( $this->mDoubleUnderscores['index'] ) ) {
+ $this->mOutput->setIndexPolicy( 'index' );
+ }
+
return $text;
}
$mWarnings, # Warning text to be returned to the user. Wikitext formatted, in the key only
$mSections, # Table of contents
$mProperties; # Name/value pairs to be cached in the DB
+ private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
/**
* Overridden title for display
function getSubtitle() { return $this->mSubtitle; }
function getOutputHooks() { return (array)$this->mOutputHooks; }
function getWarnings() { return array_keys( $this->mWarnings ); }
+ function getIndexPolicy() { return $this->mIndexPolicy; }
function containsOldMagic() { return $this->mContainsOldMagic; }
function setText( $text ) { return wfSetVar( $this->mText, $text ); }
function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime, $t ); }
function setTitleText( $t ) { return wfSetVar( $this->mTitleText, $t ); }
function setSections( $toc ) { return wfSetVar( $this->mSections, $toc ); }
+ function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy, $policy ); }
function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
'hiddencat' => array( 1, '__HIDDENCAT__' ),
'pagesincategory' => array( 1, 'PAGESINCATEGORY', 'PAGESINCAT' ),
'pagesize' => array( 1, 'PAGESIZE' ),
+ 'index' => array( 1, '__INDEX__' ),
+ 'noindex' => array( 1, '__NOINDEX__' ),
);
/**