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 eb2cae6

Browse filesBrowse files
committed
Merge branch '5.3' into 5.4
* 5.3: [Filesystem] Workaround cannot dumpFile into "protected" folders on Windows Handle concurency in Csrf DoctrineTokenProvider Missing translations for Chinese (zh_CN) #41814 update Italian translation Fix SessionTokenStorage reuse with Request added missing Arabic translations
2 parents 45dee34 + 733c8e4 commit eb2cae6
Copy full SHA for eb2cae6

File tree

Expand file treeCollapse file tree

8 files changed

+96
-15
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+96
-15
lines changed

‎src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,15 @@ public function updateExistingToken(PersistentTokenInterface $token, string $tok
192192
return;
193193
}
194194

195-
$this->deleteTokenBySeries($tmpSeries);
196-
$this->createNewToken(new PersistentToken($token->getClass(), $token->getUserIdentifier(), $tmpSeries, $token->getTokenValue(), $lastUsed));
195+
$this->conn->beginTransaction();
196+
try {
197+
$this->deleteTokenBySeries($tmpSeries);
198+
$this->createNewToken(new PersistentToken($token->getClass(), $token->getUserIdentifier(), $tmpSeries, $token->getTokenValue(), $lastUsed));
199+
200+
$this->conn->commit();
201+
} catch (\Exception $e) {
202+
$this->conn->rollBack();
203+
}
197204
}
198205

199206
/**

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,6 @@ public function dumpFile(string $filename, $content)
669669
$this->mkdir($dir);
670670
}
671671

672-
if (!is_writable($dir)) {
673-
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
674-
}
675-
676672
// Will create a temp file with 0600 access rights
677673
// when the filesystem supports chmod.
678674
$tmpFile = $this->tempnam($dir, basename($filename));
@@ -711,10 +707,6 @@ public function appendToFile(string $filename, $content)
711707
$this->mkdir($dir);
712708
}
713709

714-
if (!is_writable($dir)) {
715-
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
716-
}
717-
718710
if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND)) {
719711
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
720712
}

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,27 @@ public function testCopyShouldKeepExecutionPermission()
17661766
$this->assertFilePermissions(767, $targetFilePath);
17671767
}
17681768

1769+
public function testDumpToProtectedDirectory()
1770+
{
1771+
if (\DIRECTORY_SEPARATOR !== '\\') {
1772+
$this->markTestSkipped('This test is specific to Windows.');
1773+
}
1774+
1775+
if (($userProfilePath = getenv('USERPROFILE')) === false || !is_dir($userProfilePath)) {
1776+
throw new \RuntimeException('Failed to retrieve user profile path.');
1777+
}
1778+
1779+
$targetPath = implode(\DIRECTORY_SEPARATOR, [$userProfilePath, 'Downloads', '__test_file.ext']);
1780+
1781+
try {
1782+
$this->assertFileDoesNotExist($targetPath);
1783+
$this->filesystem->dumpFile($targetPath, 'foobar');
1784+
$this->assertFileExists($targetPath);
1785+
} finally {
1786+
$this->filesystem->remove($targetPath);
1787+
}
1788+
}
1789+
17691790
/**
17701791
* Normalize the given path (transform each forward slash into a real directory separator).
17711792
*/

