Skip to content

Commit 5f48017

Browse files
committed
Remove uniqid() from tempnam() calls
1 parent 6d01a03 commit 5f48017

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

Factory/HttpFoundationFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private function createUploadedFile(UploadedFileInterface $psrUploadedFile): Upl
104104
*/
105105
protected function getTemporaryPath(): string
106106
{
107-
return tempnam(sys_get_temp_dir(), uniqid('symfony', true));
107+
return tempnam(sys_get_temp_dir(), 'symfony');
108108
}
109109

110110
public function createResponse(ResponseInterface $psrResponse, bool $streamed = false): Response

Tests/Factory/HttpFoundationFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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, 'sftest');
202202
file_put_contents($filePath, $content);
203203

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

Tests/Factory/PsrHttpFactoryTest.php

Lines changed: 8 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 = $this->createTempFile();
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 = $this->createTempFile();
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 = $this->createTempFile();
198198
file_put_contents($path, 'Binary');
199199

200200
$request = new Request();
@@ -287,4 +287,9 @@ private static function buildHttpMessageFactory(): PsrHttpFactory
287287

288288
return new PsrHttpFactory($factory, $factory, $factory, $factory);
289289
}
290+
291+
private function createTempFile(): string
292+
{
293+
return tempnam($this->tmpDir, 'sftest');
294+
}
290295
}

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(), 'sftest');
221221
file_put_contents($path, $content);
222222

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

0 commit comments

Comments
 (0)