MediaWiki  1.34.0
DescribeFileOp.php
Go to the documentation of this file.
1 <?php
28 class DescribeFileOp extends FileOp {
29  protected function allowedParams() {
30  return [ [ 'src' ], [ 'headers' ], [ '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  $status->fatal( 'backend-fail-notexists', $this->params['src'] );
40 
41  return $status;
42  } elseif ( $srcExists === FileBackend::EXISTENCE_ERROR ) {
43  $status->fatal( 'backend-fail-stat', $this->params['src'] );
44 
45  return $status;
46  }
47  // Update file existence predicates
48  $predicates['exists'][$this->params['src']] = $srcExists;
49  $predicates['sha1'][$this->params['src']] =
50  $this->fileSha1( $this->params['src'], $predicates );
51 
52  return $status; // safe to call attempt()
53  }
54 
55  protected function doAttempt() {
56  // Update the source file's metadata
57  return $this->backend->describeInternal( $this->setFlags( $this->params ) );
58  }
59 
60  public function storagePathsChanged() {
61  return [ $this->params['src'] ];
62  }
63 }
FileOp\fileSha1
fileSha1( $source, array $predicates)
Get the SHA-1 hash a file in storage will have when this operation is attempted.
Definition: FileOp.php:453
DescribeFileOp
Change metadata for a file at the given storage path in the backend.
Definition: DescribeFileOp.php:28
FileOp
FileBackend helper class for representing operations.
Definition: FileOp.php:36
DescribeFileOp\allowedParams
allowedParams()
Get the file operation parameters.
Definition: DescribeFileOp.php:29
FileOp\setFlags
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
Definition: FileOp.php:346
DescribeFileOp\storagePathsChanged
storagePathsChanged()
Get a list of storage paths written to for this operation.
Definition: DescribeFileOp.php:60
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
DescribeFileOp\doPrecheck
doPrecheck(array &$predicates)
Definition: DescribeFileOp.php:33
DescribeFileOp\doAttempt
doAttempt()
Definition: DescribeFileOp.php:55