Skip to content

Commit ec8118e

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: [HttpClient] Don't ignore errors from curl_multi_exec() [HttpClient] Double check if handle is complete CI for macOS [DependencyInjection] Resolve ChildDefinition in AbstractRecursivePass [Translation] [Bridge] [Lokalise] Fix push keys to lokalise. Closes #… [PropertyAccess] Fix accessing public property in Object [Process] fixed uppercase ARGC and ARGV should also be skipped [PropertyAccess] Add tests accessing public (dynamic) properties [Mailer] Update docs for sendmail -t [FrameworkBundle] Fix cache pool configuration with one adapter and one provider [FrameworkBundle] Use correct cookie domain in loginUser() Missing translations for Belarusian (be) #41032
2 parents eb09957 + c22492b commit ec8118e

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,13 +1084,14 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
10841084
->prototype('array')
10851085
->fixXmlConfig('adapter')
10861086
->beforeNormalization()
1087-
->ifTrue(function ($v) { return (isset($v['adapters']) || \is_array($v['adapter'] ?? null)) && isset($v['provider']); })
1088-
->thenInvalid('Pool cannot have a "provider" while "adapter" is set to a map')
1087+
->ifTrue(function ($v) { return isset($v['provider']) && \is_array($v['adapters'] ?? $v['adapter'] ?? null) && 1 < \count($v['adapters'] ?? $v['adapter']); })
1088+
->thenInvalid('Pool cannot have a "provider" while more than one adapter is defined')
10891089
->end()
10901090
->children()
10911091
->arrayNode('adapters')
10921092
->performNoDeepMerging()
10931093
->info('One or more adapters to chain for creating the pool, defaults to "cache.app".')
1094+
->beforeNormalization()->castToArray()->end()
10941095
->beforeNormalization()
10951096
->always()->then(function ($values) {
10961097
if ([0] === array_keys($values) && \is_array($values[0])) {

KernelBrowser.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,13 @@ public function loginUser(object $user, string $firewallContext = 'main'): self
144144
$session->set('_security_'.$firewallContext, serialize($token));
145145
$session->save();
146146

147-
$cookie = new Cookie($session->getName(), $session->getId());
148-
$this->getCookieJar()->set($cookie);
147+
$domains = array_unique(array_map(function (Cookie $cookie) use ($session) {
148+
return $cookie->getName() === $session->getName() ? $cookie->getDomain() : '';
149+
}, $this->getCookieJar()->all())) ?: [''];
150+
foreach ($domains as $domain) {
151+
$cookie = new Cookie($session->getName(), $session->getId(), null, null, $domain);
152+
$this->getCookieJar()->set($cookie);
153+
}
149154

150155
return $this;
151156
}

Tests/Functional/SecurityTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,20 @@ public function testLoginInBetweenRequests()
7070
$client->request('GET', '/main/user_profile');
7171
$this->assertEquals('Welcome the-username!', $client->getResponse()->getContent());
7272
}
73+
74+
public function testLoginUserMultipleTimes()
75+
{
76+
$userFoo = new InMemoryUser('the-username', 'the-password', ['ROLE_FOO']);
77+
$userBar = new InMemoryUser('no-role-username', 'the-password');
78+
$client = $this->createClient(['test_case' => 'Security', 'root_config' => 'config.yml']);
79+
$client->loginUser($userFoo);
80+
81+
$client->request('GET', '/main/user_profile');
82+
$this->assertEquals('Welcome the-username!', $client->getResponse()->getContent());
83+
84+
$client->loginUser($userBar);
85+
86+
$client->request('GET', '/main/user_profile');
87+
$this->assertEquals('Welcome no-role-username!', $client->getResponse()->getContent());
88+
}
7389
}

0 commit comments

Comments
 (0)