Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9701bd

Browse files
committed
return false early from directory resource
1 parent f7ba71d commit d9701bd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Symfony/Component/Config/Resource/DirectoryResource.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public function isFresh($timestamp)
6868
return false;
6969
}
7070

71-
$newestMTime = filemtime($this->resource);
71+
if (($newestMTime = filemtime($this->resource)) > $timestamp) {
72+
return false;
73+
}
74+
7275
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
7376
// if regex filtering is enabled only check matching files
7477
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
@@ -81,7 +84,12 @@ public function isFresh($timestamp)
8184
continue;
8285
}
8386

84-
$newestMTime = max($file->getMTime(), $newestMTime);
87+
// early return if a file's mtime is exceeds than passed timestamp
88+
if (($fileMTime = $file->getMTime()) > $timestamp) {
89+
return false;
90+
}
91+
92+
$newestMTime = max($fileMTime, $newestMTime);
8593
}
8694

8795
return $newestMTime < $timestamp;

0 commit comments

Comments
 (0)