Skip to content

Commit 34226a3

Browse files
committed
bug #27236 [Filesystem] Fix usages of error_get_last() (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [Filesystem] Fix usages of error_get_last() | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Same as #27232 for 2.7. When a userland error handler doesn't return `false`, `error_get_last()` is not updated, so we cannot see the real last error, but the previous one. See https://3v4l.org/Smmt7 Commits ------- 9d015c7c50 [Filesystem] Fix usages of error_get_last()
2 parents 764cdfd + 090095a commit 34226a3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

SplFileInfo.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ public function getRelativePathname()
6666
*/
6767
public function getContents()
6868
{
69-
$level = error_reporting(0);
69+
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
7070
$content = file_get_contents($this->getPathname());
71-
error_reporting($level);
71+
restore_error_handler();
7272
if (false === $content) {
73-
$error = error_get_last();
74-
throw new \RuntimeException($error['message']);
73+
throw new \RuntimeException($error);
7574
}
7675

7776
return $content;

0 commit comments

Comments
 (0)