Skip to content

Commit 95d1191

Browse files
Merge branch '7.1' into 7.2
* 7.1: fix detecting anonymous exception classes on Windows and PHP 7 skip tests requiring the intl extension if it's not installed [RateLimiter] Fix DateInterval normalization re-add missing profiler shortcuts on profiler homepage Fix support for \SplTempFileObject in BinaryFileResponse [Security] Store original token in token storage when implicitly exiting impersonation [Cache] Fix clear() when using Predis
2 parents 3b5f623 + 28ba29d commit 95d1191

File tree

21 files changed

+185
-13
lines changed

21 files changed

+185
-13
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
{% block sidebar_search_css_class %}{% endblock %}
3838
{% block sidebar_shortcuts_links %}
39+
{{ parent() }}
3940
{{ render(controller('web_profiler.controller.profiler::searchBarAction', query={type: profile_type }|merge(request.query.all))) }}
4041
{% endblock %}
4142

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ protected function doClear(string $namespace): bool
514514

515515
$cursor = null;
516516
do {
517-
$keys = $host instanceof \Predis\ClientInterface ? $host->scan($cursor, 'MATCH', $pattern, 'COUNT', 1000) : $host->scan($cursor, $pattern, 1000);
517+
$keys = $host instanceof \Predis\ClientInterface ? $host->scan($cursor ?? 0, 'MATCH', $pattern, 'COUNT', 1000) : $host->scan($cursor, $pattern, 1000);
518518
if (isset($keys[1]) && \is_array($keys[1])) {
519519
$cursor = $keys[0];
520520
$keys = $keys[1];

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): vo
864864
}
865865

866866
if (str_contains($message, "@anonymous\0")) {
867-
$message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
867+
$message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
868868
}
869869

870870
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX;

src/Symfony/Component/ErrorHandler/ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,6 @@ private function cleanTrace(array $backtrace, int $type, string &$file, int &$li
742742
*/
743743
private function parseAnonymousClass(string $message): string
744744
{
745-
return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', static fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
745+
return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', static fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
746746
}
747747
}

src/Symfony/Component/ErrorHandler/Exception/FlattenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function getMessage(): string
228228
public function setMessage(string $message): static
229229
{
230230
if (str_contains($message, "@anonymous\0")) {
231-
$message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
231+
$message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
232232
}
233233

234234
$this->message = $message;

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function setChunkSize(int $chunkSize): static
126126
*/
127127
public function setAutoLastModified(): static
128128
{
129-
$this->setLastModified(\DateTimeImmutable::createFromFormat('U', $this->file->getMTime()));
129+
$this->setLastModified(\DateTimeImmutable::createFromFormat('U', $this->tempFileObject ? time() : $this->file->getMTime()));
130130

131131
return $this;
132132
}
@@ -197,7 +197,9 @@ public function prepare(Request $request): static
197197
$this->offset = 0;
198198
$this->maxlen = -1;
199199

200-
if (false === $fileSize = $this->file->getSize()) {
200+
if ($this->tempFileObject) {
201+
$fileSize = $this->tempFileObject->fstat()['size'];
202+
} elseif (false === $fileSize = $this->file->getSize()) {
201203
return $this;
202204
}
203205
$this->headers->remove('Transfer-Encoding');

src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ public function testCreateFromTemporaryFile()
451451
$this->assertEquals('attachment; filename=temp', $response->headers->get('Content-Disposition'));
452452

453453
ob_start();
454+
$response->setAutoLastModified();
455+
$response->prepare(new Request());
456+
$this->assertSame('7', $response->headers->get('Content-Length'));
454457
$response->sendContent();
455458
$string = ob_get_clean();
456459
$this->assertSame('foo,bar', $string);

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private function checkController(Request $request, callable $controller): callab
264264
}
265265

266266
if (str_contains($name, '@anonymous')) {
267-
$name = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $name);
267+
$name = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $name);
268268
}
269269

