From 1cd0618cd458eb9c96ec35cabb32b89cc75c1889 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 17 Oct 2014 11:39:15 -0700 Subject: [PATCH] API: Clean up skin handling * Set a more sensible value for the "title" of the page (Special:ApiHelp rather than API) * Avoid calling various skin-related hooks that aren't going to be used. * Don't override the user in the DerivativeContext, MessageCache doesn't pay attention to it anyway for ->parse(). Bug: 72131 Bug: 72174 Change-Id: Idc42ab6526d640dc68fa93f6b4c5524b3d9e2e44 --- includes/api/ApiFormatBase.php | 5 +++-- includes/api/ApiHelp.php | 2 +- includes/skins/SkinApi.php | 30 ++++++++++++++++++++++++++++++ includes/skins/SkinApiTemplate.php | 14 ++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 7a08ed7d1b..f0037bb291 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -155,12 +155,13 @@ abstract class ApiFormatBase extends ApiBase { $result = $this->getBuffer(); $context = new DerivativeContext( $this->getMain() ); - $context->setUser( new User ); // anon to avoid caching issues $context->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'apioutput' ) ); + $context->setTitle( SpecialPage::getTitleFor( 'ApiHelp' ) ); $out = new OutputPage( $context ); + $context->setOutput( $out ); + $out->addModules( 'mediawiki.apipretty' ); $out->setPageTitle( $context->msg( 'api-format-title' ) ); - $context->setOutput( $out ); $header = $context->msg( 'api-format-prettyprint-header' ) ->params( $format, strtolower( $format ) ) diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index 0c962d0a96..8ae05e0a12 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -43,9 +43,9 @@ class ApiHelp extends ApiBase { // Get the help $context = new DerivativeContext( $this->getMain()->getContext() ); - $context->setUser( new User ); // anon to avoid caching issues $context->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'apioutput' ) ); $context->setLanguage( $this->getMain()->getLanguage() ); + $context->setTitle( SpecialPage::getTitleFor( 'ApiHelp' ) ); $out = new OutputPage( $context ); $context->setOutput( $out ); diff --git a/includes/skins/SkinApi.php b/includes/skins/SkinApi.php index 064c076b91..2fef2209c8 100644 --- a/includes/skins/SkinApi.php +++ b/includes/skins/SkinApi.php @@ -38,4 +38,34 @@ class SkinApi extends SkinTemplate { parent::setupSkinUserCss( $out ); $out->addModuleStyles( 'mediawiki.skinning.interface' ); } + + // Skip work and hooks for stuff we don't use + + function buildSidebar() { + return array(); + } + + function getNewtalks() { + return ''; + } + + function getSiteNotice() { + return ''; + } + + public function getLanguages() { + return array(); + } + + protected function buildPersonalUrls() { + return array(); + } + + protected function buildContentNavigationUrls() { + return array(); + } + + protected function buildNavUrls() { + return array(); + } } diff --git a/includes/skins/SkinApiTemplate.php b/includes/skins/SkinApiTemplate.php index be77c617ee..d5c57eb22c 100644 --- a/includes/skins/SkinApiTemplate.php +++ b/includes/skins/SkinApiTemplate.php @@ -49,4 +49,18 @@ class SkinApiTemplate extends BaseTemplate {