Fix Uuid class not found: use native PHP UUID v4 generation
symfony/uid not installed, replace Uuid::v4() with random_int based UUID v4 generation (RFC 4122 compliant). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
class AnalyticsController extends AbstractController
|
||||
{
|
||||
@@ -78,7 +77,13 @@ class AnalyticsController extends AbstractController
|
||||
AnalyticsCryptoService $crypto,
|
||||
EntityManagerInterface $em,
|
||||
): AnalyticsUniqId {
|
||||
$uid = Uuid::v4()->toRfc4122();
|
||||
$uid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
random_int(0, 0xFFFF), random_int(0, 0xFFFF),
|
||||
random_int(0, 0xFFFF),
|
||||
random_int(0, 0x0FFF) | 0x4000,
|
||||
random_int(0, 0x3FFF) | 0x8000,
|
||||
random_int(0, 0xFFFF), random_int(0, 0xFFFF), random_int(0, 0xFFFF),
|
||||
);
|
||||
$ua = $request->headers->get('User-Agent', '');
|
||||
|
||||
$visitor = new AnalyticsUniqId();
|
||||
|
||||
Reference in New Issue
Block a user