From: Antoine Musso Date: Mon, 23 Jan 2012 14:48:49 +0000 (+0000) Subject: FileOp: allow creation of an empty file X-Git-Tag: 1.31.0-rc.0~25124 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=ed90f5548f6e1c9987e178dbe698ee9e2e49ebbb;p=lhc%2Fweb%2Fwiklou.git FileOp: allow creation of an empty file When creating a file but ommitting the 'content' key, it would throw a notice. Using getParams let us forget about the 'content' key and hence create files with no content. --- diff --git a/includes/filerepo/backend/FileOp.php b/includes/filerepo/backend/FileOp.php index c325190ef5..71a853148f 100644 --- a/includes/filerepo/backend/FileOp.php +++ b/includes/filerepo/backend/FileOp.php @@ -438,7 +438,7 @@ class StoreFileOp extends FileOp { /** * Create a file in the backend with the given content. * Parameters similar to FileBackend::createInternal(), which include: - * content : a string of raw file contents + * content : a string of raw file content. Let unset to create an empty file. * dst : destination storage path * overwrite : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination @@ -451,7 +451,7 @@ class CreateFileOp extends FileOp { protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); // Check if the source data is too big - if ( strlen( $this->params['content'] ) > $this->backend->maxFileSizeInternal() ) { + if ( strlen( $this->getParam( 'content' ) ) > $this->backend->maxFileSizeInternal() ) { $status->fatal( 'backend-fail-create', $this->params['dst'] ); return $status; // Check if a file can be placed at the destination