r65009 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65008‎ | r65009 | r65010 >
Date:04:44, 14 April 2010
Author:mah
Status:deferred
Tags:
Comment:
Switch to watchlist param
Modified paths:
  • /trunk/extensions/FirefoggChunkedUpload/ApiFirefoggChunkedUpload.php (modified) (history)
  • /trunk/extensions/FirefoggChunkedUpload/FirefoggChunkedUploadHandler.php (modified) (history)
  • /trunk/extensions/FirefoggChunkedUpload/tests/UploadFromChunksTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FirefoggChunkedUpload/ApiFirefoggChunkedUpload.php
@@ -6,10 +6,6 @@
77 */
88
99 class ApiFirefoggChunkedUpload extends ApiUpload {
10 - /* public function __construct( $main, $action ) { */
11 - /* parent::__construct( $main, $action ); */
12 - /* } */
13 -
1410 public function execute() {
1511 global $wgUser;
1612
@@ -51,13 +47,13 @@
5248
5349 public function getUpload() { return $this->mUpload; }
5450
55 - public function performUploadInit($comment, $pageText, $watch, $user) {
 51+ public function performUploadInit($comment, $pageText, $watchlist, $user) {
5652 $check = $this->mUpload->validateNameAndOverwrite();
5753 if( $check !== true ) {
5854 $this->getVerificationError( $check );
5955 }
6056
61 - $session = $this->mUpload->setupChunkSession( $comment, $pageText, $watch );
 57+ $session = $this->mUpload->setupChunkSession( $comment, $pageText, $watchlist );
6258 return array('uploadUrl' =>
6359 wfExpandUrl( wfScript( 'api' ) ) . "?" .
6460 wfArrayToCGI( array(
@@ -80,7 +76,7 @@
8177
8278 public function performUploadDone($user) {
8379 $this->mUpload->finalizeFile();
84 - $status = parent::performUpload( $this->comment, $this->pageText, $this->watch, $user );
 80+ $status = parent::performUpload( $this->comment, $this->pageText, $this->watchlist, $user );
8581
8682 if ( $status['result'] !== 'Success' ) {
8783 return $status;
@@ -97,12 +93,12 @@
9894 */
9995 public function performUpload( ) {
10096 wfDebug( "\n\n\performUpload(chunked): comment: " . $this->comment .
101 - ' pageText: ' . $this->pageText . ' watch: ' . $this->watch );
 97+ ' pageText: ' . $this->pageText . ' watch: ' . $this->watchlist );
10298 $ret = "unknown error";
10399
104100 global $wgUser;
105101 if ( $this->mUpload->getChunkMode() == FirefoggChunkedUploadHandler::INIT ) {
106 - $ret = $this->performUploadInit($this->comment, $this->pageText, $this->watch, $wgUser);
 102+ $ret = $this->performUploadInit($this->comment, $this->pageText, $this->watchlist, $wgUser);
107103 } else if ( $this->mUpload->getChunkMode() == FirefoggChunkedUploadHandler::CHUNK ) {
108104 $ret = $this->performUploadChunk();
109105 } else if ( $this->mUpload->getChunkMode() == FirefoggChunkedUploadHandler::DONE ) {
@@ -127,7 +123,7 @@
128124 if( $params['chunksession'] === null ) {
129125 $required[] = 'filename';
130126 $required[] = 'comment';
131 - $required[] = 'watch';
 127+ $required[] = 'watchlist';
132128 $required[] = 'ignorewarnings';
133129 }
134130
@@ -143,11 +139,19 @@
144140 'filename' => null,
145141 'token' => null,
146142 'comment' => null,
147 - 'watch' => false,
148143 'ignorewarnings' => false,
149144 'chunksession' => null,
150145 'chunk' => null,
151146 'done' => false,
 147+ 'watchlist' => array(
 148+ ApiBase::PARAM_DFLT => 'preferences',
 149+ ApiBase::PARAM_TYPE => array(
 150+ 'watch',
 151+ 'unwatch',
 152+ 'preferences',
 153+ 'nochange'
 154+ ),
 155+ ),
152156 );
153157 }
154158
@@ -156,7 +160,7 @@
157161 'filename' => 'Target filename',
158162 'token' => 'Edit token. You can get one of these through prop=info',
159163 'comment' => 'Upload comment',
160 - 'watch' => 'Watch the page',
 164+ 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
161165 'ignorewarnings' => 'Ignore any warnings',
162166 'chunksession' => 'The session key, established on the first contact during the chunked upload',
163167 'chunk' => 'The data in this chunk of a chunked upload',
Index: trunk/extensions/FirefoggChunkedUpload/tests/UploadFromChunksTest.php
@@ -117,7 +117,7 @@
118118 $this->doApiRequest( array(
119119 'action' => 'firefoggupload',
120120 'comment' => 'test',
121 - 'watch' => true,
 121+ 'watchlist' => 'watch',
122122 'filename' => 'tmp.txt',
123123 'token' => $token ), $data );
124124 } catch ( UsageException $e ) {
@@ -141,7 +141,7 @@
142142 $data = $this->doApiRequest( array(
143143 'action' => 'firefoggupload',
144144 'comment' => 'test',
145 - 'watch' => true,
 145+ 'watchlist' => 'watch',
146146 'filename' => 'TestPic.png',
147147 'token' => $token ), $data );
148148
@@ -216,7 +216,7 @@
217217 $data = $this->doApiRequest( array(
218218 'action' => 'firefoggupload',
219219 'comment' => 'test',
220 - 'watch' => true,
 220+ 'watchlist' => 'watch',
221221 'filename' => 'tmp.png',
222222 'token' => $token ), $data );
223223 return $data;
@@ -284,7 +284,7 @@
285285 $data = $this->doApiRequest( array(
286286 'action' => 'firefoggupload',
287287 'comment' => 'test',
288 - 'watch' => true,
 288+ 'watchlist' => 'watch',
289289 'filename' => 'twar.png',
290290 'token' => $token ), $data );
291291
Index: trunk/extensions/FirefoggChunkedUpload/FirefoggChunkedUploadHandler.php
@@ -15,7 +15,7 @@
1616 protected $comment;
1717 protected $repoPath;
1818 protected $pageText;
19 - protected $watch;
 19+ protected $watchlist;
2020
2121 public $status;
2222
@@ -27,11 +27,11 @@
2828 * Set session information for chunked uploads and allocate a unique key.
2929 * @param $comment string
3030 * @param $pageText string
31 - * @param $watch bodolean
 31+ * @param $watchlist bodolean
3232 *
3333 * @returns string the session key for this chunked upload
3434 */
35 - public function setupChunkSession( $comment, $pageText, $watch ) {
 35+ public function setupChunkSession( $comment, $pageText, $watchlist ) {
3636 if ( !isset( $this->sessionKey ) ) {
3737 $this->sessionKey = $this->getSessionKey();
3838 }
@@ -47,8 +47,8 @@
4848 if ( isset( $pageText ) ) {
4949 $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['pageText'] = $pageText;
5050 }
51 - if ( isset( $watch ) ) {
52 - $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['watch'] = $watch;
 51+ if ( isset( $watchlist ) ) {
 52+ $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['watchlist'] = $watchlist;
5353 }
5454 $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['version'] = self::SESSION_VERSION;
5555
@@ -110,7 +110,7 @@
111111 if ( isset( $sessionData[$this->sessionKey]['version'] )
112112 && $sessionData[$this->sessionKey]['version'] == self::SESSION_VERSION )
113113 {
114 - foreach ( array( 'comment', 'pageText', 'watch', 'mFilteredName', 'repoPath', 'mFileSize', 'mDesiredDestName' )
 114+ foreach ( array( 'comment', 'pageText', 'watchlist', 'mFilteredName', 'repoPath', 'mFileSize', 'mDesiredDestName' )
115115 as $key ) {
116116 if ( isset( $sessionData[$this->sessionKey][$key] ) ) {
117117 $this->$key = $sessionData[$this->sessionKey][$key];

Status & tagging log