Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5cb3ee5

Browse filesBrowse files
Merge branch '6.0' into 6.1
* 6.0: [Notifier] composer.json cleanup [HttpKernel] AbstractSessionListener should not override the cache lifetime for private responses [DependencyInjection] Shared private services becomes public after a public service is accessed [DI] Fix undefined class in test
2 parents 295dcc7 + 34f2413 commit 5cb3ee5
Copy full SHA for 5cb3ee5

File tree

Expand file treeCollapse file tree

18 files changed

+149
-98
lines changed
Filter options
Expand file treeCollapse file tree

18 files changed

+149
-98
lines changed

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ public function has(string $id): bool
505505
*/
506506
public function get(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): ?object
507507
{
508-
if ($this->isCompiled() && isset($this->removedIds[$id]) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $invalidBehavior) {
509-
return parent::get($id);
508+
if ($this->isCompiled() && isset($this->removedIds[$id])) {
509+
return ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $invalidBehavior ? parent::get($id) : null;
510510
}
511511

512512
return $this->doGet($id, $invalidBehavior);
@@ -523,9 +523,9 @@ private function doGet(string $id, int $invalidBehavior = ContainerInterface::EX
523523
}
524524
try {
525525
if (ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $invalidBehavior) {
526-
return parent::get($id, $invalidBehavior);
526+
return $this->privates[$id] ?? parent::get($id, $invalidBehavior);
527527
}
528-
if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
528+
if (null !== $service = $this->privates[$id] ?? parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
529529
return $service;
530530
}
531531
} catch (ServiceCircularReferenceException $e) {
@@ -1025,8 +1025,8 @@ private function createService(Definition $definition, array &$inlineServices, b
10251025

10261026
$arguments = $this->doResolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($arguments)), $inlineServices, $isConstructorArgument);
10271027

1028-
if (null !== $id && $definition->isShared() && isset($this->services[$id]) && ($tryProxy || !$definition->isLazy())) {
1029-
return $this->services[$id];
1028+
if (null !== $id && $definition->isShared() && (isset($this->services[$id]) || isset($this->privates[$id])) && ($tryProxy || !$definition->isLazy())) {
1029+
return $this->services[$id] ?? $this->privates[$id];
10301030
}
10311031

10321032
if (null !== $factory) {
@@ -1580,7 +1580,11 @@ private function shareService(Definition $definition, mixed $service, ?string $i
15801580
$inlineServices[$id ?? spl_object_hash($definition)] = $service;
15811581

15821582
if (null !== $id && $definition->isShared()) {
1583-
$this->services[$id] = $service;
1583+
if ($definition->isPrivate() && $this->isCompiled()) {
1584+
$this->privates[$id] = $service;
1585+
} else {
1586+
$this->services[$id] = $service;
1587+
}
15841588
unset($this->loading[$id]);
15851589
}
15861590
}

‎src/Symfony/Component/DependencyInjection/ReverseContainer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ReverseContainer.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ public function getId(object $service): ?string
6363
*/
6464
public function getService(string $id): object
6565
{
66-
if ($this->serviceContainer->has($id)) {
67-
return $this->serviceContainer->get($id);
68-
}
69-
7066
if ($this->reversibleLocator->has($id)) {
7167
return $this->reversibleLocator->get($id);
7268
}
@@ -75,7 +71,6 @@ public function getService(string $id): object
7571
throw new ServiceNotFoundException($id, null, null, [], sprintf('The "%s" service is private and cannot be accessed by reference. You should either make it public, or tag it as "%s".', $id, $this->tagName));
7672
}
7773

78-
// will throw a ServiceNotFoundException
79-
$this->serviceContainer->get($id);
74+
return $this->serviceContainer->get($id);
8075
}
8176
}

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,19 @@ public function testIndexedByServiceIdWithDecoration()
184184

185185
$container->setDefinition(Service::class, $service);
186186

187-
$decorated = new Definition(Decorated::class);
187+
$decorated = new Definition(DecoratedService::class);
188188
$decorated->setPublic(true);
189189
$decorated->setDecoratedService(Service::class);
190190

191-
$container->setDefinition(Decorated::class, $decorated);
191+
$container->setDefinition(DecoratedService::class, $decorated);
192192

193193
$container->compile();
194194

195195
/** @var ServiceLocator $locator */
196196
$locator = $container->get(Locator::class)->locator;
197197
static::assertTrue($locator->has(Service::class));
198-
static::assertFalse($locator->has(Decorated::class));
199-
static::assertInstanceOf(Decorated::class, $locator->get(Service::class));
198+
static::assertFalse($locator->has(DecoratedService::class));
199+
static::assertInstanceOf(DecoratedService::class, $locator->get(Service::class));
200200
}
201201

202202
public function testDefinitionOrderIsTheSame()

‎src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,10 +1079,19 @@ public function testPrivateServiceUser()
10791079
$container->addDefinitions([
10801080
'bar' => $fooDefinition,
10811081
'bar_user' => $fooUserDefinition->setPublic(true),
1082+
'bar_user2' => $fooUserDefinition->setPublic(true),
10821083
]);
10831084

10841085
$container->compile();
1086+
$this->assertNull($container->get('bar', $container::NULL_ON_INVALID_REFERENCE));
10851087
$this->assertInstanceOf(\BarClass::class, $container->get('bar_user')->bar);
1088+
1089+
// Ensure that accessing a public service with a shared private service
1090+
// does not make the private service available.
1091+
$this->assertNull($container->get('bar', $container::NULL_ON_INVALID_REFERENCE));
1092+
1093+
// Ensure the private service is still shared.
1094+
$this->assertSame($container->get('bar_user')->bar, $container->get('bar_user2')->bar);
10861095
}
10871096

