8000 [Config] added existence check to some resource methods · lauris/symfony@241aa92 · GitHub
[go: up one dir, main page]

Skip to content

Commit 241aa92

Browse files
committed
[Config] added existence check to some resource methods
* fixed DELETED event when starting to watch a file that does not exist yet * fixed files that are deleted and then re-created Conflicts: src/Symfony/Component/ResourceWatcher/StateChecker/ResourceStateChecker.php tests/Symfony/Tests/Component/ResourceWatcher/StateChecker/DirectoryStateCheckerTest.php tests/Symfony/Tests/Component/ResourceWatcher/StateChecker/FileStateCheckerTest.php
1 parent 56b60c8 commit 241aa92

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public function getFilteredChilds()
7575
*/
7676
public function getFilteredResources()
7777
{
78+
if (!$this->exists()) {
79+
return array();
80+
}
81+
7882
$iterator = new \DirectoryIterator($this->resource);
7983

8084
$resources = array();
@@ -166,6 +170,10 @@ public function hasFile($file)
166170
*/
167171
public function getModificationTime()
168172
{
173+
if (!$this->exists()) {
174+
return -1;
175+
}
176+
169177
clearstatcache(true, $this->resource);
170178
$newestMTime = filemtime($this->resource);
171179

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class FileResource implements ResourceInterface
2929
*/
3030
public function __construct($resource)
3131
{
32-
$this->resource = realpath($resource);
32+
$this->resource = file_exists($resource) ? realpath($resource) : $resource;
3333
}
3434

3535
/**
@@ -59,6 +59,10 @@ public function getResource()
5959
*/
6060
public function getModificationTime()
6161
{
62+
if (!$this->exists()) {
63+
return -1;
64+
}
65+
6266
clearstatcache(true, $this->resource);
6367

6468
return filemtime($this->resource);

0 commit comments

Comments
 (0)
0