From a61ecc92cb04c4801af5879655ee50eddff0a8ce Mon Sep 17 00:00:00 2001 From: andrey-tech Date: Mon, 30 Sep 2024 08:02:33 +0300 Subject: [PATCH 1/2] Fix deprecations in CommandDataCollector --- composer.json | 2 +- src/DataCollector/CommandDataCollector.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 626c5655..929c2ab0 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "homepage": "http://www.doctrine-project.org", "require": { "php": "^8.1", - "ext-mongodb": "^1.5", + "ext-mongodb": "^1.16", "composer-runtime-api": "^2.0", "doctrine/mongodb-odm": "^2.6", "doctrine/persistence": "^3.0", diff --git a/src/DataCollector/CommandDataCollector.php b/src/DataCollector/CommandDataCollector.php index cade11ca..fc77f369 100644 --- a/src/DataCollector/CommandDataCollector.php +++ b/src/DataCollector/CommandDataCollector.php @@ -6,6 +6,7 @@ use Doctrine\ODM\MongoDB\APM\Command; use Doctrine\ODM\MongoDB\APM\CommandLogger; +use MongoDB\BSON\Document; use stdClass; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -16,8 +17,6 @@ use function array_reduce; use function count; use function json_decode; -use function MongoDB\BSON\fromPHP; -use function MongoDB\BSON\toCanonicalExtendedJSON; /** @internal */ final class CommandDataCollector extends DataCollector @@ -33,10 +32,11 @@ public function collect(Request $request, Response $response, ?Throwable $except 'commands' => array_map( static function (Command $command): array { $dbProperty = '$db'; + $document = Document::fromPHP($command->getCommand()); return [ 'database' => $command->getCommand()->$dbProperty ?? '', - 'command' => json_decode(toCanonicalExtendedJSON(fromPHP($command->getCommand()))), + 'command' => json_decode($document->toCanonicalExtendedJSON()), 'durationMicros' => $command->getDurationMicros(), ]; }, From 3ea9572ce884ae5b75f41037348b2332fd83d111 Mon Sep 17 00:00:00 2001 From: andrey-tech Date: Mon, 30 Sep 2024 08:24:21 +0300 Subject: [PATCH 2/2] Fix spaces --- src/DataCollector/CommandDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataCollector/CommandDataCollector.php b/src/DataCollector/CommandDataCollector.php index fc77f369..7530d8a5 100644 --- a/src/DataCollector/CommandDataCollector.php +++ b/src/DataCollector/CommandDataCollector.php @@ -32,7 +32,7 @@ public function collect(Request $request, Response $response, ?Throwable $except 'commands' => array_map( static function (Command $command): array { $dbProperty = '$db'; - $document = Document::fromPHP($command->getCommand()); + $document = Document::fromPHP($command->getCommand()); return [ 'database' => $command->getCommand()->$dbProperty ?? '',