Skip to content

Commit

Permalink
Use random_bytes instead of uniqid (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
valtzu authored May 29, 2022
1 parent 3226059 commit 94bc351
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Doctrine/Common/Proxy/ProxyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function array_slice;
use function array_unique;
use function assert;
use function bin2hex;
use function call_user_func;
use function chmod;
use function class_exists;
Expand All @@ -43,6 +44,7 @@
use function mkdir;
use function preg_match;
use function preg_match_all;
use function random_bytes;
use function rename;
use function rtrim;
use function sprintf;
Expand All @@ -52,7 +54,6 @@
use function strtr;
use function substr;
use function trim;
use function uniqid;
use function var_export;

use const DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -338,7 +339,7 @@ public function generateProxyClass(ClassMetadata $class, $fileName = false)
throw UnexpectedValueException::proxyDirectoryNotWritable($this->proxyDirectory);
}

$tmpFileName = $fileName . '.' . uniqid('', true);
$tmpFileName = $fileName . '.' . bin2hex(random_bytes(12));

file_put_contents($tmpFileName, $proxyCode);
@chmod($tmpFileName, 0664);
Expand Down

0 comments on commit 94bc351

Please sign in to comment.