From c6f7ca6fa1f14eb8db6b1aa33fe45c9e542b6e8e Mon Sep 17 00:00:00 2001 From: rubenrua Date: Thu, 23 Feb 2017 14:04:10 +0100 Subject: [PATCH] Fix RuntimeException when an Emacs buffer is modified 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); ``` --- .../Component/Config/Resource/DirectoryResource.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Resource/DirectoryResource.php b/src/Symfony/Component/Config/Resource/DirectoryResource.php index e403725d6ac6..bde84b1b5bd5 100644 --- a/src/Symfony/Component/Config/Resource/DirectoryResource.php +++ b/src/Symfony/Component/Config/Resource/DirectoryResource.php @@ -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; } }