aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames D. Forrester <jforrester@wikimedia.org>2017-11-20 15:50:22 -0800
committerKrinkle <krinklemail@gmail.com>2018-04-18 00:30:34 +0000
commit225b462a50b545b1f100e0d51a6070b0766ce12a (patch)
tree039b6d0024cecaead80fdee45dd32abd77041b52
parent30ba8f52dc8827578ec7901207c9cbd00e44b76a (diff)
downloadmediawikicore-225b462a50b545b1f100e0d51a6070b0766ce12a.tar.gz
mediawikicore-225b462a50b545b1f100e0d51a6070b0766ce12a.zip
Drop deprecated EnableAPI and EnableWriteAPI settings
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
-rw-r--r--RELEASE-NOTES-1.321
-rw-r--r--api.php21
-rw-r--r--includes/DefaultSettings.php21
-rw-r--r--includes/OutputPage.php34
-rw-r--r--includes/api/ApiQuerySiteinfo.php2
-rw-r--r--includes/diff/DifferenceEngine.php6
-rw-r--r--includes/page/Article.php4
-rw-r--r--includes/preferences/DefaultPreferencesFactory.php22
-rw-r--r--includes/resourceloader/ResourceLoaderStartUpModule.php4
-rw-r--r--includes/skins/Skin.php6
-rw-r--r--includes/specials/SpecialApiSandbox.php4
-rw-r--r--includes/specials/forms/UploadForm.php3
-rw-r--r--opensearch_desc.php2
-rw-r--r--tests/phpunit/includes/OutputPageTest.php1
-rw-r--r--tests/phpunit/includes/api/ApiTestCaseUpload.php1
-rw-r--r--tests/phpunit/includes/api/ApiUploadTestCase.php1
16 files changed, 45 insertions, 88 deletions
diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32
index 941cf3f1f09e..d8eb2e281368 100644
--- a/RELEASE-NOTES-1.32
+++ b/RELEASE-NOTES-1.32
@@ -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 d9a69db37e62..9c5ac9571602 100644
--- 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 ] );
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 6d7962c2c1bd..8ddf3101ed7c 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -8045,25 +8045,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;
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 99dd4a7c0e62..dd64413fd457 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -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' ) ) {
diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php
index 30482732671b..3f2d510343cc 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -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;
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php
index 8f57c578eba4..b1ca4352693b 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -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' );
}
diff --git a/includes/page/Article.php b/includes/page/Article.php
index 3cbeacffa757..7577972b0053 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -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' );
}
diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php
index 6eceb84bcfe8..3bc21f726b20 100644
--- a/includes/preferences/DefaultPreferencesFactory.php
+++ b/includes/preferences/DefaultPreferencesFactory.php
@@ -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',
+ ];
}
/**
diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php
index 681e8dc0052a..c0dd188423d8 100644
--- a/includes/resourceloader/ResourceLoaderStartUpModule.php
+++ b/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -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,
diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php
index e2de9ec382fd..80a1f6eb632a 100644
--- a/includes/skins/Skin.php
+++ b/includes/skins/Skin.php
@@ -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()
) {
diff --git a/includes/specials/SpecialApiSandbox.php b/includes/specials/SpecialApiSandbox.php
index 2733e75716c1..c000d546d17e 100644
--- a/includes/specials/SpecialApiSandbox.php
+++ b/includes/specials/SpecialApiSandbox.php
@@ -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',
diff --git a/includes/specials/forms/UploadForm.php b/includes/specials/forms/UploadForm.php
index eacdace18a85..a316374f4bf4 100644
--- a/includes/specials/forms/UploadForm.php
+++ b/includes/specials/forms/UploadForm.php
@@ -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 = [
diff --git a/opensearch_desc.php b/opensearch_desc.php
index 92c182d8a70e..b9b21611d027 100644
--- a/opensearch_desc.php
+++ b/opensearch_desc.php
@@ -85,7 +85,7 @@ $urls[] = [
'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) ];
foreach ( $wgOpenSearchTemplates as $type => $template ) {
- if ( !$template && $wgEnableAPI ) {
+ if ( !$template ) {
$template = ApiOpenSearch::getOpenSearchTemplate( $type );
}
diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index 88c585fe5cfc..81bbcd7ea419 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -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,
diff --git a/tests/phpunit/includes/api/ApiTestCaseUpload.php b/tests/phpunit/includes/api/ApiTestCaseUpload.php
index 3670fad846cd..a4ff1f0e90cb 100644
--- a/tests/phpunit/includes/api/ApiTestCaseUpload.php
+++ b/tests/phpunit/includes/api/ApiTestCaseUpload.php
@@ -4,5 +4,4 @@
* For backward compatibility since 1.31
*/
abstract class ApiTestCaseUpload extends ApiUploadTestCase {
-
}
diff --git a/tests/phpunit/includes/api/ApiUploadTestCase.php b/tests/phpunit/includes/api/ApiUploadTestCase.php
index 3c7efd57682b..cf56052a55c8 100644
--- a/tests/phpunit/includes/api/ApiUploadTestCase.php
+++ b/tests/phpunit/includes/api/ApiUploadTestCase.php
@@ -12,7 +12,6 @@ abstract class ApiUploadTestCase extends ApiTestCase {
$this->setMwGlobals( [
'wgEnableUploads' => true,
- 'wgEnableAPI' => true,
] );
$this->clearFakeUploads();