Skip to content

Commit fdc40f3

Browse files
authored
Fix deprecations in CommandDataCollector (#856)
* Fix deprecations in CommandDataCollector * Fix spaces
1 parent 0642b8b commit fdc40f3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"homepage": "http://www.doctrine-project.org",
2626
"require": {
2727
"php": "^8.1",
28-
"ext-mongodb": "^1.5",
28+
"ext-mongodb": "^1.16",
2929
"composer-runtime-api": "^2.0",
3030
"doctrine/mongodb-odm": "^2.6",
3131
"doctrine/persistence": "^3.0",

src/DataCollector/CommandDataCollector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\ODM\MongoDB\APM\Command;
88
use Doctrine\ODM\MongoDB\APM\CommandLogger;
9+
use MongoDB\BSON\Document;
910
use stdClass;
1011
use Symfony\Component\HttpFoundation\Request;
1112
use Symfony\Component\HttpFoundation\Response;
@@ -16,8 +17,6 @@
1617
use function array_reduce;
1718
use function count;
1819
use function json_decode;
19-
use function MongoDB\BSON\fromPHP;
20-
use function MongoDB\BSON\toCanonicalExtendedJSON;
2120

2221
/** @internal */
2322
final class CommandDataCollector extends DataCollector
@@ -33,10 +32,11 @@ public function collect(Request $request, Response $response, ?Throwable $except
3332
'commands' => array_map(
3433
static function (Command $command): array {
3534
$dbProperty = '$db';
35+
$document = Document::fromPHP($command->getCommand());
3636

3737
return [
3838
'database' => $command->getCommand()->$dbProperty ?? '',
39-
'command' => json_decode(toCanonicalExtendedJSON(fromPHP($command->getCommand()))),
39+
'command' => json_decode($document->toCanonicalExtendedJSON()),
4040
'durationMicros' => $command->getDurationMicros(),
4141
];
4242
},

0 commit comments

Comments
 (0)