Skip to content

Commit ff4bb8f

Browse files
[Filesystem] Fix usages of error_get_last()
1 parent 40bcd77 commit ff4bb8f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ public static function createConnection($dsn, array $options = array())
126126
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
127127
}
128128

129-
if (@!$redis->isConnected()) {
129+
set_error_handler('var_dump', 0);
130+
$isConnected = @$redis->isConnected();
131+
restore_error_handler();
132+
if (!$isConnected) {
130133
$e = ($e = error_get_last()) && preg_match('/^Redis::p?connect\(\): (.*)/', $e['message'], $e) ? sprintf(' (%s)', $e[1]) : '';
131134
throw new InvalidArgumentException(sprintf('Redis connection failed%s: %s', $e, $dsn));
132135
}

src/Symfony/Component/Lock/Store/FlockStore.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,13 @@ private function lock(Key $key, $blocking)
7878
);
7979

8080
// Silence error reporting
81-
set_error_handler(function () {
82-
});
83-
if (!$handle = fopen($fileName, 'r')) {
84-
if ($handle = fopen($fileName, 'x')) {
85-
chmod($fileName, 0444);
86-
} elseif (!$handle = fopen($fileName, 'r')) {
81+
set_error_handler('var_dump', 0);
82+
if (!$handle = @fopen($fileName, 'r')) {
83+
if ($handle = @fopen($fileName, 'x')) {
84+
@chmod($fileName, 0444);
85+
} elseif (!$handle = @fopen($fileName, 'r')) {
8786
usleep(100); // Give some time for chmod() to complete
88-
$handle = fopen($fileName, 'r');
87+
$handle = @fopen($fileName, 'r');
8988
}
9089
}
9190
restore_error_handler();

0 commit comments

Comments
 (0)