]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check if the size field is available
authorLukas Reschke <lukas@owncloud.com>
Mon, 17 Nov 2014 21:39:40 +0000 (22:39 +0100)
committerLukas Reschke <lukas@owncloud.com>
Mon, 17 Nov 2014 21:39:40 +0000 (22:39 +0100)
In some cases the 'size' field is not available resulting in some PHP errors such as:

```json
{"reqId":"03548fd9e3d3aca15a5796b3b35d7b9d","remoteAddr":"::1","app":"PHP","message":"Undefined index: size at \/Users\/lreschke\/Programming\/core\/lib\/private\/files\/fileinfo.php#125","level":3,"time":"2014-11-17T21:38:57+00:00"}
```

This can be experienced when creating a new empty file and deleting it right away, then when going to the trash bin this error is thrown.

lib/private/files/fileinfo.php

index 8457a2d160f02a4397f9d4a7ac4612ad0de3427e..d6d6a245e44e8c2136734904bfc4606d851c72db 100644 (file)
@@ -122,7 +122,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
         * @return int
         */
        public function getSize() {
-               return $this->data['size'];
+               return isset($this->data['size']) ? $this->data['size'] : 0;
        }
 
        /**