270270
throw new BadRequestException(\sprintf('Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class));

src/Symfony/Component/Intl/Tests/CountriesTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Intl\Countries;
1515
use Symfony\Component\Intl\Exception\MissingResourceException;
16+
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
/**
1819
* @group intl-data
@@ -823,6 +824,10 @@ public function testGetCountryCodes()
823824
*/
824825
public function testGetNames($displayLocale)
825826
{
827+
if ('en' !== $displayLocale) {
828+
IntlTestHelper::requireFullIntl($this);
829+
}
830+
826831
$countries = array_keys(Countries::getNames($displayLocale));
827832

828833
sort($countries);
@@ -832,6 +837,8 @@ public function testGetNames($displayLocale)
832837

833838
public function testGetNamesDefaultLocale()
834839
{
840+
IntlTestHelper::requireFullIntl($this);
841+
835842
\Locale::setDefault('de_AT');
836843

837844
$this->assertSame(Countries::getNames('de_AT'), Countries::getNames());
@@ -842,6 +849,10 @@ public function testGetNamesDefaultLocale()
842849
*/
843850
public function testGetNamesSupportsAliases($alias, $ofLocale)
844851
{
852+
if ('en' !== $ofLocale) {
853+
IntlTestHelper::requireFullIntl($this);
854+
}
855+
845856
// Can't use assertSame(), because some aliases contain scripts with
846857
// different collation (=order of output) than their aliased locale
847858
// e.g. sr_Latn_ME => sr_ME
@@ -853,6 +864,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale)
853864
*/
854865
public function testGetName($displayLocale)
855866
{
867+
if ('en' !== $displayLocale) {
868+
IntlTestHelper::requireFullIntl($this);
869+
}
870+
856871
$names = Countries::getNames($displayLocale);
857872

858873
foreach ($names as $country => $name) {
@@ -924,6 +939,10 @@ public function testAlpha3CodeExists()
924939
*/
925940
public function testGetAlpha3Name($displayLocale)
926941
{
942+
if ('en' !== $displayLocale) {
943+
IntlTestHelper::requireFullIntl($this);
944+
}
945+
927946
$names = Countries::getNames($displayLocale);
928947

929948
foreach ($names as $alpha2 => $name) {
@@ -944,6 +963,10 @@ public function testGetAlpha3NameWithInvalidCountryCode()
944963
*/
945964
public function testGetAlpha3Names($displayLocale)
946965
{
966+
if ('en' !== $displayLocale) {
967+
IntlTestHelper::requireFullIntl($this);
968+
}
969+
947970
$names = Countries::getAlpha3Names($displayLocale);
948971

949972
$alpha3Codes = array_keys($names);

src/Symfony/Component/Intl/Tests/CurrenciesTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Intl\Currencies;
1515
use Symfony\Component\Intl\Exception\MissingResourceException;
16+
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
/**
1819
* @group intl-data
@@ -600,6 +601,10 @@ public function testGetCurrencyCodes()
600601
*/
601602
public function testGetNames($displayLocale)
602603
{
604+
if ('en' !== $displayLocale) {
605+
IntlTestHelper::requireFullIntl($this);
606+
}
607+
603608
$names = Currencies::getNames($displayLocale);
604609

605610
$keys = array_keys($names);
@@ -618,6 +623,8 @@ public function testGetNames($displayLocale)
618623

619624
public function testGetNamesDefaultLocale()
620625
{
626+
IntlTestHelper::requireFullIntl($this);
627+
621628
\Locale::setDefault('de_AT');
622629

623630
$this->assertSame(Currencies::getNames('de_AT'), Currencies::getNames());
@@ -628,6 +635,10 @@ public function testGetNamesDefaultLocale()
628635
*/
629636
public function testGetNamesSupportsAliases($alias, $ofLocale)
630637
{
638+
if ('en' !== $ofLocale) {
639+
IntlTestHelper::requireFullIntl($this);
640+
}
641+
631642
// Can't use assertSame(), because some aliases contain scripts with
632643
// different collation (=order of output) than their aliased locale
633644
// e.g. sr_Latn_ME => sr_ME
@@ -639,6 +650,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale)
639650
*/
640651
public function testGetName($displayLocale)
641652
{
653+
if ('en' !== $displayLocale) {
654+
IntlTestHelper::requireFullIntl($this);
655+
}
656+
642657
$expected = Currencies::getNames($displayLocale);
643658
$actual = [];
644659

@@ -651,6 +666,8 @@ public function testGetName($displayLocale)
651666

652667
public function testGetNameDefaultLocale()
653668
{
669+
IntlTestHelper::requireFullIntl($this);
670+
654671
\Locale::setDefault('de_AT');
655672

656673
$expected = Currencies::getNames('de_AT');

0 commit comments

Comments
 (0)