8000 Merge branch '4.3' into 4.4 · symfony/symfony@81ac674 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81ac674

Browse files
Merge branch '4.3' into 4.4
* 4.3: SCA: minor code tweaks [HttpClient] fallbackto CURLMOPT_MAXCONNECTS when CURLMOPT_MAX_HOST_CONNECTIONS is not available fixed typo [HttpKernel] Fix Apache mod_expires Session Cache-Control issue Fix getFileLinkFormat() to avoid returning the wrong URL in Profiler
2 parents 26954bc + 5a06f94 commit 81ac674

File tree

9 files changed

+21
-10
lines changed

9 files changed

+21
-10
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ protected function detectMetadataDriver($dir, ContainerBuilder $container)
257257
$configPath = $this->getMappingResourceConfigDirectory();
258258
$extension = $this->getMappingResourceExtension();
259259

260-
if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) {
260+
if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml', GLOB_NOSORT)) {
261261
$driver = 'xml';
262-
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) {
262+
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml', GLOB_NOSORT)) {
263263
$driver = 'yml';
264-
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) {
264+
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php', GLOB_NOSORT)) {
265265
$driver = 'php';
266266
} else {
267267
// add the closest existing directory as a resource

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,8 +1047,7 @@ private function getAbbreviationSuggestions(array $abbrevs): string
10471047
*/
10481048
public function extractNamespace($name, $limit = null)
10491049
{
1050-
$parts = explode(':', $name);
1051-
array_pop($parts);
1050+
$parts = explode(':', $name, -1);
10521051

10531052
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
10541053
}

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ public function __construct(array $defaultOptions = [], int $maxHostConnections
7373
curl_multi_setopt($this->multi->handle, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
7474
}
7575
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS')) {
76-
curl_multi_setopt($this->multi->handle, CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : PHP_INT_MAX);
76+
$maxHostConnections = curl_multi_setopt($this->multi->handle, CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : PHP_INT_MAX) ? 0 : $maxHostConnections;
77+
}
78+
if (\defined('CURLMOPT_MAXCONNECTS') && 0 < $maxHostConnections) {
79+
curl_multi_setopt($this->multi->handle, CURLMOPT_MAXCONNECTS, $maxHostConnections);
7780
}
7881

7982
// Skip configuring HTTP/2 push when it's unsupported or buggy, see https://bugs.php.net/77535

src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function getFileLinkFormat()
9696

9797
if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) {
9898
return [
99-
$request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat,
99+
$request->getSchemeAndHttpHost().$this->urlFormat,
100100
$this->baseDir.\DIRECTORY_SEPARATOR, '',
101101
];
102102
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function onKernelResponse(FilterResponseEvent $event)
8585
if ($session instanceof Session ? $session->getUsageIndex() !== end($this->sessionUsageStack) : $session->isStarted()) {
8686
if ($autoCacheControl) {
8787
$response
88+
->setExpires(new \DateTime())
8889
->setPrivate()
8990
->setMaxAge(0)
9091
->headers->addCacheControlDirective('must-revalidate');

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ protected function initializeContainer()
598598
static $legacyContainers = [];
599599
$oldContainerDir = \dirname($oldContainer->getFileName());
600600
$legacyContainers[$oldContainerDir.'.legacy'] = true;
601-
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) {
601+
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', GLOB_NOSORT) as $legacyContainer) {
602602
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
603603
(new Filesystem())->remove(substr($legacyContainer, 0, -7));
604604
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ public function testResponseIsPrivateIfSessionStarted()
8484
$response = new Response();
8585
$listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
8686

87+
$this->assertTrue($response->headers->has('Expires'));
8788
$this->assertTrue($response->headers->hasCacheControlDirective('private'));
8889
$this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
8990
$this->assertSame('0', $response->headers->getCacheControlDirective('max-age'));
91+
$this->assertLessThanOrEqual((new \DateTime('now', new \DateTimeZone('UTC'))), (new \DateTime($response->headers->get('Expires'))));
9092
$this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER));
9193
}
9294

@@ -110,6 +112,7 @@ public function testResponseIsStillPublicIfSessionStartedAndHeaderPresent()
110112
$listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
111113

112114
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
115+
$this->assertFalse($response->headers->has('Expires'));
113116
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
114117
$this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
115118
$this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage'));
@@ -129,6 +132,7 @@ public function testUninitializedSession()
129132

130133
$listener = new SessionListener($container);
131134
$listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
135+
$this->assertFalse($response->headers->has('Expires'));
132136
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
133137
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
134138
$this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
@@ -160,6 +164,7 @@ public function testSurrogateMasterRequestIsPublic()
160164
$listener->onKernelResponse(new ResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST, $response));
161165
$listener->onFinishRequest(new FinishRequestEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST));
162166

167+
$this->assertFalse($response->headers->has('Expires'));
163168
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
164169
$this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
165170
$this->assertSame('30', $response->headers->getCacheControlDirective('max-age'));
@@ -169,5 +174,8 @@ public function testSurrogateMasterRequestIsPublic()
169174
$this->assertTrue($response->headers->hasCacheControlDirective('private'));
170175
$this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
171176
$this->assertSame('0', $response->headers->getCacheControlDirective('max-age'));
177+
178+
$this->assertTrue($response->headers->has('Expires'));
179+
$this->assertLessThanOrEqual((new \DateTime('now', new \DateTimeZone('UTC'))), (new \DateTime($response->headers->get('Expires'))));
172180
}
173181
}

src/Symfony/Component/Intl/Data/Util/LocaleScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class LocaleScanner
4040
*/
4141
public function scanLocales(string $sourceDir): array
4242
{
43-
$locales = glob($sourceDir.'/*.txt');
43+
$locales = glob($sourceDir.'/*.txt', GLOB_NOSORT);
4444

4545
// Remove file extension and sort
4646
array_walk($locales, function (&$locale) { $locale = basename($locale, '.txt'); });

src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testConstructor()
2626
$b = new TextPart('content');
2727
$c = DataPart::fromPath($file = __DIR__.'/../../Fixtures/mimetypes/test.gif');
2828
$f = new FormDataPart([
29-
'foo' => $content = 'very very long content that will not be cut even if the length i way more than 76 characters, ok?',
29+
'foo' => $content = 'very very long content that will not be cut even if the length is way more than 76 characters, ok?',
3030
'bar' => clone $b,
3131
'baz' => clone $c,
3232
]);

0 commit comments

Comments
 (0)
0