MediaWiki  1.34.0
DeleteFileOp.php
Go to the documentation of this file.
1 <?php
28 class DeleteFileOp extends FileOp {
29  protected function allowedParams() {
30  return [ [ 'src' ], [ 'ignoreMissingSource' ], [ 'src' ] ];
31  }
32 
33  protected function doPrecheck( array &$predicates ) {
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 }
DeleteFileOp\doAttempt
doAttempt()
Definition: DeleteFileOp.php:63
DeleteFileOp
Delete a file at the given storage path from the backend.
Definition: DeleteFileOp.php:28
FileOp
FileBackend helper class for representing operations.
Definition: FileOp.php:36
FileOp\setFlags
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
Definition: FileOp.php:346
DeleteFileOp\storagePathsChanged
storagePathsChanged()
Get a list of storage paths written to for this operation.
Definition: DeleteFileOp.php:68
FileOp\getParam
getParam( $name)
Get the value of the parameter with the given name.
Definition: FileOp.php:139
DeleteFileOp\doPrecheck
doPrecheck(array &$predicates)
Definition: DeleteFileOp.php:33
DeleteFileOp\allowedParams
allowedParams()
Get the file operation parameters.
Definition: DeleteFileOp.php:29
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
$status
return $status
Definition: SyntaxHighlight.php:347
FileOp\fileExists
fileExists( $source, array $predicates)
Check if a file will exist in storage when this operation is attempted.
Definition: FileOp.php:433