Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85ec307

Browse files
minor #57726 use more entropy with uniqid() (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- use more entropy with `uniqid()` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT following #57697 on the `6.4` branch Commits ------- b91e8a2 use more entropy with uniqid()
2 parents 1a49e27 + b91e8a2 commit 85ec307

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/Symfony/Bridge/PsrHttpMessage/Tests/Factory/HttpFoundationFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function testCreateUploadedFile()
172172
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);
173173
$size = $symfonyUploadedFile->getSize();
174174

175-
$uniqid = uniqid();
175+
$uniqid = uniqid('', true);
176176
$symfonyUploadedFile->move($this->tmpDir, $uniqid);
177177

178178
$this->assertEquals($uploadedFile->getSize(), $size);
@@ -198,7 +198,7 @@ public function testCreateUploadedFileWithError()
198198

199199
private function createUploadedFile(string $content, int $error, string $clientFileName, string $clientMediaType): UploadedFile
200200
{
201-
$filePath = tempnam($this->tmpDir, uniqid());
201+
$filePath = tempnam($this->tmpDir, uniqid('', true));
202202
file_put_contents($filePath, $content);
203203

204204
return new UploadedFile($filePath, filesize($filePath), $error, $clientFileName, $clientMediaType);

src/Symfony/Bridge/PsrHttpMessage/Tests/Factory/PsrHttpFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function testGetContentCanBeCalledAfterRequestCreation()
131131

132132
private function createUploadedFile(string $content, string $originalName, string $mimeType, int $error): UploadedFile
133133
{
134-
$path = tempnam($this->tmpDir, uniqid());
134+
$path = tempnam($this->tmpDir, uniqid('', true));
135135
file_put_contents($path, $content);
136136

137137
return new UploadedFile($path, $originalName, $mimeType, $error, true);
@@ -182,7 +182,7 @@ public function testCreateResponseFromStreamed()
182182

183183
public function testCreateResponseFromBinaryFile()
184184
{
185-
$path = tempnam($this->tmpDir, uniqid());
185+
$path = tempnam($this->tmpDir, uniqid('', true));
186186
file_put_contents($path, 'Binary');
187187

188188
$response = new BinaryFileResponse($path);
@@ -194,7 +194,7 @@ public function testCreateResponseFromBinaryFile()
194194

195195
public function testCreateResponseFromBinaryFileWithRange()
196196
{
197-
$path = tempnam($this->tmpDir, uniqid());
197+
$path = tempnam($this->tmpDir, uniqid('', true));
198198
file_put_contents($path, 'Binary');
199199

200200
$request = new Request();

src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/CovertTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function responseProvider(): array
217217

218218
private static function createUploadedFile(string $content, string $originalName, string $mimeType, int $error): UploadedFile
219219
{
220-
$path = tempnam(sys_get_temp_dir(), uniqid());
220+
$path = tempnam(sys_get_temp_dir(), uniqid('', true));
221221
file_put_contents($path, $content);
222222

223223
return new UploadedFile($path, $originalName, $mimeType, $error, true);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public function testInvalidSentinelMasterName()
413413
}
414414

415415
$master = getenv('MESSENGER_REDIS_DSN');
416-
$uid = uniqid('sentinel_');
416+
$uid = uniqid('sentinel_', true);
417417

418418
$exp = explode('://', $master, 2)[1];
419419
$this->expectException(\InvalidArgumentException::class);

src/Symfony/Component/Serializer/Debug/TraceableSerializer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141

4242
public function serialize(mixed $data, string $format, array $context = []): string
4343
{
44-
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
44+
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);
4545

4646
$startTime = microtime(true);
4747
$result = $this->serializer->serialize($data, $format, $context);
@@ -56,7 +56,7 @@ public function serialize(mixed $data, string $format, array $context = []): str
5656

5757
public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed
5858
{
59-
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
59+
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);
6060

6161
$startTime = microtime(true);
6262
$result = $this->serializer->deserialize($data, $type, $format, $context);
@@ -71,7 +71,7 @@ public function deserialize(mixed $data, string $type, string $format, array $co
7171

7272
public function normalize(mixed $object, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
7373
{
74-
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
74+
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);
7575

7676
$startTime = microtime(true);
7777
$result = $this->serializer->normalize($object, $format, $context);
@@ -86,7 +86,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
8686

8787
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
8888
{
89-
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
89+
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);
9090

9191
$startTime = microtime(true);
9292
$result = $this->serializer->denormalize($data, $type, $format, $context);
@@ -101,7 +101,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
101101

102102
public function encode(mixed $data, string $format, array $context = []): string
103103
{
104-
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
104+
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);
105105

106106
$startTime = microtime(true);
107107
$result = $this->serializer->encode($data, $format, $context);
@@ -116,7 +116,7 @@ public function encode(mixed $data, string $format, array $context = []): string
116116

117117
public function decode(string $data, string $format, array $context = []): mixed
118118
{
119-
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid();
119+
$context[self::DEBUG_TRACE_ID] = $traceId = uniqid('', true);
120120

121121
$startTime = microtime(true);
122122
$result = $this->serializer->decode($data, $format, $context);

0 commit comments

Comments
 (0)