From 58cd520e323d149cb5eae75c10c072ea586b06f1 Mon Sep 17 00:00:00 2001 From: Alexander Kurilo Date: Thu, 26 Jun 2014 19:46:45 +0300 Subject: [PATCH] Fix attempt of traversing bool in FileLockRegion --- lib/Doctrine/ORM/Cache/Region/FileLockRegion.php | 9 +++++++-- .../Tools/Export/AbstractClassMetadataExporterTest.php | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index 7e20d5f73..5994e40cf 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -201,8 +201,13 @@ class FileLockRegion implements ConcurrentRegion */ public function evictAll() { - foreach (glob(sprintf("%s/*.%s" , $this->directory, self::LOCK_EXTENSION)) as $filename) { - @unlink($filename); + // The check below is necessary because on some platforms glob returns false + // when nothing matched (even though no errors occurred) + $filenames = glob(sprintf("%s/*.%s" , $this->directory, self::LOCK_EXTENSION)); + if (is_array($filenames)) { + foreach ($filenames as $filename) { + @unlink($filename); + } } return $this->region->evictAll(); diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php index 3ad2c88f1..7c3c33c6a 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php @@ -393,8 +393,10 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest return unlink($path); } else if (is_dir($path)) { $files = glob(rtrim($path,'/').'/*'); - foreach ($files as $file){ - $this->_deleteDirectory($file); + if (is_array($files)) { + foreach ($files as $file){ + $this->_deleteDirectory($file); + } } return rmdir($path); }