Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / jobqueue / jobs / PublishStashedFileJob.php
blob27ff97ef548a5916e39ad91dedef41956d8bb5a2
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @defgroup JobQueue JobQueue
22 use MediaWiki\Status\Status;
24 /**
25 * Upload a file from the upload stash into the local file repo.
27 * @ingroup Upload
28 * @ingroup JobQueue
30 class PublishStashedFileJob extends Job implements GenericParameterJob {
31 use UploadJobTrait;
33 public function __construct( array $params ) {
34 parent::__construct( 'PublishStashedFile', $params );
35 $this->removeDuplicates = true;
36 $this->initialiseUploadJob( $this->params['filekey'] );
39 public function getDeduplicationInfo() {
40 $info = parent::getDeduplicationInfo();
41 if ( is_array( $info['params'] ) ) {
42 $info['params'] = [ 'filekey' => $info['params']['filekey'] ];
45 return $info;
48 /**
49 * Get the parameters for job logging
51 * @param Status[] $status
52 * @return array
54 public function logJobParams( $status ): array {
55 return [
56 'stage' => $status['stage'] ?? '-',
57 'result' => $status['result'] ?? '-',
58 'status' => (string)( $status['status'] ?? '-' ),
59 'filekey' => $this->params['filekey'],
60 'filename' => $this->params['filename'],
61 'user' => $this->user->getName(),
65 /**
66 * getter for the upload
68 * @return UploadFromStash
70 protected function getUpload(): UploadBase {
71 if ( $this->upload === null ) {
72 $this->upload = new UploadFromStash( $this->user );
73 // @todo initialize() causes a GET, ideally we could frontload the antivirus
74 // checks and anything else to the stash stage (which includes concatenation and
75 // the local file is thus already there). That way, instead of GET+PUT, there could
76 // just be a COPY operation from the stash to the public zone.
77 $this->upload->initialize( $this->params['filekey'], $this->params['filename'] );
79 return $this->upload;