From 06debf1eb6affacbcdcdf4db5cfafe5e87c734a9 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Tue, 11 Feb 2014 19:29:10 +0100 Subject: [PATCH] Deprecate llurl= in favour of llprop=url for action=query&prop=langlinks New props will be added with I54c66c8935b0dbbf3bf8e292236119597f1cbe41 Change-Id: I1340b18b51bccdfaaddec6a16df320d5f6e5acfa --- RELEASE-NOTES-1.23 | 1 + includes/api/ApiQueryLangLinks.php | 37 +++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 4fc198a415..ffda350fcd 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -164,6 +164,7 @@ production. possible page restriction (protection) levels and types. * Added prop 'limitreportdata' and 'limitreporthtml' to action=parse. * (bug 58627) Provide language names on action=parse&prop=langlinks. +* Deprecated llurl= in favour of llprop=url for action=query&prop=langlinks. === Languages updated in 1.23 === diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index a20b8553d7..506bd2e06d 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -41,11 +41,18 @@ class ApiQueryLangLinks extends ApiQueryBase { } $params = $this->extractRequestParams(); + $prop = array_flip( (array)$params['prop'] ); if ( isset( $params['title'] ) && !isset( $params['lang'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'lang' ) ); } + // Handle deprecated param + $this->requireMaxOneParameter( $params, 'url', 'prop' ); + if ( $params['url'] ) { + $prop = array( 'url' => 1 ); + } + $this->addFields( array( 'll_from', 'll_lang', @@ -104,7 +111,7 @@ class ApiQueryLangLinks extends ApiQueryBase { break; } $entry = array( 'lang' => $row->ll_lang ); - if ( $params['url'] ) { + if ( isset( $prop['url'] ) ) { $title = Title::newFromText( "{$row->ll_lang}:{$row->ll_title}" ); if ( $title ) { $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); @@ -133,7 +140,16 @@ class ApiQueryLangLinks extends ApiQueryBase { ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 ), 'continue' => null, - 'url' => false, + 'url' => array( + ApiBase::PARAM_DFLT => false, + ApiBase::PARAM_DEPRECATED => true, + ), + 'prop' => array( + ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_TYPE => array( + 'url', + ) + ), 'lang' => null, 'title' => null, 'dir' => array( @@ -150,7 +166,11 @@ class ApiQueryLangLinks extends ApiQueryBase { return array( 'limit' => 'How many langlinks to return', 'continue' => 'When more results are available, use this to continue', - 'url' => 'Whether to get the full URL', + 'url' => "Whether to get the full URL (Cannot be used with {$this->getModulePrefix()}prop)", + 'prop' => array( + 'Which additional properties to get for each interlanguage link', + ' url - Adds the full URL', + ), 'lang' => 'Language code', 'title' => "Link to search for. Must be used with {$this->getModulePrefix()}lang", 'dir' => 'The direction in which to list', @@ -175,9 +195,14 @@ class ApiQueryLangLinks extends ApiQueryBase { } public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'missingparam', 'lang' ), - ) ); + return array_merge( parent::getPossibleErrors(), + $this->getRequireMaxOneParameterErrorMessages( + array( 'url', 'prop' ) + ), + array( + array( 'missingparam', 'lang' ), + ) + ); } public function getExamples() { -- 2.20.1