MediaWiki REL1_34
DescribeFileOp.php
Go to the documentation of this file.
1<?php
28class DescribeFileOp extends FileOp {
29 protected function allowedParams() {
30 return [ [ 'src' ], [ 'headers' ], [ '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 $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}
Change metadata for a file at the given storage path in the backend.
storagePathsChanged()
Get a list of storage paths written to for this operation.
allowedParams()
Get the file operation parameters.
doPrecheck(array &$predicates)
FileBackend helper class for representing operations.
Definition FileOp.php:36
fileSha1( $source, array $predicates)
Get the SHA-1 hash a file in storage will have when this operation is attempted.
Definition FileOp.php:453
fileExists( $source, array $predicates)
Check if a file will exist in storage when this operation is attempted.
Definition FileOp.php:433
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
Definition FileOp.php:346