From: Brad Jorsch Date: Thu, 25 Oct 2018 13:31:31 +0000 (-0400) Subject: API: Set robots noindex,nofollow on HTML output X-Git-Tag: 1.34.0-rc.0~3635^2 X-Git-Url: http://git.cyclocoop.org//%27http:/code.google.com/p/ie7-js//%27?a=commitdiff_plain;h=46875ad86141fe614eeadbaa843204fa80967218;p=lhc%2Fweb%2Fwiklou.git API: Set robots noindex,nofollow on HTML output There's probably not much benefit in search engines indexing the API auto-generated help or various random "format=jsonfm" outputs. On Wikimedia wikis we already have a robots.txt entry denying indexing of everything under /w/, which includes api.php. Bug: T207818 Change-Id: I196d401eeb5fcf49844265df41ad3cce83ffdcdf --- diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 234fcfdd5e..9d6914579f 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -252,6 +252,7 @@ abstract class ApiFormatBase extends ApiBase { $out = new OutputPage( $context ); $context->setOutput( $out ); + $out->setRobotPolicy( 'noindex,nofollow' ); $out->addModuleStyles( 'mediawiki.apipretty' ); $out->setPageTitle( $context->msg( 'api-format-title' ) ); diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index 72509c233e..84fcbeff7b 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -44,6 +44,7 @@ class ApiHelp extends ApiBase { $context->setLanguage( $this->getMain()->getLanguage() ); $context->setTitle( SpecialPage::getTitleFor( 'ApiHelp' ) ); $out = new OutputPage( $context ); + $out->setRobotPolicy( 'noindex,nofollow' ); $out->setCopyrightUrl( 'https://www.mediawiki.org/wiki/Special:MyLanguage/Copyright' ); $context->setOutput( $out );