‎src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Csrf\Tests\TokenStorage;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\RequestStack;
1718
use Symfony\Component\HttpFoundation\Session\Session;
@@ -24,6 +25,8 @@
2425
*/
2526
class SessionTokenStorageTest extends TestCase
2627
{
28+
use ExpectDeprecationTrait;
29+
2730
private const SESSION_NAMESPACE = 'foobar';
2831

2932
/**
@@ -159,4 +162,50 @@ public function testClearDoesNotRemoveNonNamespacedSessionValues()
159162
$this->assertTrue($this->session->has('foo'));
160163
$this->assertSame('baz', $this->session->get('foo'));
161164
}
165+
166+
/**
167+
* @group legacy
168+
*/
169+
public function testMockSessionIsCreatedWhenMissing()
170+
{
171+
$this->expectDeprecation('Since symfony/security-csrf 5.3: Using the "Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage" without a session has no effect and is deprecated. It will throw a "Symfony\Component\HttpFoundation\Exception\SessionNotFoundException" in Symfony 6.0');
172+
173+
$this->storage->setToken('token_id', 'TOKEN');
174+
175+
$requestStack = new RequestStack();
176+
$storage = new SessionTokenStorage($requestStack, self::SESSION_NAMESPACE);
177+
178+
$this->assertFalse($storage->hasToken('foo'));
179+
$storage->setToken('foo', 'bar');
180+
$this->assertTrue($storage->hasToken('foo'));
181+
$this->assertSame('bar', $storage->getToken('foo'));
182+
183+
$session = new Session(new MockArraySessionStorage());
184+
$request = new Request();
185+
$request->setSession($session);
186+
$requestStack->push($request);
187+
}
188+
189+
/**
190+
* @group legacy
191+
*/
192+
public function testMockSessionIsReusedEvenWhenRequestHasSession()
193+
{
194+
$this->expectDeprecation('Since symfony/security-csrf 5.3: Using the "Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage" without a session has no effect and is deprecated. It will throw a "Symfony\Component\HttpFoundation\Exception\SessionNotFoundException" in Symfony 6.0');
195+
196+
$this->storage->setToken('token_id', 'TOKEN');
197+
198+
$requestStack = new RequestStack();
199+
$storage = new SessionTokenStorage($requestStack, self::SESSION_NAMESPACE);
200+
201+
$storage->setToken('foo', 'bar');
202+
$this->assertSame('bar', $storage->getToken('foo'));
203+
204+
$session = new Session(new MockArraySessionStorage());
205+
$request = new Request();
206+
$request->setSession($session);
207+
$requestStack->push($request);
208+
209+
$this->assertSame('bar', $storage->getToken('foo'));
210+
}
162211
}

‎src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SessionTokenStorage implements ClearableTokenStorageInterface
3434
private $requestStack;
3535
private $namespace;
3636
/**
37-
* Tp be remove in Symfony 6.0
37+
* To be removed in Symfony 6.0.
3838
*/
3939
private $session;
4040

@@ -130,7 +130,7 @@ public function clear()
130130
private function getSession(): SessionInterface
131131
{
132132
try {
133-
return $this->requestStack->getSession();
133+
return $this->session ?? $this->requestStack->getSession();
134134
} catch (SessionNotFoundException $e) {
135135
trigger_deprecation('symfony/security-csrf', '5.3', 'Using the "%s" without a session has no effect and is deprecated. It will throw a "%s" in Symfony 6.0', __CLASS__, SessionNotFoundException::class);
136136

‎src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@
386386
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
387387
<target> صالح (ISIN) هذه القيمة ليست رقم تعريف الأوراق المالية الدولي.</target>
388388
</trans-unit>
389+
<trans-unit id="100">
390+
<source>This value should be a valid expression.</source>
391+
<target>يجب أن تكون هذه القيمة تعبيرًا صالحًا.</target>
392+
</trans-unit>
389393
</body>
390394
</file>
391395
</xliff>

‎src/Symfony/Component/Validator/Resources/translations/validators.it.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.it.xlf
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@
386386
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
387387
<target>Questo valore non è un codice identificativo internazionale di valori mobiliari (ISIN) valido.</target>
388388
</trans-unit>
389+
<trans-unit id="100">
390+
<source>This value should be a valid expression.</source>
391+
<target>Questo valore dovrebbe essere un'espressione valida.</target>
392+
</trans-unit>
389393
</body>
390394
</file>
391395
</xliff>

‎src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,23 +368,27 @@
368368
</trans-unit>
369369
<trans-unit id="95">
370370
<source>This value is not a valid hostname.</source>
371-
<target>该数值不是有效的主机名称。</target>
371+
<target>该值不是有效的主机名称。</target>
372372
</trans-unit>
373373
<trans-unit id="96">
374374
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375375
<target>该集合内的元素数量得是 {{ compared_value }} 的倍数。</target>
376376
</trans-unit>
377377
<trans-unit id="97">
378378
<source>This value should satisfy at least one of the following constraints:</source>
379-
<target>该数值需符合以下其中一个约束:</target>
379+
<target>该值需符合以下其中一个约束:</target>
380380
</trans-unit>
381381
<trans-unit id="98">
382382
<source>Each element of this collection should satisfy its own set of constraints.</source>
383383
<target>该集合内的每个元素需符合元素本身规定的约束。</target>
384384
</trans-unit>
385385
<trans-unit id="99">
386386
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
387-
<target>该数值不是有效的国际证券识别码 (ISIN)。</target>
387+
<target>该值不是有效的国际证券识别码 (ISIN)。</target>
388+
</trans-unit>
389+
<trans-unit id="100">
390+
<source>This value should be a valid expression.</source>
391+
<target>该值需为一个有效的表达式。</target>
388392
</trans-unit>
389393
</body>
390394
</file>

0 commit comments

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