Skip to content

Commit d4a02bd

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: pass CSV escape characters explicitly move setting deprecation session options into a legacy group test
2 parents e4863db + e104cd2 commit d4a02bd

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,39 @@ public function testCookieOptions()
203203
$this->assertEquals($options, $gco);
204204
}
205205

206-
public function testSessionOptions()
206+
public function testCacheExpireOption()
207207
{
208208
$options = [
209-
'trans_sid_tags' => 'a=href',
210209
'cache_expire' => '200',
211210
];
212211

213212
$this->getStorage($options);
214213

215-
$this->assertSame('a=href', \ini_get('session.trans_sid_tags'));
216214
$this->assertSame('200', \ini_get('session.cache_expire'));
217215
}
218216

217+
/**
218+
* The test must only be removed when the "session.trans_sid_tags" option is removed from PHP or when the "trans_sid_tags" option is no longer supported by the native session storage.
219+
*/
220+
public function testTransSidTagsOption()
221+
{
222+
$previousErrorHandler = set_error_handler(function ($errno, $errstr) use (&$previousErrorHandler) {
223+
if ('ini_set(): Usage of session.trans_sid_tags INI setting is deprecated' !== $errstr) {
224+
return $previousErrorHandler ? $previousErrorHandler(...\func_get_args()) : false;
225+
}
226+
});
227+
228+
try {
229+
$this->getStorage([
230+
'trans_sid_tags' => 'a=href',
231+
]);
232+
} finally {
233+
restore_error_handler();
234+
}
235+
236+
$this->assertSame('a=href', \ini_get('session.trans_sid_tags'));
237+
}
238+
219239
public function testSetSaveHandler()
220240
{
221241
$initialSaveHandler = ini_set('session.save_handler', 'files');

src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function find(?string $ip, ?string $url, ?int $limit, ?string $method, ?i
5959

6060
$result = [];
6161
while (\count($result) < $limit && $line = $this->readLineFromFile($file)) {
62-
$values = str_getcsv($line);
62+
$values = str_getcsv($line, ',', '"', '\\');
6363

6464
if (7 > \count($values)) {
6565
// skip invalid lines
@@ -193,7 +193,7 @@ public function write(Profile $profile): bool
193193
$profile->getParentToken(),
194194
$profile->getStatusCode(),
195195
$profile->getVirtualType() ?? 'request',
196-
]);
196+
], ',', '"', '\\');
197197
fclose($file);
198198

199199
if (1 === mt_rand(1, 10)) {

src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,12 @@ public function testMultiRowIndexFile()
343343

344344
$handle = fopen($this->tmpDir.'/index.csv', 'r');
345345
for ($i = 0; $i < $iteration; ++$i) {
346-
$row = fgetcsv($handle);
346+
$row = fgetcsv($handle, null, ',', '"', '\\');
347347
$this->assertEquals('token'.$i, $row[0]);
348348
$this->assertEquals('127.0.0.'.$i, $row[1]);
349349
$this->assertEquals('http://foo.bar/'.$i, $row[3]);
350350
}
351-
$this->assertFalse(fgetcsv($handle));
351+
$this->assertFalse(fgetcsv($handle, null, ',', '"', '\\'));
352352
}
353353

354354
/**

src/Symfony/Component/Translation/Dumper/CsvFileDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra
2828
$handle = fopen('php://memory', 'r+');
2929

3030
foreach ($messages->all($domain) as $source => $target) {
31-
fputcsv($handle, [$source, $target], $this->delimiter, $this->enclosure);
31+
fputcsv($handle, [$source, $target], $this->delimiter, $this->enclosure, '\\');
3232
}
3333

3434
rewind($handle);

src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function readPropertiesFromRegistry(array $properties): array
129129
array_shift($lines);
130130

131131
foreach ($lines as $line) {
132-
$columns = str_getcsv($line, "\t");
132+
$columns = str_getcsv($line, "\t", '"', '\\');
133133
$propertyLabel = array_shift($columns);
134134

135135
if (!isset($properties[$propertyLabel])) {

0 commit comments

Comments
 (0)