8000 Merge branch '3.4' into 4.0 · symfony/symfony@26535bb · GitHub
[go: up one dir, main page]

Skip to content

Commit 26535bb

Browse files
Merge branch '3.4' into 4.0
* 3.4: [Lock] use 'r+' for fopen (fixes issue on Solaris) [HttpKernel] fix test compat with PHP 5.3 fix handling of nested Error instances fix file lock on SunOS [Cache] more granular handling of exceptions in AbstractTrait::clear() change `evaluate()` docblock return type from string to mixed Set serialize_precision explicitly to avoid fancy float rounding
2 parents 641ecbb + df0dba6 commit 26535bb

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,26 @@ public function hasItem($key)
105105
public function clear()
106106
{
107107
$this->deferred = array();
108-
try {
109-
if ($cleared = $this->versioningIsEnabled) {
110-
$namespaceVersion = 2;
111-
try {
112-
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
113-
$namespaceVersion = 1 + (int) $v;
114-
}
115-
} catch (\Exception $e) {
108+
if ($cleared = $this->versioningIsEnabled) {
109+
$namespaceVersion = 2;
110+
try {
111+
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
112+
$namespaceVersion = 1 + (int) $v;
116113
}
117-
$namespaceVersion .= ':';
114+
} catch (\Exception $e) {
115+
}
116+
$namespaceVersion .= ':';
117+
try {
118118
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
119-
if ($cleared = true === $cleared || array() === $cleared) {
120-
$this->namespaceVersion = $namespaceVersion;
121-
}
119+
} catch (\Exception $e) {
120+
$cleared = false;
121+
}
122+
if ($cleared = true === $cleared || array() === $cleared) {
123+
$this->namespaceVersion = $namespaceVersion;
122124
}
125+
}
123126

127+
try {
124128
return $this->doClear($this->namespace) || $cleared;
125129
} catch (\Exception $e) {
126130
CacheItem::log($this->logger, 'Failed to clear the cache', array('exception' => $e));

src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function compile($expression, $names = array())
6060
* @param Expression|string $expression The expression to compile
6161
* @param array $values An array of values
6262
*
63-
* @return string The result of the evaluation of the expression
63+
* @return mixed The result of the evaluation of the expression
6464
*/
6565
public function evaluate($expression, $values = array())
6666
{

src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function onKernelException(GetResponseForExceptionEvent $event)
6464
}
6565
}
6666

67-
$prev = new \ReflectionProperty('Exception', 'previous');
67+
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
6868
$prev->setAccessible(true);
6969
$prev->setValue($wrapper, $exception);
7070

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ private function lock(Key $key, $blocking)
7979

8080
// Silence error reporting
8181
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
82-
if (!$handle = fopen($fileName, 'r')) {
82+
if (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
8383
if ($handle = fopen($fileName, 'x')) {
8484
chmod($fileName, 0444);
85-
} elseif (!$handle = fopen($fileName, 'r')) {
85+
} elseif (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
8686
usleep(100); // Give some time for chmod() to complete
87-
$handle = fopen($fileName, 'r');
87+
$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r');
8888
}
8989
}
9090
restore_error_handler();

0 commit comments

Comments
 (0)
0