Skip to content

Commit 4ce5a1b

Browse files
Merge branch '3.4' into 4.0
* 3.4: Add color support for Hyper terminal . [HttpFoundation] Fix tests: new message for status 425 [Doctrine Bridge] Fixed usage of wrong variable when tagged subscriber is invalid [PropertyInfo] added handling of nullable types in PhpDoc [HttpKernel] Make AbstractTestSessionListener compatible with CookieClearingLogoutHandler [Cache] provider does not respect option maxIdLength with versioning enabled
2 parents cfde207 + 771c22b commit 4ce5a1b

File tree

16 files changed

+127
-14
lines changed

16 files changed

+127
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
},
102102
"conflict": {
103103
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
104-
"phpdocumentor/type-resolver": "<0.2.1",
104+
"phpdocumentor/type-resolver": "<0.3.0",
105105
"phpunit/phpunit": "<5.4.3"
106106
},
107107
"provide": {

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function addTaggedSubscribers(ContainerBuilder $container)
6868
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
6969
foreach ($connections as $con) {
7070
if (!isset($this->connections[$con])) {
71-
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $taggedSubscriber, implode(', ', array_keys($this->connections))));
71+
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
7272
}
7373

7474
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', array(new Reference($id)));

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ private static function hasColorSupport()
316316
&& sapi_windows_vt100_support(STDOUT))
317317
|| false !== getenv('ANSICON')
318318
|| 'ON' === getenv('ConEmuANSI')
319-
|| 'xterm' === getenv('TERM');
319+
|| 'xterm' === getenv('TERM')
320+
|| 'Hyper' === getenv('TERM_PROGRAM');
320321
}
321322

322323
if (function_exists('stream_isatty')) {

src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,34 @@ public function testLongKey()
3434
$cache->hasItem(str_repeat('-', 39));
3535
}
3636

37+
public function testLongKeyVersioning()
38+
{
39+
$cache = $this->getMockBuilder(MaxIdLengthAdapter::class)
40+
->setConstructorArgs(array(str_repeat('-', 26)))
41+
->getMock();
42+
43+
$reflectionClass = new \ReflectionClass(AbstractAdapter::class);
44+
45+
$reflectionMethod = $reflectionClass->getMethod('getId');
46+
$reflectionMethod->setAccessible(true);
47+
48+
// No versioning enabled
49+
$this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12))));
50+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))));
51+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 23)))));
52+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 40)))));
53+
54+
$reflectionProperty = $reflectionClass->getProperty('versioningIsEnabled');
55+
$reflectionProperty->setAccessible(true);
56+
$reflectionProperty->setValue($cache, true);
57+
58+
// Versioning enabled
59+
$this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12))));
60+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))));
61+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 23)))));
62+
$this->assertLessThanOrEqual(50, strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 40)))));
63+
}
64+
3765
/**
3866
* @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException
3967
* @expectedExceptionMessage Namespace must be 26 chars max, 40 given ("----------------------------------------")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private function getId($key)
255255
return $this->namespace.$this->namespaceVersion.$key;
256256
}
257257
if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) {
258-
$id = $this->namespace.$this->namespaceVersion.substr_replace(base64_encode(hash('sha256', $key, true)), ':', -22);
258+
$id = $this->namespace.$this->namespaceVersion.substr_replace(base64_encode(hash('sha256', $key, true)), ':', -(\strlen($this->namespaceVersion) + 22));
259259
}
260260

261261
return $id;

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ protected function hasColorSupport()
9898
&& @sapi_windows_vt100_support($this->stream))
9999
|| false !== getenv('ANSICON')
100100
|| 'ON' === getenv('ConEmuANSI')
101-
|| 'xterm' === getenv('TERM');
101+
|| 'xterm' === getenv('TERM')
102+
|| 'Hyper' === getenv('TERM_PROGRAM');
102103
}
103104

104105
if (function_exists('stream_isatty')) {

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function createProgressBar($max = 0)
269269
{
270270
$progressBar = parent::createProgressBar($max);
271271

272-
if ('\\' !== DIRECTORY_SEPARATOR) {
272+
if ('\\' !== DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
273273
$progressBar->setEmptyBarCharacter(''); // light shade character \u2591
274274
$progressBar->setProgressCharacter('');
275275
$progressBar->setBarCharacter(''); // dark shade character \u2593

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ class Response
6464
const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
6565
const HTTP_LOCKED = 423; // RFC4918
6666
const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
67+
68+
/**
69+
* @deprecated
70+
*/
6771
const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817
72+
const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04
6873
const HTTP_UPGRADE_REQUIRED = 426; // RFC2817
6974
const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585
7075
const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585
@@ -169,7 +174,7 @@ class Response
169174
422 => 'Unprocessable Entity', // RFC4918
170175
423 => 'Locked', // RFC4918
171176
424 => 'Failed Dependency', // RFC4918
172-
425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817
177+
425 => 'Too Early', // RFC-ietf-httpbis-replay-04
173178
426 => 'Upgrade Required', // RFC2817
174179
428 => 'Precondition Required', // RFC6585
175180
429 => 'Too Many Requests', // RFC6585

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public function onKernelResponse(FilterResponseEvent $event)
7171

7272
if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) {
7373
$params = session_get_cookie_params();
74+
75+
foreach ($event->getResponse()->headers->getCookies() as $cookie) {
76+
if ($session->getName() === $cookie->getName() && $params['path'] === $cookie->getPath() && $params['domain'] == $cookie->getDomain()) {
77+
return;
78+
}
79+
}
80+
7481
$event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']));
7582
$this->sessionId = $session->getId();
7683
}

src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,36 @@ public function testEmptySessionWithNewSessionIdDoesSendCookie()
106106
$this->assertNotEmpty($response->headers->getCookies());
107107
}
108108

109+
/**
110+
* @dataProvider anotherCookieProvider
111+
*/
112+
public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie($existing, array $expected)
113+
{
114+
$this->sessionHasBeenStarted();
115+
$this->sessionIsEmpty();
116+
$this->fixSessionId('456');
117+
118+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
119+
$request = Request::create('/', 'GET', array(), array('MOCKSESSID' => '123'));
120+
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
121+
$this->listener->onKernelRequest($event);
122+
123+
$response = new Response('', 200, array('Set-Cookie' => $existing));
124+
125+
$response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
126+
127+
$this->assertSame($expected, $response->headers->get('Set-Cookie', null, false));
128+
}
129+
130+
public function anotherCookieProvider()
131+
{
132+
return array(
133+
'same' => array('MOCKSESSID=789; path=/', array('MOCKSESSID=789; path=/')),
134+
'different domain' => array('MOCKSESSID=789; path=/; domain=example.com', array('MOCKSESSID=789; path=/; domain=example.com', 'MOCKSESSID=456; path=/')),
135+
'different path' => array('MOCKSESSID=789; path=/foo', array('MOCKSESSID=789; path=/foo', 'MOCKSESSID=456; path=/')),
136+
);
137+
}
138+
109139
public function testUnstartedSessionIsNotSave()
110140
{
111141
$this->sessionHasNotBeenStarted();
@@ -123,10 +153,10 @@ public function testDoesNotImplementServiceSubscriberInterface()
123153
$this->assertFalse(is_subclass_of(TestSessionListener::class, ServiceSubscriberInterface::class, 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford'));
124154
}
125155

126-
private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
156+
private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, Response $response = null)
127157
{
128158
$request->setSession($this->session);
129-
$response = new Response();
159+
$response = $response ?: new Response();
130160
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
131161
$event = new FilterResponseEvent($kernel, $request, $type, $response);
132162

0 commit comments

Comments
 (0)