Skip to content

Commit 9f99453

Browse files
Merge branch '2.8' into 3.2
* 2.8: property constraints can be added in child classes added test for staticClassLoader in LazyLoadingMetadatafactory spelling fixes Readd Symfony version status in the toolbar make sure that null can be the invalid value [VarDumper] Improve dump of AMQP* Object [VarDumper] Fixed dumping of terminated generator bumped Symfony version to 2.8.18 updated VERSION for 2.8.17 updated CHANGELOG for 2.8.17 bumped Symfony version to 2.7.25 updated VERSION for 2.7.24 update CONTRIBUTORS for 2.7.24 updated CHANGELOG for 2.7.24 [FrameworkBundle] Simplify createPackageDefinition fix directory resource considers same timestamp not fresh return false early from directory resource
2 parents 2ffa7b8 + 35b2e1c commit 9f99453

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Resource/DirectoryResource.php

Lines changed: 9 additions & 3 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 ($timestamp < filemtime($this->resource)) {
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,10 +90,13 @@ public function isFresh($timestamp)
8790
continue;
8891
}
8992

90-
$newestMTime = max($file->getMTime(), $newestMTime);
93+
// early return if a file's mtime exceeds the passed timestamp
94+
if ($timestamp < $file->getMTime()) {
95+
return false;
96+
}
9197
}
9298

93-
return $newestMTime < $timestamp;
99+
return true;
94100
}
95101

96102
public function serialize()

Tests/Resource/DirectoryResourceTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ public function testIsFreshNewFileWithDifferentPattern()
110110
public function testIsFreshDeleteFile()
111111
{
112112
$resource = new DirectoryResource($this->directory);
113+
$time = time();
114+
sleep(1);
113115
unlink($this->directory.'/tmp.xml');
114-
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if an existing file is removed');
116+
$this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed');
115117
}
116118

117119
public function testIsFreshDeleteDirectory()

0 commit comments

Comments
 (0)