diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2014-04-13 14:46:37 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2014-04-13 14:51:33 +0100 |
commit | 869e7a51f0ed5b24c1ee0714112edb71e7dd1b62 (patch) | |
tree | 5ea8b631e02cf9f95dfb0648a012e4e93e93f4b3 /apps/files_trashbin/lib/trashbin.php | |
parent | fa8814902e9012880179e61ea846a7d85e3079f8 (diff) | |
download | nextcloud-server-869e7a51f0ed5b24c1ee0714112edb71e7dd1b62.tar.gz nextcloud-server-869e7a51f0ed5b24c1ee0714112edb71e7dd1b62.zip |
Prevent error in files_trashbin
`glob` can return FALSE when the directory is empty, instead of an empty array,
causing an error at `foreach`.
"Note: On some systems it is impossible to distinguish between empty match and
an error."
See http://www.php.net/manual/en/function.glob.php -> Return Values
Diffstat (limited to 'apps/files_trashbin/lib/trashbin.php')
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index bf8d465e5de..9b931333b7f 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -824,13 +824,15 @@ class Trashbin { $matches = glob($escapedVersionsName . '*'); } - foreach ($matches as $ma) { - if ($timestamp) { - $parts = explode('.v', substr($ma, 0, $offset)); - $versions[] = (end($parts)); - } else { - $parts = explode('.v', $ma); - $versions[] = (end($parts)); + if (is_array($matches)) { + foreach ($matches as $ma) { + if ($timestamp) { + $parts = explode('.v', substr($ma, 0, $offset)); + $versions[] = (end($parts)); + } else { + $parts = explode('.v', $ma); + $versions[] = (end($parts)); + } } } return $versions; |