production.
=== Configuration changes in 1.32 ===
+* (T115414) The $wgEnableAPI and $wgEnableWriteAPI settings, deprecated in 1.31, have been removed.
* …
=== New features in 1.32 ===
/**
* 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
*
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' );
* 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 ] );
* @{
*/
-/**
- * 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
$wgAjaxUploadDestCheck = true;
/**
- * Enable previewing licences via AJAX. Also requires $wgEnableAPI to be true.
+ * Enable previewing licences via AJAX.
*/
$wgAjaxLicensePreview = true;
'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' ) ) {
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;
* or false if no link is needed
*/
protected function getMarkPatrolledLinkInfo() {
- global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
+ global $wgUseRCPatrol;
$user = $this->getUser();
// 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' );
}
* @return bool
*/
public function showPatrolFooter() {
- global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
+ global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol;
$outputPage = $this->getContext()->getOutput();
$user = $this->getContext()->getUser();
}
$outputPage->preventClickjacking();
- if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
+ if ( $user->isAllowed( 'writeapi' ) ) {
$outputPage->addModules( 'mediawiki.page.patrol.ajax' );
}
}
}
- 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',
+ ];
}
/**
'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,
* @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();
}
// 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()
) {
$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',
$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 = [
'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) ];
foreach ( $wgOpenSearchTemplates as $type => $template ) {
- if ( !$template && $wgEnableAPI ) {
+ if ( !$template ) {
$template = ApiOpenSearch::getOpenSearchTemplate( $type );
}
$context->setConfig( new HashConfig( $config + [
'AppleTouchIcon' => false,
'DisableLangConversion' => true,
- 'EnableAPI' => false,
'EnableCanonicalServerLink' => false,
'Favicon' => false,
'Feed' => false,
* For backward compatibility since 1.31
*/
abstract class ApiTestCaseUpload extends ApiUploadTestCase {
-
}
$this->setMwGlobals( [
'wgEnableUploads' => true,
- 'wgEnableAPI' => true,
] );
$this->clearFakeUploads();