Merge branch '4.0' into 4.1

* 4.0:
  [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
This commit is contained in:
Nicolas Grekas 2018-06-21 13:15:46 +02:00
commit e1f2c3c058
4 changed files with 22 additions and 18 deletions

View File

@ -105,22 +105,26 @@ trait AbstractTrait
public function clear()
{
$this->deferred = array();
try {
if ($cleared = $this->versioningIsEnabled) {
$namespaceVersion = 2;
try {
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
$namespaceVersion = 1 + (int) $v;
}
} catch (\Exception $e) {
}
$namespaceVersion .= ':';
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
if ($cleared = true === $cleared || array() === $cleared) {
$this->namespaceVersion = $namespaceVersion;
if ($cleared = $this->versioningIsEnabled) {
$namespaceVersion = 2;
try {
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
$namespaceVersion = 1 + (int) $v;
}
} catch (\Exception $e) {
}
$namespaceVersion .= ':';
try {
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
} catch (\Exception $e) {
$cleared = false;
}
if ($cleared = true === $cleared || array() === $cleared) {
$this->namespaceVersion = $namespaceVersion;
}
}
try {
return $this->doClear($this->namespace) || $cleared;
} catch (\Exception $e) {
CacheItem::log($this->logger, 'Failed to clear the cache', array('exception' => $e));

View File

@ -60,7 +60,7 @@ class ExpressionLanguage
* @param Expression|string $expression The expression to compile
* @param array $values An array of values
*
* @return string The result of the evaluation of the expression
* @return mixed The result of the evaluation of the expression
*/
public function evaluate($expression, $values = array())
{

View File

@ -67,7 +67,7 @@ class ExceptionListener implements EventSubscriberInterface
}
}
$prev = new \ReflectionProperty('Exception', 'previous');
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
$prev->setAccessible(true);
$prev->setValue($wrapper, $exception);

View File

@ -79,12 +79,12 @@ class FlockStore implements StoreInterface
// Silence error reporting
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
if (!$handle = fopen($fileName, 'r')) {
if (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
if ($handle = fopen($fileName, 'x')) {
chmod($fileName, 0444);
} elseif (!$handle = fopen($fileName, 'r')) {
} elseif (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
usleep(100); // Give some time for chmod() to complete
$handle = fopen($fileName, 'r');
$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r');
}
}
restore_error_handler();