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
This commit is contained in:
Robin McCorkell 2014-04-13 14:46:37 +01:00
parent fa8814902e
commit 869e7a51f0
1 changed files with 9 additions and 7 deletions

View 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;