From: Aaron Date: Thu, 17 May 2012 18:28:05 +0000 (-0700) Subject: [FileBackend] A few code cleanups and some error message improvements. X-Git-Tag: 1.31.0-rc.0~23582 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_user_edit%27%2C%20iduser=user.userid%29%20%7D%7D?a=commitdiff_plain;h=159cc27fde1f650f577095d1ad1ce697a3da4d8b;p=lhc%2Fweb%2Fwiklou.git [FileBackend] A few code cleanups and some error message improvements. Change-Id: I75f066104b98638ca956042c4e877c0f6327509c --- diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index bb3f9ee24c..94e509ec62 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -286,8 +286,7 @@ abstract class FileBackend { * @return Status */ final public function create( array $params, array $opts = array() ) { - $params['op'] = 'create'; - return $this->doOperation( $params, $opts ); + return $this->doOperation( array( 'op' => 'create' ) + $params, $opts ); } /** @@ -301,8 +300,7 @@ abstract class FileBackend { * @return Status */ final public function store( array $params, array $opts = array() ) { - $params['op'] = 'store'; - return $this->doOperation( $params, $opts ); + return $this->doOperation( array( 'op' => 'store' ) + $params, $opts ); } /** @@ -316,8 +314,7 @@ abstract class FileBackend { * @return Status */ final public function copy( array $params, array $opts = array() ) { - $params['op'] = 'copy'; - return $this->doOperation( $params, $opts ); + return $this->doOperation( array( 'op' => 'copy' ) + $params, $opts ); } /** @@ -331,8 +328,7 @@ abstract class FileBackend { * @return Status */ final public function move( array $params, array $opts = array() ) { - $params['op'] = 'move'; - return $this->doOperation( $params, $opts ); + return $this->doOperation( array( 'op' => 'move' ) + $params, $opts ); } /** @@ -346,8 +342,7 @@ abstract class FileBackend { * @return Status */ final public function delete( array $params, array $opts = array() ) { - $params['op'] = 'delete'; - return $this->doOperation( $params, $opts ); + return $this->doOperation( array( 'op' => 'delete' ) + $params, $opts ); } /** diff --git a/includes/filerepo/backend/FileBackendStore.php b/includes/filerepo/backend/FileBackendStore.php index 1b788dbe64..5537e9378f 100644 --- a/includes/filerepo/backend/FileBackendStore.php +++ b/includes/filerepo/backend/FileBackendStore.php @@ -137,7 +137,8 @@ abstract class FileBackendStore extends FileBackend { wfProfileIn( __METHOD__ ); wfProfileIn( __METHOD__ . '-' . $this->name ); if ( filesize( $params['src'] ) > $this->maxFileSizeInternal() ) { - $status = Status::newFatal( 'backend-fail-store', $params['dst'] ); + $status = Status::newFatal( 'backend-fail-maxsize', + $params['dst'], $this->maxFileSizeInternal() ); } else { $status = $this->doStoreInternal( $params ); $this->clearCache( array( $params['dst'] ) ); diff --git a/includes/filerepo/backend/FileOp.php b/includes/filerepo/backend/FileOp.php index d134edd5ce..b2b46ed907 100644 --- a/includes/filerepo/backend/FileOp.php +++ b/includes/filerepo/backend/FileOp.php @@ -450,10 +450,13 @@ class StoreFileOp extends FileOp { return $status; // Check if the source file is too big } elseif ( filesize( $this->params['src'] ) > $this->backend->maxFileSizeInternal() ) { + $status->fatal( 'backend-fail-maxsize', + $this->params['dst'], $this->backend->maxFileSizeInternal() ); $status->fatal( 'backend-fail-store', $this->params['src'], $this->params['dst'] ); return $status; // Check if a file can be placed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { + $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-store', $this->params['src'], $this->params['dst'] ); return $status; } @@ -507,10 +510,13 @@ class CreateFileOp extends FileOp { $status = Status::newGood(); // Check if the source data is too big if ( strlen( $this->getParam( 'content' ) ) > $this->backend->maxFileSizeInternal() ) { + $status->fatal( 'backend-fail-maxsize', + $this->params['dst'], $this->backend->maxFileSizeInternal() ); $status->fatal( 'backend-fail-create', $this->params['dst'] ); return $status; // Check if a file can be placed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { + $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-create', $this->params['dst'] ); return $status; } @@ -562,6 +568,7 @@ class CopyFileOp extends FileOp { return $status; // Check if a file can be placed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { + $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-copy', $this->params['src'], $this->params['dst'] ); return $status; } @@ -616,6 +623,7 @@ class MoveFileOp extends FileOp { return $status; // Check if a file can be placed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { + $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-move', $this->params['src'], $this->params['dst'] ); return $status; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index c13c9da623..e3a1deef68 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2283,8 +2283,9 @@ If the problem persists, contact an [[Special:ListUsers/sysop|administrator]].', 'backend-fail-writetemp' => 'Could not write to temporary file.', 'backend-fail-closetemp' => 'Could not close temporary file.', 'backend-fail-read' => 'Could not read file $1.', -'backend-fail-create' => 'Could not create file $1.', -'backend-fail-maxsize' => 'Could not create file $1 because it is larger than {{PLURAL:$2|one byte|$2 bytes}}.', +'backend-fail-create' => 'Could not write file $1.', +'backend-fail-maxsize' => 'Could not write file $1 because it is larger than {{PLURAL:$2|one byte|$2 bytes}}.', +'backend-fail-usable' => 'Could not write file $1 due to insufficient permissions or missing directories/containers.', 'backend-fail-readonly' => 'The storage backend "$1" is currently read-only. The reason given is: "\'\'$2\'\'"', 'backend-fail-synced' => 'The file "$1" is in an inconsistent state within the internal storage backends', 'backend-fail-connect' => 'Could not connect to storage backend "$1".', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index eb85c53a2d..9ccf5f3152 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -1966,6 +1966,8 @@ Extensions making use of it: Parameters: * $1 is the number of operations attempted at once in this case. * $2 is the maximum number of operations that can be attempted at once.', +'backend-fail-usable' => 'Parameters: +* $1 is a file path', # File journal errors 'filejournal-fail-dbconnect' => 'Parameters: diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index c55b83d64f..6bf74b51a7 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1388,7 +1388,8 @@ $wgMessageStructure = array( 'backend-fail-connect', 'backend-fail-internal', 'backend-fail-contenttype', - 'backend-fail-batchsize' + 'backend-fail-batchsize', + 'backend-fail-usable' ), 'filejournal-errors' => array(