Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6140587
UploadFromUrlJob.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
UploadFromUrlJob.php
View Options
<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace
MediaWiki\JobQueue\Jobs
;
use
MediaWiki\JobQueue\GenericParameterJob
;
use
MediaWiki\JobQueue\Job
;
use
MediaWiki\Status\Status
;
use
UploadBase
;
use
UploadFromUrl
;
/**
* Upload a file by URL, via the jobqueue.
*/
class
UploadFromUrlJob
extends
Job
implements
GenericParameterJob
{
use
UploadJobTrait
;
public
function
__construct
(
array
$params
)
{
// @TODO: fix the invokation of Job::__construct in the parent class
parent
::
__construct
(
'UploadFromUrl'
,
$params
);
$this
->
removeDuplicates
=
true
;
$this
->
user
=
null
;
$this
->
cacheKey
=
UploadFromUrl
::
getCacheKey
(
$this
->
params
);
}
/**
* Deduplicate on title, url alone.
*
* Please note that this could cause some
* edge case failure, when the image at the
* same remote url is changed before the first upload
* is ran.
*
* @return array
*/
public
function
getDeduplicationInfo
()
{
$info
=
parent
::
getDeduplicationInfo
();
if
(
is_array
(
$info
[
'params'
]
)
)
{
$info
[
'params'
]
=
[
'url'
=>
$info
[
'params'
][
'url'
],
'title'
=>
$info
[
'params'
][
'filename'
]
];
}
return
$info
;
}
protected
function
getUpload
():
UploadBase
{
if
(
$this
->
upload
===
null
)
{
$this
->
upload
=
new
UploadFromUrl
;
$this
->
upload
->
initialize
(
$this
->
params
[
'filename'
],
$this
->
params
[
'url'
]
);
}
return
$this
->
upload
;
}
/**
* Get the parameters for job logging
*
* @param Status[] $status
* @return array
*/
public
function
logJobParams
(
$status
):
array
{
return
[
'stage'
=>
$status
[
'stage'
]
??
'-'
,
'result'
=>
$status
[
'result'
]
??
'-'
,
'status'
=>
(
string
)(
$status
[
'status'
]
??
'-'
),
'url'
=>
$this
->
params
[
'url'
],
'filename'
=>
$this
->
params
[
'filename'
],
'user'
=>
$this
->
user
->
getName
(),
];
}
}
/** @deprecated class alias since 1.44 */
class_alias
(
UploadFromUrlJob
::
class
,
'UploadFromUrlJob'
);
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 7 2026, 18:03 (6 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c9/d9/7709ad924d30b02b7c3d9bd7a45c
Default Alt Text
UploadFromUrlJob.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment