Drop deprecated EnableAPI and EnableWriteAPI settings
authorJames D. Forrester <jforrester@wikimedia.org>
Mon, 20 Nov 2017 23:50:22 +0000 (15:50 -0800)
committerKrinkle <krinklemail@gmail.com>
Wed, 18 Apr 2018 00:30:34 +0000 (00:30 +0000)
The siteinfo API response's 'writeapi' value is now hard-set to true,
as are the ResourceLoader variables wgEnableAPI and wgEnableWriteAPI,
to be deprecated later.

Bug: T115414
Change-Id: I54ff9428b247ba203d67aba079149393f323d5a9

16 files changed:
RELEASE-NOTES-1.32
api.php
includes/DefaultSettings.php
includes/OutputPage.php
includes/api/ApiQuerySiteinfo.php
includes/diff/DifferenceEngine.php
includes/page/Article.php
includes/preferences/DefaultPreferencesFactory.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/skins/Skin.php
includes/specials/SpecialApiSandbox.php
includes/specials/forms/UploadForm.php
opensearch_desc.php
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/api/ApiTestCaseUpload.php
tests/phpunit/includes/api/ApiUploadTestCase.php

index 941cf3f..d8eb2e2 100644 (file)
@@ -6,6 +6,7 @@ MediaWiki 1.32 is an alpha-quality branch and is not recommended for use in
 production.
 
 === Configuration changes in 1.32 ===
+* (T115414) The $wgEnableAPI and $wgEnableWriteAPI settings, deprecated in 1.31, have been removed.
 * …
 
 === New features in 1.32 ===
diff --git a/api.php b/api.php
index d9a69db..9c5ac95 100644 (file)
--- a/api.php
+++ b/api.php
@@ -2,13 +2,10 @@
 /**
  * This file is the entry point for all API queries.
  *
- * It begins by checking whether the API is enabled on this wiki; if not,
- * it informs the user that s/he should set $wgEnableAPI to true and exits.
- * Otherwise, it constructs a new ApiMain using the parameter passed to it
- * as an argument in the URL ('?action=') and with write-enabled set to the
- * value of $wgEnableWriteAPI as specified in LocalSettings.php.
- * It then invokes "execute()" on the ApiMain object instance, which
- * produces output in the format specified in the URL.
+ * It begins by constructing a new ApiMain using the parameter passed to it
+ * as an argument in the URL ('?action='). It then invokes "execute()" on the
+ * ApiMain object instance, which produces output in the format specified in
+ * the URL.
  *
  * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
@@ -55,14 +52,6 @@ if ( isset( $_SERVER['PATH_INFO'] ) && $_SERVER['PATH_INFO'] != '' ) {
        die( 1 );
 }
 
-// Verify that the API has not been disabled
-if ( !$wgEnableAPI ) {
-       header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 );
-       echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php'
-               . '<pre><b>$wgEnableAPI=true;</b></pre>';
-       die( 1 );
-}
-
 // Set a dummy $wgTitle, because $wgTitle == null breaks various things
 // In a perfect world this wouldn't be necessary
 $wgTitle = Title::makeTitle( NS_SPECIAL, 'Badtitle/dummy title for API calls set in api.php' );
@@ -76,7 +65,7 @@ try {
         * is some form of an ApiMain, possibly even one that produces an error message,
         * but we don't care here, as that is handled by the constructor.
         */
-       $processor = new ApiMain( RequestContext::getMain(), $wgEnableWriteAPI );
+       $processor = new ApiMain( RequestContext::getMain(), true );
 
        // Last chance hook before executing the API
        Hooks::run( 'ApiBeforeMain', [ &$processor ] );
index 6d7962c..8ddf310 100644 (file)
@@ -8044,25 +8044,6 @@ $wgExemptFromUserRobotsControl = null;
  * @{
  */
 
-/**
- * Enable the MediaWiki API for convenient access to
- * machine-readable data via api.php
- *
- * See https://www.mediawiki.org/wiki/API
- *
- * @deprecated since 1.31
- */
-$wgEnableAPI = true;
-
-/**
- * Allow the API to be used to perform write operations
- * (page edits, rollback, etc.) when an authorised user
- * accesses it
- *
- * @deprecated since 1.31
- */
-$wgEnableWriteAPI = true;
-
 /**
  *
  *     WARNING: SECURITY THREAT - debug use only
@@ -8217,7 +8198,7 @@ $wgAjaxExportList = [];
 $wgAjaxUploadDestCheck = true;
 
 /**
- * Enable previewing licences via AJAX. Also requires $wgEnableAPI to be true.
+ * Enable previewing licences via AJAX.
  */
 $wgAjaxLicensePreview = true;
 
index 99dd4a7..dd64413 100644 (file)
@@ -3337,24 +3337,22 @@ class OutputPage extends ContextSource {
                        'title' => $this->msg( 'opensearch-desc' )->inContentLanguage()->text(),
                ] );
 
