Eranroz has uploaded a new change for review. https://gerrit.wikimedia.org/r/53964
Change subject: Support PageSet in ApiWatch ...................................................................... Support PageSet in ApiWatch Add support for PageSet capabilities in ApiWatch. The module now supports batch operation on titles, pageids etc. The old title (single page) parameter is still used to keep backward compatibility. Splitted from 17216 Change-Id: I820dcb64d469616b10741df013911197cc5bde29 --- M RELEASE-NOTES-1.21 M includes/api/ApiWatch.php 2 files changed, 45 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/64/53964/1 diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index e7e718d..be8e6df 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -203,6 +203,7 @@ * (bug 44719) Removed mention of non-existing maintenance/migrateCurStubs.php script in includes/DefaultSettings.php * (bug 45143) jquery.badge: Treat non-Latin variants of zero as zero as well. +* (bug 46151) mwdocgen.php should not ignore exit code of doxygen command. === API changes in 1.21 === * prop=revisions can now report the contentmodel and contentformat. @@ -270,6 +271,8 @@ * (bug 33304) list=allpages will now find really old indefinite protections. * (bug 45937) meta=allmessages will report a syntactically invalid lang as a proper error instead of as an uncaught exception. +* (bug 32151) ApiWatch now have pageset capabilities (titles/pageids/generators). + Title parameter is now deprecated. === API internal changes in 1.21 === * For debugging only, a new global $wgDebugAPI removes many API restrictions when true. diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 3e51299..5838c78 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -30,20 +30,36 @@ * @ingroup API */ class ApiWatch extends ApiBase { + private $mPageSet = null; public function execute() { $user = $this->getUser(); if ( !$user->isLoggedIn() ) { $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); } - $params = $this->extractRequestParams(); - $title = Title::newFromText( $params['title'] ); - - if ( !$title || $title->isExternal() || !$title->canExist() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); + // by default we use pageset to extract the page to work on. + // title is still supported for backward compatability + if ( !isset( $params['title'] ) ) { + $pageSet = $this->getPageSet(); + $pageSet->execute(); + $res = array(); + foreach ( $pageSet->getTitles() as $title ) { + $r = $this->watchTitle( $title, $user, $params ); + $res[] = $r; + } + $this->getResult()->setIndexedTagName( $res, 'w' ); + } else { + $title = Title::newFromText( $params['title'] ); + if ( !$title || $title->isExternal() || !$title->canExist() ) { + $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); + } + $res = $this->watchTitle( $title, $user, $params ); } + $this->getResult()->addValue( null, $this->getModuleName(), $res ); + } + private function watchTitle( $title, $user, $params ) { $res = array( 'title' => $title->getPrefixedText() ); // Currently unnecessary, code to act as a safeguard against any change in current behavior of uselang @@ -71,8 +87,20 @@ if ( !$success ) { $this->dieUsageMsg( 'hookaborted' ); } - $this->getResult()->addValue( null, $this->getModuleName(), $res ); + return $res; } + + + /** + * Get a cached instance of an ApiPageSet object + * @return ApiPageSet + */ + private function getPageSet() { + if ( $this->mPageSet === null ) { + $this->mPageSet = new ApiPageSet( $this ); + } + return $this->mPageSet; + } public function mustBePosted() { return true; @@ -91,10 +119,11 @@ } public function getAllowedParams() { - return array( + $psModule = $this->getPageSet(); + return $psModule->getAllowedParams() + array( 'title' => array( ApiBase::PARAM_TYPE => 'string', - ApiBase::PARAM_REQUIRED => true + ApiBase::PARAM_DEPRECATED => true ), 'unwatch' => false, 'uselang' => null, @@ -106,8 +135,9 @@ } public function getParamDescription() { - return array( - 'title' => 'The page to (un)watch', + $psModule = $this->getPageSet(); + return $psModule->getParamDescription() + array( + 'title' => 'The page to (un)watch. use titles instead', 'unwatch' => 'If set the page will be unwatched rather than watched', 'uselang' => 'Language to show the message in', 'token' => 'A token previously acquired via prop=info', @@ -139,8 +169,8 @@ public function getExamples() { return array( - 'api.php?action=watch&title=Main_Page' => 'Watch the page "Main Page"', - 'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"', + 'api.php?action=watch&titles=Main_Page' => 'Watch the page "Main Page"', + 'api.php?action=watch&titles=Main_Page&unwatch=' => 'Unwatch the page "Main Page"', ); } -- To view, visit https://gerrit.wikimedia.org/r/53964 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I820dcb64d469616b10741df013911197cc5bde29 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Eranroz <eranro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits