MediaWiki REL1_34
DeleteFileOp.php
Go to the documentation of this file.
1<?php
28class DeleteFileOp extends FileOp {
29 protected function allowedParams() {
30 return [ [ 'src' ], [ 'ignoreMissingSource' ], [ 'src' ] ];
31 }
32
33 protected function doPrecheck( array &$predicates ) {
34 $status = StatusValue::newGood();
35
36 // Check source file existence
37 $srcExists = $this->fileExists( $this->params['src'], $predicates );
38 if ( $srcExists === false ) {
39 if ( $this->getParam( 'ignoreMissingSource' ) ) {
40 $this->doOperation = false; // no-op
41 // Update file existence predicates (cache 404s)
42 $predicates['exists'][$this->params['src']] = false;
43 $predicates['sha1'][$this->params['src']] = false;
44
45 return $status; // nothing to do
46 } else {
47 $status->fatal( 'backend-fail-notexists', $this->params['src'] );
48
49 return $status;
50 }
51 } elseif ( $srcExists === FileBackend::EXISTENCE_ERROR ) {
52 $status->fatal( 'backend-fail-stat', $this->params['src'] );
53
54 return $status;
55 }
56 // Update file existence predicates
57 $predicates['exists'][$this->params['src']] = false;
58 $predicates['sha1'][$this->params['src']] = false;
59
60 return $status; // safe to call attempt()
61 }
62
63 protected function doAttempt() {
64 // Delete the source file
65 return $this->backend->deleteInternal( $this->setFlags( $this->params ) );
66 }
67
68 public function storagePathsChanged() {
69 return [ $this->params['src'] ];
70 }
71}
Delete a file at the given storage path from the backend.
allowedParams()
Get the file operation parameters.
storagePathsChanged()
Get a list of storage paths written to for this operation.
doPrecheck(array &$predicates)
FileBackend helper class for representing operations.
Definition FileOp.php:36
fileExists( $source, array $predicates)
Check if a file will exist in storage when this operation is attempted.
Definition FileOp.php:433
getParam( $name)
Get the value of the parameter with the given name.
Definition FileOp.php:139
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
Definition FileOp.php:346