-               if ( $config->get( 'EnableAPI' ) ) {
-                       # Real Simple Discovery link, provides auto-discovery information
-                       # for the MediaWiki API (and potentially additional custom API
-                       # support such as WordPress or Twitter-compatible APIs for a
-                       # blogging extension, etc)
-                       $tags['rsd'] = Html::element( 'link', [
-                               'rel' => 'EditURI',
-                               'type' => 'application/rsd+xml',
-                               // Output a protocol-relative URL here if $wgServer is protocol-relative.
-                               // Whether RSD accepts relative or protocol-relative URLs is completely
-                               // undocumented, though.
-                               'href' => wfExpandUrl( wfAppendQuery(
-                                       wfScript( 'api' ),
-                                       [ 'action' => 'rsd' ] ),
-                                       PROTO_RELATIVE
-                               ),
-                       ] );
-               }
+               # Real Simple Discovery link, provides auto-discovery information
+               # for the MediaWiki API (and potentially additional custom API
+               # support such as WordPress or Twitter-compatible APIs for a
+               # blogging extension, etc)
+               $tags['rsd'] = Html::element( 'link', [
+                       'rel' => 'EditURI',
+                       'type' => 'application/rsd+xml',
+                       // Output a protocol-relative URL here if $wgServer is protocol-relative.
+                       // Whether RSD accepts relative or protocol-relative URLs is completely
+                       // undocumented, though.
+                       'href' => wfExpandUrl( wfAppendQuery(
+                               wfScript( 'api' ),
+                               [ 'action' => 'rsd' ] ),
+                               PROTO_RELATIVE
+                       ),
+               ] );
 
                # Language variants
                if ( !$config->get( 'DisableLangConversion' ) ) {
index 3048273..3f2d510 100644 (file)
@@ -223,7 +223,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                if ( $data['readonly'] ) {
                        $data['readonlyreason'] = wfReadOnlyReason();
                }
-               $data['writeapi'] = (bool)$config->get( 'EnableWriteAPI' );
+               $data['writeapi'] = true; // Deprecated since MW 1.32
 
                $data['maxarticlesize'] = $config->get( 'MaxArticleSize' ) * 1024;
 
index 8f57c57..b1ca435 100644 (file)
@@ -524,7 +524,7 @@ class DifferenceEngine extends ContextSource {
         *  or false if no link is needed
         */
        protected function getMarkPatrolledLinkInfo() {
-               global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
+               global $wgUseRCPatrol;
 
                $user = $this->getUser();
 
@@ -564,9 +564,7 @@ class DifferenceEngine extends ContextSource {
                        // Build the link
                        if ( $rcid ) {
                                $this->getOutput()->preventClickjacking();
-                               if ( $wgEnableAPI && $wgEnableWriteAPI
-                                       && $user->isAllowed( 'writeapi' )
-                               ) {
+                               if ( $user->isAllowed( 'writeapi' ) ) {
                                        $this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
                                }
 
index 3cbeacf..7577972 100644 (file)
@@ -965,7 +965,7 @@ class Article implements Page {
         * @return bool
         */
        public function showPatrolFooter() {
-               global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
+               global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol;
 
                $outputPage = $this->getContext()->getOutput();
                $user = $this->getContext()->getUser();
@@ -1100,7 +1100,7 @@ class Article implements Page {
                }
 
                $outputPage->preventClickjacking();
-               if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
+               if ( $user->isAllowed( 'writeapi' ) ) {
                        $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
                }
 
index 6eceb84..3bc21f7 100644 (file)
@@ -1188,18 +1188,16 @@ class DefaultPreferencesFactory implements PreferencesFactory {
                        }
                }
 
-               if ( $this->config->get( 'EnableAPI' ) ) {
-                       $defaultPreferences['watchlisttoken'] = [
-                               'type' => 'api',
-                       ];
-                       $defaultPreferences['watchlisttoken-info'] = [
-                               'type' => 'info',
-                               'section' => 'watchlist/tokenwatchlist',
-                               'label-message' => 'prefs-watchlist-token',
-                               'default' => $user->getTokenFromOption( 'watchlisttoken' ),
-                               'help-message' => 'prefs-help-watchlist-token2',
-                       ];
-               }
+               $defaultPreferences['watchlisttoken'] = [
+                       'type' => 'api',
+               ];
+               $defaultPreferences['watchlisttoken-info'] = [
+                       'type' => 'info',
+                       'section' => 'watchlist/tokenwatchlist',
+                       'label-message' => 'prefs-watchlist-token',
+                       'default' => $user->getTokenFromOption( 'watchlisttoken' ),
+                       'help-message' => 'prefs-help-watchlist-token2',
+               ];
        }
 
        /**
index 681e8dc..c0dd188 100644 (file)
@@ -101,8 +101,8 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgContentLanguage' => $wgContLang->getCode(),
                        'wgTranslateNumerals' => $conf->get( 'TranslateNumerals' ),
                        'wgVersion' => $conf->get( 'Version' ),
-                       'wgEnableAPI' => $conf->get( 'EnableAPI' ),
-                       'wgEnableWriteAPI' => $conf->get( 'EnableWriteAPI' ),
+                       'wgEnableAPI' => true, // Deprecated since MW 1.32
+                       'wgEnableWriteAPI' => true, // Deprecated since MW 1.32
                        'wgMainPageTitle' => $mainPage->getPrefixedText(),
                        'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
                        'wgNamespaceIds' => $namespaceIds,
index e2de9ec..80a1f6e 100644 (file)
@@ -171,7 +171,7 @@ abstract class Skin extends ContextSource {
         * @return array Array of modules with helper keys for easy overriding
         */
        public function getDefaultModules() {
-               global $wgUseAjax, $wgEnableAPI, $wgEnableWriteAPI;
+               global $wgUseAjax;
 
                $out = $this->getOutput();
                $config = $this->getConfig();
@@ -217,8 +217,8 @@ abstract class Skin extends ContextSource {
                }
 
                // Add various resources if required
-               if ( $wgUseAjax && $wgEnableAPI ) {
-                       if ( $wgEnableWriteAPI && $user->isLoggedIn()
+               if ( $wgUseAjax ) {
+                       if ( $user->isLoggedIn()
                                && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
                                && $this->getRelevantTitle()->canExist()
                        ) {
index 2733e75..c000d54 100644 (file)
@@ -35,10 +35,6 @@ class SpecialApiSandbox extends SpecialPage {
                $out = $this->getOutput();
                $this->addHelpLink( 'Help:ApiSandbox' );
 
-               if ( !$this->getConfig()->get( 'EnableAPI' ) ) {
-                       $out->showErrorPage( 'error', 'apisandbox-api-disabled' );
-               }
-
                $out->addJsConfigVars( 'apihighlimits', $this->getUser()->isAllowed( 'apihighlimits' ) );
                $out->addModuleStyles( [
                        'mediawiki.special.apisandbox.styles',
index eacdace..a316374 100644 (file)
@@ -407,8 +407,7 @@ class UploadForm extends HTMLForm {
                $config = $this->getConfig();
 
                $useAjaxDestCheck = $config->get( 'UseAjax' ) && $config->get( 'AjaxUploadDestCheck' );
-               $useAjaxLicensePreview = $config->get( 'UseAjax' ) &&
-                       $config->get( 'AjaxLicensePreview' ) && $config->get( 'EnableAPI' );
+               $useAjaxLicensePreview = $config->get( 'UseAjax' ) && $config->get( 'AjaxLicensePreview' );
                $this->mMaxUploadSize['*'] = UploadBase::getMaxUploadSize();
 
                $scriptVars = [
index 92c182d..b9b2161 100644 (file)
@@ -85,7 +85,7 @@ $urls[] = [
        'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) ];
 
 foreach ( $wgOpenSearchTemplates as $type => $template ) {
-       if ( !$template && $wgEnableAPI ) {
+       if ( !$template ) {
                $template = ApiOpenSearch::getOpenSearchTemplate( $type );
        }
 
index 88c585f..81bbcd7 100644 (file)
@@ -673,7 +673,6 @@ class OutputPageTest extends MediaWikiTestCase {
                $context->setConfig( new HashConfig( $config + [
                        'AppleTouchIcon' => false,
                        'DisableLangConversion' => true,
-                       'EnableAPI' => false,
                        'EnableCanonicalServerLink' => false,
                        'Favicon' => false,
                        'Feed' => false,
index 3670fad..a4ff1f0 100644 (file)
@@ -4,5 +4,4 @@
  * For backward compatibility since 1.31
  */
 abstract class ApiTestCaseUpload extends ApiUploadTestCase {
-
 }
index 3c7efd5..cf56052 100644 (file)
@@ -12,7 +12,6 @@ abstract class ApiUploadTestCase extends ApiTestCase {
 
                $this->setMwGlobals( [
                        'wgEnableUploads' => true,
-                       'wgEnableAPI' => true,
                ] );
 
                $this->clearFakeUploads();