From c8bdcb3408e1408ca6657a81d9cf7cad375d19c4 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Fri, 10 Jan 2020 22:32:00 +0000 Subject: [PATCH 1/6] Fix that no-cache requires positive validation with the origin, even for fresh responses --- .../Component/HttpKernel/HttpCache/HttpCache.php | 4 ++++ .../HttpKernel/Tests/HttpCache/HttpCacheTest.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index dbe0280659..da60e74642 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -323,6 +323,10 @@ class HttpCache implements HttpKernelInterface, TerminableInterface return $this->validate($request, $entry, $catch); } + if ($entry->headers->hasCacheControlDirective('no-cache')) { + return $this->validate($request, $entry, $catch); + } + $this->record($request, 'fresh'); $entry->headers->set('Age', $entry->getAge()); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index a4e30444a5..ef201de6cf 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -443,6 +443,22 @@ class HttpCacheTest extends HttpCacheTestCase $this->assertTrue($this->response->headers->has('Age')); } + public function testRevalidatesResponsesWithNoCacheDirectiveEvenIfFresh() + { + $this->setNextResponse(200, ['Cache-Control' => 'public, no-cache, max-age=10', 'ETag' => 'some-etag'], 'OK'); + $this->request('GET', '/'); // warm the cache + + sleep(5); + + $this->setNextResponse(304, ['Cache-Control' => 'public, no-cache, max-age=10', 'ETag' => 'some-etag']); + $this->request('GET', '/'); + + $this->assertHttpKernelIsCalled(); // no-cache -> MUST have revalidated at origin + $this->assertTraceContains('valid'); + $this->assertEquals('OK', $this->response->getContent()); + $this->assertEquals(0, $this->response->getAge()); + } + public function testCachesResponsesWithAnExpirationHeader() { $time = \DateTime::createFromFormat('U', time() + 5); From 45461c73bf78431c4f61933a92eee1422351f522 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 13 Jan 2020 09:00:59 +0100 Subject: [PATCH 2/6] fix PHP const mapping keys using the inline notation --- src/Symfony/Component/Yaml/Inline.php | 5 +++++ src/Symfony/Component/Yaml/Tests/InlineTest.php | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index aef68c7b2f..73aba3cb8b 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -504,6 +504,11 @@ class Inline $isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true); $key = self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true); + if ('!php/const' === $key) { + $key .= self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true); + $key = self::evaluateScalar($key, $flags); + } + if (':' !== $key && false === $i = strpos($mapping, ':', $i)) { break; } diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 3f3b913f7b..54372d6950 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -58,6 +58,7 @@ class InlineTest extends TestCase ['!php/const PHP_INT_MAX', PHP_INT_MAX], ['[!php/const PHP_INT_MAX]', [PHP_INT_MAX]], ['{ foo: !php/const PHP_INT_MAX }', ['foo' => PHP_INT_MAX]], + ['{ !php/const PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']], ['!php/const NULL', null], ]; } @@ -93,6 +94,7 @@ class InlineTest extends TestCase ['!php/const:PHP_INT_MAX', PHP_INT_MAX], ['[!php/const:PHP_INT_MAX]', [PHP_INT_MAX]], ['{ foo: !php/const:PHP_INT_MAX }', ['foo' => PHP_INT_MAX]], + ['{ !php/const:PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']], ['!php/const:NULL', null], ]; } From fb48bbc05be5533a930bd31d211287a8f234bf78 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 2 Jan 2020 19:17:31 +0100 Subject: [PATCH 3/6] [PhpUnitBridge][SymfonyTestsListenerTrait] Remove some unneeded code --- .../PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 4591f67ed5..54c15b67ce 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -37,7 +37,6 @@ class SymfonyTestsListenerTrait private $gatheredDeprecations = array(); private $previousErrorHandler; private $testsWithWarnings; - private $reportUselessTests; private $error; private $runsInSeparateProcess = false; @@ -198,10 +197,6 @@ class SymfonyTestsListenerTrait public function startTest($test) { if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { - if (null !== $test->getTestResultObject()) { - $this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything(); - } - // This event is triggered before the test is re-run in isolation if ($this->willBeIsolated($test)) { $this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec'); @@ -267,11 +262,6 @@ class SymfonyTestsListenerTrait $classGroups = $Test::getGroups($className); $groups = $Test::getGroups($className, $test->getName(false)); - if (null !== $this->reportUselessTests) { - $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests); - $this->reportUselessTests = null; - } - if ($errored = null !== $this->error) { $test->getTestResultObject()->addError($test, $this->error, 0); $this->error = null; From 207cdafd546d5f11e7fc425984934e2211a697f1 Mon Sep 17 00:00:00 2001 From: knezmilos13 Date: Tue, 14 Jan 2020 19:27:07 +0100 Subject: [PATCH 4/6] [Validator] Fix plurals for sr_Latn (Serbian language written in latin script) validation messages --- .../translations/validators.sr_Latn.xlf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf index 018dd1233a..20dff43c6d 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf @@ -24,11 +24,11 @@ You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Morate odabrati bar {{ limit }} mogućnost.|Morate odabrati bar {{ limit }} mogućnosti. + Morate odabrati bar {{ limit }} mogućnost.|Morate odabrati bar {{ limit }} mogućnosti.|Morate odabrati bar {{ limit }} mogućnosti. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Morate odabrati najviše {{ limit }} mogućnost.|Morate odabrati najviše {{ limit }} mogućnosti. + Morate odabrati najviše {{ limit }} mogućnost.|Morate odabrati najviše {{ limit }} mogućnosti.|Morate odabrati najviše {{ limit }} mogućnosti. One or more of the given values is invalid. @@ -76,7 +76,7 @@ This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Vrednost je predugačka. Trebalo bi da ima {{ limit }} karakter ili manje.|Vrednost je predugačka. Trebalo bi da ima {{ limit }} karaktera ili manje. + Vrednost je predugačka. Trebalo bi da ima {{ limit }} karakter ili manje.|Vrednost je predugačka. Trebalo bi da ima {{ limit }} karaktera ili manje.|Vrednost je predugačka. Trebalo bi da ima {{ limit }} karaktera ili manje. This value should be {{ limit }} or more. @@ -84,7 +84,7 @@ This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Vrednost je prekratka. Trebalo bi da ima {{ limit }} karakter ili više.|Vrednost je prekratka. Trebalo bi da ima {{ limit }} karaktera ili više. + Vrednost je prekratka. Trebalo bi da ima {{ limit }} karakter ili više.|Vrednost je prekratka. Trebalo bi da ima {{ limit }} karaktera ili više.|Vrednost je prekratka. Trebalo bi da ima {{ limit }} karaktera ili više. This value should not be blank. @@ -180,7 +180,7 @@ This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Vrednost bi trebalo da ima tačno {{ limit }} karakter.|Vrednost bi trebalo da ima tačno {{ limit }} karaktera. + Vrednost bi trebalo da ima tačno {{ limit }} karakter.|Vrednost bi trebalo da ima tačno {{ limit }} karaktera.|Vrednost bi trebalo da ima tačno {{ limit }} karaktera. The file was only partially uploaded. @@ -204,15 +204,15 @@ This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - Ova kolekcija bi trebalo da sadrži {{ limit }} ili više elemenata.|Ova kolekcija bi trebalo da sadrži {{ limit }} ili više elemenata. + Ova kolekcija bi trebalo da sadrži {{ limit }} ili više elemenata.|Ova kolekcija bi trebalo da sadrži {{ limit }} ili više elemenata.|Ova kolekcija bi trebalo da sadrži {{ limit }} ili više elemenata. This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - Ova kolekcija bi trebalo da sadrži {{ limit }} ili manje elemenata.|Ova kolekcija bi trebalo da sadrži {{ limit }} ili manje elemenata. + Ova kolekcija bi trebalo da sadrži {{ limit }} ili manje elemenata.|Ova kolekcija bi trebalo da sadrži {{ limit }} ili manje elemenata.|Ova kolekcija bi trebalo da sadrži {{ limit }} ili manje elemenata. This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - Ova kolekcija bi trebalo da sadrži tačno {{ limit }} element.|Ova kolekcija bi trebalo da sadrži tačno {{ limit }} elemenata. + Ova kolekcija bi trebalo da sadrži tačno {{ limit }} element.|Ova kolekcija bi trebalo da sadrži tačno {{ limit }} elementa.|Ova kolekcija bi trebalo da sadrži tačno {{ limit }} elemenata. Invalid card number. From 820eb357c8afaf0d3868f9b778459dc644ff2804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 14 Jan 2020 22:28:32 +0100 Subject: [PATCH 5/6] Fix RememberMe with null password --- .../RememberMe/TokenBasedRememberMeServices.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php index afa12e4f03..3df2ced622 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php @@ -89,10 +89,10 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices /** * Generates the cookie value. * - * @param string $class - * @param string $username The username - * @param int $expires The Unix timestamp when the cookie expires - * @param string $password The encoded password + * @param string $class + * @param string $username The username + * @param int $expires The Unix timestamp when the cookie expires + * @param string|null $password The encoded password * * @return string */ @@ -111,10 +111,10 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices /** * Generates a hash for the cookie to ensure it is not being tampered with. * - * @param string $class - * @param string $username The username - * @param int $expires The Unix timestamp when the cookie expires - * @param string $password The encoded password + * @param string $class + * @param string $username The username + * @param int $expires The Unix timestamp when the cookie expires + * @param string|null $password The encoded password * * @return string */ From 6b811e6b4c7c43be27b62141e2ee970ada660d69 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 16 Jan 2020 10:18:18 +0100 Subject: [PATCH 6/6] chown and chgrp should also accept int as owner and group --- src/Symfony/Component/Filesystem/Filesystem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index cd456c7848..7d7301c3a1 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -211,7 +211,7 @@ class Filesystem * Change the owner of an array of files or directories. * * @param string|iterable $files A filename, an array of files, or a \Traversable instance to change owner - * @param string $user The new owner user name + * @param string|int $user A user name or number * @param bool $recursive Whether change the owner recursively or not * * @throws IOException When the change fails @@ -238,7 +238,7 @@ class Filesystem * Change the group of an array of files or directories. * * @param string|iterable $files A filename, an array of files, or a \Traversable instance to change group - * @param string $group The group name + * @param string|int $group A group name or number * @param bool $recursive Whether change the group recursively or not * * @throws IOException When the change fails