API: Clean up skin handling
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 17 Oct 2014 18:39:15 +0000 (11:39 -0700)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 17 Oct 2014 18:47:34 +0000 (11:47 -0700)
* 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
includes/api/ApiHelp.php
includes/skins/SkinApi.php
includes/skins/SkinApiTemplate.php

index 7a08ed7..f0037bb 100644 (file)
@@ -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 ) )
index 0c962d0..8ae05e0 100644 (file)
@@ -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 );
 
index 064c076..2fef220 100644 (file)
@@ -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();
+       }
 }
index be77c61..d5c57eb 100644 (file)
@@ -49,4 +49,18 @@ class SkinApiTemplate extends BaseTemplate {
 
        <?php
        }
+
+       // Skip work and hooks for stuff we don't use
+
+       function getToolbox() {
+               return array();
+       }
+
+       function getPersonalTools() {
+               return array();
+       }
+
+       function getSidebar( $options = array() ) {
+               return array();
+       }
 }