API: Add iwprop=url, deprecate iwurl for prop=iwlinks
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 20 Aug 2014 13:40:01 +0000 (09:40 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 20 Aug 2014 13:40:01 +0000 (09:40 -0400)
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
includes/api/ApiQueryIWLinks.php

index b354cc0..b89f294 100644 (file)
@@ -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 ===
 
index bb388cd..a185ee2 100644 (file)
@@ -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',