MediaWiki REL1_37
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
48 // Update file existence predicates since the operation is expected to be allowed to run
49 $predicates[self::ASSUMED_EXISTS][$this->params['src']] = $srcExists;
50 $predicates[self::ASSUMED_SIZE][$this->params['src']] =
51 $this->fileSize( $this->params['src'], $predicates );
52 $predicates[self::ASSUMED_SHA1][$this->params['src']] =
53 $this->fileSha1( $this->params['src'], $predicates );
54
55 return $status; // safe to call attempt()
56 }
57
58 protected function doAttempt() {
59 // Update the source file's metadata
60 return $this->backend->describeInternal( $this->setFlags( $this->params ) );
61 }
62
63 public function storagePathsChanged() {
64 return [ $this->params['src'] ];
65 }
66}
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 of a file in storage when this operation is attempted.
Definition FileOp.php:526
fileExists( $source, array $predicates)
Check if a file will exist in storage when this operation is attempted.
Definition FileOp.php:483
const ASSUMED_EXISTS
Definition FileOp.php:73
const ASSUMED_SIZE
Definition FileOp.php:74
const ASSUMED_SHA1
Definition FileOp.php:72
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
Definition FileOp.php:368
fileSize( $source, array $predicates)
Get the size a file in storage will have when this operation is attempted.
Definition FileOp.php:504