From bac75af45d80422d31810e86fe49a9be6c59b3c7 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 20 Aug 2014 09:40:01 -0400 Subject: [PATCH] API: Add iwprop=url, deprecate iwurl for prop=iwlinks Someone objected to the possibility of removing the deprecated llurl because prop=iwlinks still had an iwurl parameter, and they wanted parallelism. So let's deprecate iwurl too. Change-Id: I675c36868d6ce531a9de632203ca7b9742d63be1 --- RELEASE-NOTES-1.24 | 2 ++ includes/api/ApiQueryIWLinks.php | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index b354cc0d6f..b89f294f6b 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -235,6 +235,8 @@ production. * action=paraminfo now indicates when a parameter is specifying a submodule. Internally, a new param type 'submodule' is available to indicate this which automatically queries the list of submodule names from the ApiModuleManager. +* The iwurl parameter to prop=iwlinks is deprecated in favor of iwprop=url, for + parallelism with prop=langlinks. === Languages updated in 1.24 === diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index bb388cd1a3..a185ee24e6 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -42,11 +42,19 @@ class ApiQueryIWLinks extends ApiQueryBase { } $params = $this->extractRequestParams(); + $prop = array_flip( (array)$params['prop'] ); if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'prefix' ) ); } + // Handle deprecated param + $this->requireMaxOneParameter( $params, 'url', 'prop' ); + if ( $params['url'] ) { + $this->logFeatureUsage( 'prop=iwlinks&iwurl' ); + $prop = array( 'url' => 1 ); + } + $this->addFields( array( 'iwl_from', 'iwl_prefix', @@ -114,7 +122,7 @@ class ApiQueryIWLinks extends ApiQueryBase { } $entry = array( 'prefix' => $row->iwl_prefix ); - if ( $params['url'] ) { + if ( isset( $prop['url'] ) ) { $title = Title::newFromText( "{$row->iwl_prefix}:{$row->iwl_title}" ); if ( $title ) { $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); @@ -139,7 +147,16 @@ class ApiQueryIWLinks extends ApiQueryBase { public function getAllowedParams() { return array( - 'url' => false, + 'url' => array( + ApiBase::PARAM_DFLT => false, + ApiBase::PARAM_DEPRECATED => true, + ), + 'prop' => array( + ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_TYPE => array( + 'url', + ) + ), 'limit' => array( ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', @@ -162,7 +179,11 @@ class ApiQueryIWLinks extends ApiQueryBase { public function getParamDescription() { return array( - 'url' => 'Whether to get the full URL', + 'prop' => array( + 'Which additional properties to get for each interlanguage link', + ' url - Adds the full URL', + ), + 'url' => "Whether to get the full URL (Cannot be used with {$this->getModulePrefix()}prop)", 'limit' => 'How many interwiki links to return', 'continue' => 'When more results are available, use this to continue', 'prefix' => 'Prefix for the interwiki', -- 2.20.1