8000 return false early from directory resource · symfony/symfony@cab5763 · GitHub
[go: up one dir, main page]

Skip to content

Commit cab5763

Browse files
committed
return false early from directory resource
1 parent 6791124 commit cab5763

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
@@ -74,7 +74,10 @@ public function isFresh($timestamp)
7474
return false;
7575
}
7676

77-
$newestMTime = filemtime($this->resource);
77+
if (($newestMTime = filemtime($this->resource)) > $timestamp) {
78+
return false;
79+
}
80+
7881
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
7982
// if regex filtering is enabled only check matching files
8083
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
@@ -87,7 +90,12 @@ public function isFresh($timestamp)
8790
continue;
8891
}
8992

90-
$newestMTime = max($file->getMTime(), $newestMTime);
93+
// early return if any file mtime is greater than passed timestamp
94+
if (($fileMTime = $file->getMTime()) > $timestamp) {
95+
return false;
96+
}
97+
98+
$newestMTime = max($fileMTime, $newestMTime);
9199
}
92100

93101
return $newestMTime < $timestamp;

0 commit comments

Comments
 (0)
0