From f757b2bc7e73a46d96eb4aac5bd703232bd463e4 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 25 Mar 2010 21:17:51 +0000 Subject: [PATCH] Watch/unwatch to ApiUpload Prevent mutually exclusive values --- includes/api/ApiUpload.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 7f0d857c1c..4e8f1b78e1 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -47,6 +47,10 @@ class ApiUpload extends ApiBase { $this->mParams = $this->extractRequestParams(); $request = $this->getMain()->getRequest(); + + if ( isset( $this->mParams['watch'] ) && isset( $this->mParams['unwatch'] ) ) { + $this->dieUsageMsg( array( 'show' ) ); + } // Add the uploaded file to the params array $this->mParams['file'] = $request->getFileName( 'file' ); @@ -222,6 +226,10 @@ class ApiUpload extends ApiBase { // No errors, no warnings: do the upload $status = $this->mUpload->performUpload( $this->mParams['comment'], $this->mParams['text'], $this->mParams['watch'], $wgUser ); + + if ( $this->mParams['unwatch'] ) { + $wgUser->removeWatch( $file->getTitle() ); + } if ( !$status->isGood() ) { $error = $status->getErrorsArray(); @@ -255,6 +263,7 @@ class ApiUpload extends ApiBase { 'text' => null, 'token' => null, 'watch' => false, + 'unwatch' => false, 'ignorewarnings' => false, 'file' => null, 'url' => null, @@ -270,6 +279,7 @@ class ApiUpload extends ApiBase { 'comment' => 'Upload comment. Also used as the initial page text for new files if "text" is not specified', 'text' => 'Initial page text for new files', 'watch' => 'Watch the page', + 'watch' => 'Unwatch the page', 'ignorewarnings' => 'Ignore any warnings', 'file' => 'File contents', 'url' => 'Url to fetch the file from', -- 2.20.1