]> source.dussan.org Git - nextcloud-server.git/commitdiff
Prevent error in files_trashbin
authorRobin McCorkell <rmccorkell@karoshi.org.uk>
Sun, 13 Apr 2014 13:46:37 +0000 (14:46 +0100)
committerRobin McCorkell <rmccorkell@karoshi.org.uk>
Sun, 13 Apr 2014 13:51:33 +0000 (14:51 +0100)
`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

apps/files_trashbin/lib/trashbin.php

index bf8d465e5de977726e5ee87059c2b2d87b813151..9b931333b7f729542c2c87bd539ea45a410d6588 100644 (file)
@@ -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;