summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/trashbin.php
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@karoshi.org.uk>2014-04-13 14:46:37 +0100
committerRobin McCorkell <rmccorkell@karoshi.org.uk>2014-04-13 14:51:33 +0100
commit869e7a51f0ed5b24c1ee0714112edb71e7dd1b62 (patch)
tree5ea8b631e02cf9f95dfb0648a012e4e93e93f4b3 /apps/files_trashbin/lib/trashbin.php
parentfa8814902e9012880179e61ea846a7d85e3079f8 (diff)
downloadnextcloud-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.php16
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;