10881097
public function testThrowsExceptionWhenSetServiceOnACompiledContainer()

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ public function onKernelResponse(ResponseEvent $event)
195195
}
196196

197197
if ($autoCacheControl) {
198+
$maxAge = $response->headers->hasCacheControlDirective('public') ? 0 : (int) $response->getMaxAge();
198199
$response
199-
->setExpires(new \DateTime())
200+
->setExpires(new \DateTimeImmutable('+'.$maxAge.' seconds'))
200201
->setPrivate()
201-
->setMaxAge(0)
202+
->setMaxAge($maxAge)
202203
->headers->addCacheControlDirective('must-revalidate');
203204
}
204205

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SessionListenerTest extends TestCase
3838
{
3939
/**
4040
* @dataProvider provideSessionOptions
41+
*
4142
* @runInSeparateProcess
4243
*/
4344
public function testSessionCookieOptions(array $phpSessionOptions, array $sessionOptions, array $expectedSessionOptions)
@@ -554,6 +555,64 @@ public function testUninitializedSessionWithoutInitializedSession()
554555
$this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage'));
555556
}
556557

558+
public function testResponseHeadersMaxAgeAndExpiresNotBeOverridenIfSessionStarted()
559+
{
560+
$session = $this->createMock(Session::class);
561+
$session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1));
562+
563+
$container = new Container();
564+
$container->set('initialized_session', $session);
565+
566+
$listener = new SessionListener($container);
567+
$kernel = $this->createMock(HttpKernelInterface::class);
568+
569+
$request = new Request();
570+
$listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST));
571+
572+
$response = new Response();
573+
$response->setPrivate();
574+
$expiresHeader = gmdate('D, d M Y H:i:s', time() + 600).' GMT';
575+
$response->setMaxAge(600);
576+
$listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response));
577+
578+
$this->assertTrue($response->headers->has('expires'));
579+
$this->assertSame($expiresHeader, $response->headers->get('expires'));
580+
$this->assertFalse($response->headers->has('max-age'));
581+
$this->assertSame('600', $response->headers->getCacheControlDirective('max-age'));
582+
$this->assertFalse($response->headers->hasCacheControlDirective('public'));
583+
$this->assertTrue($response->headers->hasCacheControlDirective('private'));
584+
$this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
585+
$this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER));
586+
}
587+
588+
public function testResponseHeadersMaxAgeAndExpiresDefaultValuesIfSessionStarted()
589+
{
590+
$session = $this->createMock(Session::class);
591+
$session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1));
592+
593+
$container = new Container();
594+
$container->set('initialized_session', $session);
595+
596+
$listener = new SessionListener($container);
597+
$kernel = $this->createMock(HttpKernelInterface::class);
598+
599+
$request = new Request();
600+
$listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST));
601+
602+
$response = new Response();
603+
$expiresHeader = gmdate('D, d M Y H:i:s', time()).' GMT';
604+
$listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response));
605+
606+
$this->assertTrue($response->headers->has('expires'));
607+
$this->assertSame($expiresHeader, $response->headers->get('expires'));
608+
$this->assertFalse($response->headers->has('max-age'));
609+
$this->assertSame('0', $response->headers->getCacheControlDirective('max-age'));
610+
$this->assertFalse($response->headers->hasCacheControlDirective('public'));
611+
$this->assertTrue($response->headers->hasCacheControlDirective('private'));
612+
$this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
613+
$this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER));
614+
}
615+
557616
public function testSurrogateMainRequestIsPublic()
558617
{
559618
$session = $this->createMock(Session::class);

‎src/Symfony/Component/Notifier/Bridge/Clickatell/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Clickatell/composer.json
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
"symfony/http-client": "^5.4|^6.0",
2525
"symfony/notifier": "^5.4|^6.0"
2626
},
27-
"require-dev": {
28-
"symfony/event-dispatcher": "^5.4|^6.0"
29-
},
3027
"autoload": {
3128
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Clickatell\\": "" },
3229
"exclude-from-classmap": [

‎src/Symfony/Component/Notifier/Bridge/Discord/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Discord/composer.json
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
"symfony/notifier": "^5.4|^6.0",
2222
"symfony/polyfill-mbstring": "^1.0"
2323
},
24-
"require-dev": {
25-
"symfony/event-dispatcher": "^5.4|^6.0"
26-
},
2724
"autoload": {
2825
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Discord\\": "" },
2926
"exclude-from-classmap": [

‎src/Symfony/Component/Notifier/Bridge/Engagespot/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Engagespot/composer.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.2.5",
20-
"symfony/http-client": "^4.3|^5.0|^6.0",
19+
"php": ">=8.1",
20+
"symfony/http-client": "^5.4|^6.0",
2121
"symfony/notifier": "^5.4|^6.0"
2222
},
2323
"autoload": {

‎src/Symfony/Component/Notifier/Bridge/FakeChat/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/FakeChat/composer.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"php": ">=8.1",
2525
"symfony/http-client": "^5.4|^6.0",
2626
"symfony/notifier": "^5.4|^6.0",
27-
"symfony/event-dispatcher-contracts": "^2|^3",
2827
"symfony/mailer": "^5.4|^6.0"
2928
},
3029
"autoload": {

‎src/Symfony/Component/Notifier/Bridge/FakeSms/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/FakeSms/composer.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"php": ">=8.1",
2525
"symfony/http-client": "^5.4|^6.0",
2626
"symfony/notifier": "^5.4|^6.0",
27-
"symfony/event-dispatcher-contracts": "^2|^3",
2827
"symfony/mailer": "^5.4|^6.0"
2928
},
3029
"autoload": {
+29-29Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"name": "symfony/kaz-info-teh-notifier",
3-
"type": "symfony-bridge",
4-
"description": "Symfony KazInfoTeh Notifier Bridge",
5-
"keywords": ["KazInfoTeh", "notifier", "symfony", "sms"],
6-
"homepage": "https://symfony.com",
7-
"license": "MIT",
8-
"authors": [
9-
{
10-
"name": "Egor Taranov",
11-
"email": "dev@taranovegor.com",
12-
"homepage": "https://taranovegor.com/contribution"
2+
"name": "symfony/kaz-info-teh-notifier",
3+
"type": "symfony-bridge",
4+
"description": "Symfony KazInfoTeh Notifier Bridge",
5+
"keywords": ["KazInfoTeh", "notifier", "symfony", "sms"],
6+
"homepage": "https://symfony.com",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Egor Taranov",
11+
"email": "dev@taranovegor.com",
12+
"homepage": "https://taranovegor.com/contribution"
13+
},
14+
{
15+
"name": "Symfony Community",
16+
"homepage": "https://symfony.com/contributors"
17+
}
18+
],
19+
"require": {
20+
"php": ">=8.1",
21+
"ext-simplexml": "*",
22+
"symfony/http-client": "^5.4|^6.0",
23+
"symfony/notifier": "^5.4|^6.0"
1324
},
14-
{
15-
"name": "Symfony Community",
16-
"homepage": "https://symfony.com/contributors"
17-
}
18-
],
19-
"require": {
20-
"php": ">=8.1",
21-
"ext-simplexml": "*",
22-
"symfony/http-client": "^5.4|^6.0",
23-
"symfony/notifier": "^5.4|^6.0"
24-
},
25-
"autoload": {
26-
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\KazInfoTeh\\": "" },
27-
"exclude-from-classmap": [
28-
"/Tests/"
29-
]
30-
},
31-
"minimum-stability": "dev"
25+
"autoload": {
26+
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\KazInfoTeh\\": "" },
27+
"exclude-from-classmap": [
28+
"/Tests/"
29+
]
30+
},
31+
"minimum-stability": "dev"
3232
}
+27-27Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
{
2-
"name": "symfony/message-media-notifier",
3-
"type": "symfony-notifier-bridge",
4-
"description": "Symfony MessageMedia Notifier Bridge",
5-
"keywords": ["sms", "messagemedia", "notifier"],
6-
"homepage": "https://symfony.com",
7-
"license": "MIT",
8-
"authors": [
9-
{
10-
"name": "Adrian Nguyen",
11-
"email": "vuphuong87@gmail.com"
2+
"name": "symfony/message-media-notifier",
3+
"type": "symfony-notifier-bridge",
4+
"description": "Symfony MessageMedia Notifier Bridge",
5+
"keywords": ["sms", "messagemedia", "notifier"],
6+
"homepage": "https://symfony.com",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Adrian Nguyen",
11+
"email": "vuphuong87@gmail.com"
12+
},
13+
{
14+
"name": "Symfony Community",
15+
"homepage": "https://symfony.com/contributors"
16+
}
17+
],
18+
"require": {
19+
"php": ">=8.1",
20+
"symfony/http-client": "^5.4|^6.0",
21+
"symfony/notifier": "^5.4|^6.0"
1222
},
13-
{
14-
"name": "Symfony Community",
15-
"homepage": "https://symfony.com/contributors"
16-
}
17-
],
18-
"require": {
19-
"php": ">=8.1",
20-
"symfony/http-client": "^5.4|^6.0",
21-
"symfony/notifier": "^5.4|^6.0"
22-
},
23-
"autoload": {
24-
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\MessageMedia\\": "" },
25-
"exclude-from-classmap": [
26-
"/Tests/"
27-
]
28-
},
29-
"minimum-stability": "dev"
23+
"autoload": {
24+
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\MessageMedia\\": "" },
25+
"exclude-from-classmap": [
26+
"/Tests/"
27+
]
28+
},
29+
"minimum-stability": "dev"
3030
}

‎src/Symfony/Component/Notifier/Bridge/OneSignal/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/OneSignal/composer.json
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
"symfony/http-client": "^5.4|^6.0",
2121
"symfony/notifier": "^5.4|^6.0"
2222
},
23-
"require-dev": {
24-
"symfony/event-dispatcher": "^5.4|^6.0"
25-
},
2623
"autoload": {
2724
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\OneSignal\\": "" },
2825
"exclude-from-classmap": [

‎src/Symfony/Component/Notifier/Bridge/Sendberry/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Sendberry/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=8.0.2",
19+
"php": ">=8.1",
2020
"symfony/http-client": "^5.4|^6.0",
2121
"symfony/notifier": "^5.4|^6.0"
2222
},

‎src/Symfony/Component/Notifier/Bridge/Slack/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Slack/composer.json
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
"symfony/http-client": "^5.4|^6.0",
2121
"symfony/notifier": "^5.4|^6.0"
2222
},
23-
"require-dev": {
24-
"symfony/event-dispatcher": "^5.4|^6.0"
25-
},
2623
"autoload": {
2724
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Slack\\": "" },
2825
"exclude-from-classmap": [

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.