r65165 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65164‎ | r65165 | r65166 >
Date:16:49, 17 April 2010
Author:mah
Status:ok
Tags:
Comment:
re: r65152
* Make Job::insert() return true on success
* Change from Status object to array for API result on URL upload.
Modified paths:
  • /trunk/phase3/includes/JobQueue.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUpload.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadFromUrl.php (modified) (history)
  • /trunk/phase3/maintenance/tests/UploadFromUrlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/UploadFromUrlTest.php
@@ -143,9 +143,7 @@
144144 'token' => $token,
145145 ), $data );
146146
147 - $this->assertThat( $data[0]['upload'], $this->isInstanceOf( 'Status' ),
148 - "Got Status Object" );
149 - $this->assertTrue( $data[0]['upload']->isOk(), 'Job added');
 147+ $this->assertTrue( $data[0]['upload']['queued'], 'Job added');
150148
151149 $job = Job::pop();
152150 $this->assertThat( $job, $this->isInstanceOf( 'UploadFromUrlJob' ),
Index: trunk/phase3/includes/upload/UploadFromUrl.php
@@ -24,6 +24,7 @@
2525
2626 /**
2727 * Checks if the upload from URL feature is enabled
 28+ * @return bool
2829 */
2930 public static function isEnabled() {
3031 global $wgAllowCopyUploads;
@@ -32,6 +33,7 @@
3334
3435 /**
3536 * Entry point for API upload
 37+ * @return bool true on success
3638 */
3739 public function initialize( $name, $url, $comment, $watchlist ) {
3840 global $wgUser;
@@ -66,7 +68,7 @@
6769
6870
6971 $job = new UploadFromUrlJob( $title, $params );
70 - $job->insert();
 72+ return $job->insert();
7173 }
7274
7375 /**
Index: trunk/phase3/includes/JobQueue.php
@@ -76,7 +76,8 @@
7777 $namespace = $row->job_namespace;
7878 $dbkey = $row->job_title;
7979 $title = Title::makeTitleSafe( $namespace, $dbkey );
80 - $job = Job::factory( $row->job_cmd, $title, Job::extractBlob( $row->job_params ), $row->job_id );
 80+ $job = Job::factory( $row->job_cmd, $title, Job::extractBlob( $row->job_params ),
 81+ $row->job_id );
8182
8283 $dbw->delete( 'job', $job->insertFields(), __METHOD__ );
8384 $dbw->commit();
@@ -260,6 +261,7 @@
261262
262263 /**
263264 * Insert a single job into the queue.
 265+ * @return bool true on success
264266 */
265267 function insert() {
266268 $fields = $this->insertFields();
@@ -272,7 +274,7 @@
273275 return;
274276 }
275277 }
276 - $dbw->insert( 'job', $fields, __METHOD__ );
 278+ return $dbw->insert( 'job', $fields, __METHOD__ );
277279 }
278280
279281 protected function insertFields() {
Index: trunk/phase3/includes/api/ApiUpload.php
@@ -92,10 +92,10 @@
9393 }
9494
9595 $this->mUpload = new UploadFromUrl;
96 - $this->mUpload->initialize( $this->mParams['filename'], $this->mParams['url'],
 96+ $result = $this->mUpload->initialize( $this->mParams['filename'], $this->mParams['url'],
9797 $this->mParams['comment'] );
9898
99 - $this->getResult()->addValue( null, $this->getModuleName(), Status::newGood() );
 99+ $this->getResult()->addValue( null, $this->getModuleName(), array( 'queued' => $result ) );
100100 return;
101101 }
102102 } else {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65152* New UploadFromUrlJob class to handle Upload-by-Copy...mah02:43, 17 April 2010

Status & tagging log