Skip to content

Commit c3f8915

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: [Finder] Fix using `==` as default operator in `DateComparator` [HttpFoundation] Avoid mime type guess with temp files in `BinaryFileResponse` choose the correctly cased class name for the MariaDB platform
2 parents 04aa652 + 6166a9a commit c3f8915

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

src/Symfony/Component/Finder/Comparator/DateComparator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $test)
3636
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid date.', $matches[2]));
3737
}
3838

39-
$operator = $matches[1] ?? '==';
39+
$operator = $matches[1] ?: '==';
4040
if ('since' === $operator || 'after' === $operator) {
4141
$operator = '>';
4242
}

src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static function getTestData()
5959
['after 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
6060
['since 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
6161
['!= 2005-10-10', [strtotime('2005-10-11')], [strtotime('2005-10-10')]],
62+
['2005-10-10', [strtotime('2005-10-10')], [strtotime('2005-10-11')]],
6263
];
6364
}
6465
}

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ public function prepare(Request $request): static
189189
}
190190

191191
if (!$this->headers->has('Content-Type')) {
192-
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
192+
$mimeType = null;
193+
if (!$this->tempFileObject) {
194+
$mimeType = $this->file->getMimeType();
195+
}
196+
197+
$this->headers->set('Content-Type', $mimeType ?: 'application/octet-stream');
193198
}
194199

195200
parent::prepare($request);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,15 @@ public function testSetChunkSizeTooSmall()
468468

469469
$response->setChunkSize(0);
470470
}
471+
472+
public function testCreateFromTemporaryFileWithoutMimeType()
473+
{
474+
$file = new \SplTempFileObject();
475+
$file->fwrite('foo,bar');
476+
477+
$response = new BinaryFileResponse($file);
478+
$response->prepare(new Request());
479+
480+
$this->assertSame('application/octet-stream', $response->headers->get('Content-Type'));
481+
}
471482
}

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Doctrine\DBAL\Connection as DBALConnection;
1616
use Doctrine\DBAL\Exception as DBALException;
1717
use Doctrine\DBAL\Platforms\AbstractPlatform;
18-
use Doctrine\DBAL\Platforms\MariaDb1060Platform;
1918
use Doctrine\DBAL\Platforms\MariaDBPlatform;
2019
use Doctrine\DBAL\Platforms\MySQL57Platform;
2120
use Doctrine\DBAL\Platforms\MySQL80Platform;
@@ -591,9 +590,16 @@ class_exists(MySQLPlatform::class) ? new MySQLPlatform() : new MySQL57Platform()
591590
'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE',
592591
];
593592

594-
if (class_exists(MariaDb1060Platform::class)) {
593+
if (interface_exists(DBALException::class)) {
594+
// DBAL 4+
595+
$mariaDbPlatformClass = 'Doctrine\DBAL\Platforms\MariaDB1060Platform';
596+
} else {
597+
$mariaDbPlatformClass = 'Doctrine\DBAL\Platforms\MariaDb1060Platform';
598+
}
599+
600+
if (class_exists($mariaDbPlatformClass)) {
595601
yield 'MariaDB106' => [
596-
new MariaDb1060Platform(),
602+
new $mariaDbPlatformClass(),
597603
'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED',
598604
];
599605
}

0 commit comments

Comments
 (0)