merged branch gajdaw/finder_splfileinfo_fpassthu (PR #4751)

Commits
-------

b4d7a7e [Component][Finder][SplFileInfo] file_get_contents=>fpassthru

Discussion
----------

[Component][Finder][SplFileInfo] file_get_contents=>fpassthru

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: https://github.com/symfony/symfony/pull/4335/files#r1016152
Todo: -
License of the code: MIT
Documentation PR: -
This commit is contained in:
Fabien Potencier 2012-07-09 17:05:52 +02:00
commit 5608c0c3ee

View File

@ -62,14 +62,9 @@ class SplFileInfo extends \SplFileInfo
*/ */
public function getContents() public function getContents()
{ {
$level = error_reporting(0); $file = new \SplFileObject($this->getRealpath(), "rb");
$content = file_get_contents($this->getRealpath()); ob_start();
error_reporting($level); $file->fpassthru();
if (false === $content) { return ob_get_clean();
$error = error_get_last();
throw new \RuntimeException($error['message']);
}
return $content;
} }
} }