From c0cd377c0f67f5686d6dac2e16da0b144260731d Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Thu, 11 Feb 2010 05:35:21 +0000 Subject: [PATCH] follow-up r61355 Actually test UploadChunks code against Firefogg. Uploads work, but feedback on the Firefogg side seems not too. Also, Firefogg makes a complete upload, but then attempts more uploads. --- includes/api/ApiUpload.php | 10 +++++++++- maintenance/tests/ApiSetup.php | 4 ---- maintenance/tests/ApiTest.php | 4 ++++ maintenance/tests/UploadFromChunksTest.php | 5 ++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index de50147b4e..e99e5d9686 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -138,7 +138,15 @@ class ApiUpload extends ApiBase { // Cleanup any temporary mess $this->mUpload->cleanupTempFile(); - $this->getResult()->addValue( null, $this->getModuleName(), $result ); + + if( $this->mParams['enablechunks'] ) { + foreach ($result as $key => $value) { + if($value === null) $value = ""; + $this->getResult()->addValue( null, $key, $value ); + } + } else { + $this->getResult()->addValue( null, $this->getModuleName(), $result ); + } } protected function performUpload() { diff --git a/maintenance/tests/ApiSetup.php b/maintenance/tests/ApiSetup.php index d5fbac72ba..549d8aefb7 100644 --- a/maintenance/tests/ApiSetup.php +++ b/maintenance/tests/ApiSetup.php @@ -10,10 +10,6 @@ abstract class ApiSetup extends PHPUnit_Framework_TestCase { global $wgServerName, $wgServer, $wgContLang, $wgAuth, $wgScriptPath, $wgScriptExtension, $wgMemc, $wgRequest; - if($wgServerName == "localhost" || $wgServer == "http://localhost") { - $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '. - 'be set in LocalSettings.php'); - } self::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension; $wgMemc = new FakeMemCachedClient; diff --git a/maintenance/tests/ApiTest.php b/maintenance/tests/ApiTest.php index 04f9c5b9b4..b177ebf200 100644 --- a/maintenance/tests/ApiTest.php +++ b/maintenance/tests/ApiTest.php @@ -5,6 +5,10 @@ require_once( "ApiSetup.php" ); class ApiTest extends ApiSetup { function setup() { + if($wgServerName == "localhost" || $wgServer == "http://localhost") { + $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '. + 'be set in LocalSettings.php'); + } parent::setup(); } diff --git a/maintenance/tests/UploadFromChunksTest.php b/maintenance/tests/UploadFromChunksTest.php index ebad77404b..b0decd69cc 100644 --- a/maintenance/tests/UploadFromChunksTest.php +++ b/maintenance/tests/UploadFromChunksTest.php @@ -115,8 +115,7 @@ class UploadFromChunksTest extends ApiSetup { 'token' => $token, )); - $this->assertArrayHasKey("upload", $data); - $this->assertArrayHasKey("uploadUrl", $data['upload']); + $this->assertArrayHasKey("uploadUrl", $data); return array('data' => $data, 'session' => $_SESSION, 'token' => $token); } @@ -131,7 +130,7 @@ class UploadFromChunksTest extends ApiSetup { $wgUser = User::newFromName(self::$userName); $token = $wgUser->editToken(); - $url = $data['upload']['uploadUrl']; + $url = $data['uploadUrl']; $params = wfCgiToArray(substr($url, strpos($url, "?"))); for($i=0;$i<10;$i++) { -- 2.20.1