Fix missing commit() flag in postgres savepoint class
[mediawiki.git] / includes / libs / filebackend / fileop / DescribeFileOp.php
blob9b53222433061a74057ffe21f18eadf4d12a5dc3
1 <?php
2 /**
3 * Helper class for representing operations with transaction support.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup FileBackend
22 * @author Aaron Schulz
25 /**
26 * Change metadata for a file at the given storage path in the backend.
27 * Parameters for this operation are outlined in FileBackend::doOperations().
29 class DescribeFileOp extends FileOp {
30 protected function allowedParams() {
31 return [ [ 'src' ], [ 'headers' ], [ 'src' ] ];
34 protected function doPrecheck( array &$predicates ) {
35 $status = StatusValue::newGood();
36 // Check if the source file exists
37 if ( !$this->fileExists( $this->params['src'], $predicates ) ) {
38 $status->fatal( 'backend-fail-notexists', $this->params['src'] );
40 return $status;
41 // Check if a file can be placed/changed at the source
42 } elseif ( !$this->backend->isPathUsableInternal( $this->params['src'] ) ) {
43 $status->fatal( 'backend-fail-usable', $this->params['src'] );
44 $status->fatal( 'backend-fail-describe', $this->params['src'] );
46 return $status;
48 // Update file existence predicates
49 $predicates['exists'][$this->params['src']] =
50 $this->fileExists( $this->params['src'], $predicates );
51 $predicates['sha1'][$this->params['src']] =
52 $this->fileSha1( $this->params['src'], $predicates );
54 return $status; // safe to call attempt()
57 protected function doAttempt() {
58 // Update the source file's metadata
59 return $this->backend->describeInternal( $this->setFlags( $this->params ) );
62 public function storagePathsChanged() {
63 return [ $this->params['src'] ];