8000 Merge branch '4.1' · symfony/symfony@31fc855 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31fc855

Browse files
Merge branch '4.1'
* 4.1: [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 Ignore keepQueryParams attribute when generating route redirect. [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 92c37b9 + f833167 commit 31fc855

File tree

6 files changed

+33
-28
lines changed

6 files changed

+33
-28
lines changed

src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function redirectAction(Request $request, string $route, bool $permanent
6464
if (false === $ignoreAttributes || is_array($ignoreAttributes)) {
6565
$attributes = $request->attributes->get('_route_params');
6666
$attributes = $keepQ 10000 ueryParams ? array_merge($request->query->all(), $attributes) : $attributes;
67-
unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes'], $attributes['keepRequestMethod']);
67+
unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes'], $attributes['keepRequestMethod'], $attributes['keepQueryParams']);
6868
if ($ignoreAttributes) {
6969
$attributes = array_diff_key($attributes, array_flip($ignoreAttributes));
7070
}

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testEmptyRoute()
4747
/**
4848
* @dataProvider provider
4949
*/
50-
public function testRoute($permanent, $keepRequestMethod, $ignoreAttributes, $expectedCode, $expectedAttributes)
50+
public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ignoreAttributes, $expectedCode, $expectedAttributes)
5151
{
5252
$request = new Request();
5353

@@ -63,6 +63,7 @@ public function testRoute($permanent, $keepRequestMethod, $ignoreAttributes, $ex
6363
'additional-parameter' => 'value',
6464
'ignoreAttributes' => $ignoreAttributes,
6565
'keepRequestMethod' => $keepRequestMethod,
66+
'keepQueryParams' => $keepQueryParams,
6667
),
6768
);
6869

@@ -77,7 +78,7 @@ public function testRoute($permanent, $keepRequestMethod, $ignoreAttributes, $ex
7778

7879
$controller = new RedirectController($router);
7980

80-
$returnResponse = $controller->redirectAction($request, $route, $permanent, $ignoreAttributes, $keepRequestMethod);
81+
$returnResponse = $controller->redirectAction($request, $route, $permanent, $ignoreAttributes, $keepRequestMethod, $keepQueryParams);
8182

8283
$this->assertRedirectUrl($returnResponse, $url);
8384
$this->assertEquals($expectedCode, $returnResponse->getStatusCode());
@@ -86,14 +87,14 @@ public function testRoute($permanent, $keepRequestMethod, $ignoreAttributes, $ex
8687
public function provider()
8788
{
8889
return array(
89-
array(true, false, false, 301, array('additional-parameter' => 'value')),
90-
array(false, false, false, 302, array('additional-parameter' => 'value')),
91-
array(false, false, true, 302, array()),
92-
array(false, false, array('additional-parameter'), 302, array()),
93-
array(true, true, false, 308, array('additional-parameter' => 'value')),
94-
array(false, true, false, 307, array('additional-parameter' => 'value')),
95-
array(false, true, true, 307, array()),
96-
array(false, true, array('additional-parameter'), 307, array()),
90+
array(true, false, false, false, 301, array('additional-parameter' => 'value')),
91+
array(false, false, false, false, 302, array('additional-parameter' => 'value')),
92+
array(false, false, false, true, 302, array()),
93+
array(false, false, false, array('additional-parameter'), 302, array()),
94+
array(true, true, false, false, 308, array('additional-parameter' => 'value')),
95+
array(false, true, false, false, 307, array('additional-parameter' => 'value')),
96+
array(false, true, false, true, 307, array()),
97+
array(false, true, true, array('additional-parameter'), 307, array()),
9798
);
9899
}
99100

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

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

128+
try {
125129
return $this->doClear($this->namespace) || $cleared;
126130
} catch (\Exception $e) {
127131
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
@@ -67,7 +67,7 @@ public function onKernelException(GetResponseForExceptionEvent $event)
6767
}
6868
}
6969

70-
$prev = new \ReflectionProperty('Exception', 'previous');
70+
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
7171
$prev->setAccessible(true);
7272
$prev->setValue($wrapper, $exception);
7373

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