Go to the documentation of this file.
15 'wgEnableUploads' =>
true,
16 'wgAllowCopyUploads' =>
true,
17 'wgAllowAsyncCopyUploads' =>
true,
21 if (
wfLocalFile(
'UploadFromUrlTest.png' )->exists() ) {
27 $sessionId = session_id();
28 session_write_close();
31 $module =
new ApiMain( $req,
true );
36 return array( $module->getResultData(), $req );
47 $this->assertFalse(
$job );
54 $token = $this->
user->getEditToken();
63 $this->assertEquals(
"The token parameter must be set",
$e->getMessage() );
65 $this->assertTrue( $exception,
"Got exception" );
75 $this->assertEquals(
"One of the parameters sessionkey, file, url, statuskey is required",
78 $this->assertTrue( $exception,
"Got exception" );
84 'url' =>
'http://www.example.com/test.png',
89 $this->assertEquals(
"The filename parameter must be set",
$e->getMessage() );
91 $this->assertTrue( $exception,
"Got exception" );
93 $this->
user->removeGroup(
'sysop' );
98 'url' =>
'http://www.example.com/test.png',
99 'filename' =>
'UploadFromUrlTest.png',
104 $this->assertEquals(
"Permission denied",
$e->getMessage() );
106 $this->assertTrue( $exception,
"Got exception" );
108 $this->
user->addGroup(
'sysop' );
110 'action' =>
'upload',
111 'url' =>
'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
112 'asyncdownload' => 1,
113 'filename' =>
'UploadFromUrlTest.png',
117 $this->assertEquals( $data[0][
'upload'][
'result'],
'Queued',
'Queued upload' );
120 $this->assertThat(
$job, $this->isInstanceOf(
'UploadFromUrlJob' ),
'Queued upload inserted' );
127 $token = $this->
user->getEditToken();
129 $this->
user->addGroup(
'users' );
132 $this->assertEquals( $data[0][
'upload'][
'result'],
'Success' );
133 $this->assertEquals( $data[0][
'upload'][
'filename'],
'UploadFromUrlTest.png' );
134 $this->assertTrue(
wfLocalFile( $data[0][
'upload'][
'filename'] )->exists() );
145 $token = $this->
user->getEditToken();
147 $this->
user->addGroup(
'users' );
151 $this->assertEquals( $data[0][
'upload'][
'result'],
'Warning' );
152 $this->assertTrue( isset( $data[0][
'upload'][
'sessionkey'] ) );
155 'action' =>
'upload',
156 'sessionkey' => $data[0][
'upload'][
'sessionkey'],
157 'filename' =>
'UploadFromUrlTest.png',
158 'ignorewarnings' => 1,
161 $this->assertEquals( $data[0][
'upload'][
'result'],
'Success' );
162 $this->assertEquals( $data[0][
'upload'][
'filename'],
'UploadFromUrlTest.png' );
163 $this->assertTrue(
wfLocalFile( $data[0][
'upload'][
'filename'] )->exists() );
174 $token = $this->
user->getEditToken();
177 $this->assertFalse(
$job,
'Starting with an empty jobqueue' );
179 $this->
user->addGroup(
'users' );
181 'action' =>
'upload',
182 'filename' =>
'UploadFromUrlTest.png',
183 'url' =>
'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
184 'ignorewarnings' =>
true,
189 $this->assertFalse(
$job );
191 $this->assertEquals(
'Success', $data[0][
'upload'][
'result'] );
198 $token = $this->
user->user->getEditToken();
200 $talk = $this->
user->user->getTalkPage();
201 if ( $talk->exists() ) {
203 $page->doDeleteArticle(
'' );
209 'action' =>
'upload',
210 'filename' =>
'UploadFromUrlTest.png',
211 'url' =>
'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
212 'asyncdownload' => 1,
215 'ignorewarnings' => 1,
219 $this->assertEquals(
'UploadFromUrlJob', get_class(
$job ) );
222 $this->assertTrue(
wfLocalFile(
'UploadFromUrlTest.png' )->exists() );
230 'action' =>
'upload',
231 'filename' =>
'UploadFromUrlTest.png',
232 'url' =>
'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
233 'asyncdownload' => 1,
239 $this->assertEquals(
'Using leavemessage without ignorewarnings is not supported',
$e->getMessage() );
241 $this->assertTrue( $exception );
244 $this->assertFalse(
$job );
267 private function doAsyncUpload( $token, $ignoreWarnings =
false, $leaveMessage =
false ) {
269 'action' =>
'upload',
270 'filename' =>
'UploadFromUrlTest.png',
271 'url' =>
'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
272 'asyncdownload' => 1,
275 if ( $ignoreWarnings ) {
278 if ( $leaveMessage ) {
283 $this->assertEquals( $data[0][
'upload'][
'result'],
'Queued' );
284 $this->assertTrue( isset( $data[0][
'upload'][
'statuskey'] ) );
285 $statusKey = $data[0][
'upload'][
'statuskey'];
288 $this->assertEquals(
'UploadFromUrlJob', get_class(
$job ) );
290 $status =
$job->run();
291 $this->assertTrue( $status );
294 'action' =>
'upload',
295 'statuskey' => $statusKey,
304 $this->assertTrue(
$t->exists(),
"File '$name' exists" );
306 if (
$t->exists() ) {
311 $page->doDeleteArticle(
"testing" );
315 $this->assertFalse(
$t->exists(),
"File '$name' was deleted" );
This is the main API class, used for both external and internal processing.
WebRequest clone which takes values from a provided array.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
wfSetupSession( $sessionId=false)
Initialise php session.
testClearQueue()
Ensure that the job queue is empty before continuing.
doApiRequest(array $params, array $unused=null, $appendModule=false, User $user=null)
Does the API request and returns the result.
testSetupUrlDownload( $data)
@depends testClearQueue
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
This exception will be thrown when dieUsage is called to stop module execution.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
doAsyncUpload( $token, $ignoreWarnings=false, $leaveMessage=false)
Helper function to perform an async upload, execute the job and fetch the status.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Allows to change the fields on the form that will be generated $name
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
if(PHP_SAPI !='cli') $file
testSyncDownload( $data)
@depends testClearQueue
@group Broken @group Upload @group Database
testAsyncUpload( $data)
@depends testClearQueue
if(count( $args)< 1) $job
static singleton( $wiki=false)
wfFindFile( $title, $options=array())
Find a file.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
wfLocalFile( $title)
Get an object referring to a locally registered file.
testAsyncUploadWarning( $data)
@depends testClearQueue