Skip to content

Commit

Permalink
Fix RuntimeException when an Emacs buffer is modified
Browse files Browse the repository at this point in the history
When an Emacs buffer is modified, by default Emacs automatically creates a
temporary symlink in the same directory as the file being edited (e.g. Controller.php):

```
.#Controller.php -> user@host.12345:1296583136
```

where '12345' is Emacs' PID.

In this case Symfony breaks with a RuntimeException:

```
SplFileInfo::getMTime(): stat failed for ...Bundle/Controller/.#APIController.php
```

in
vendor/symfony/symfony/src/Symfony/Component/Config/Resource/DirectoryResource.php
at line 89

```
$newestMTime = max($file->getMTime(), $newestMTime);
```
  • Loading branch information
rubenrua committed Feb 28, 2017
1 parent eb750be commit c6f7ca6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Symfony/Component/Config/Resource/DirectoryResource.php
Expand Up @@ -84,8 +84,15 @@ public function isFresh($timestamp)
continue;
}

// for broken links
try {
$fileMTime = $file->getMTime();
} catch (\RuntimeException $e) {
continue;
}

// early return if a file's mtime exceeds the passed timestamp
if ($timestamp < $file->getMTime()) {
if ($timestamp < $fileMTime) {
return false;
}
}
Expand Down

0 comments on commit c6f7ca6

Please sign in to comment.