File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -282,17 +282,14 @@ protected function getPrimaryServer()
282
282
283
283
protected function getServerVersion (ReadPreference $ readPreference = null )
284
284
{
285
- $ cursor = $ this ->manager ->executeCommand (
285
+ $ buildInfo = $ this ->manager ->executeCommand (
286
286
$ this ->getDatabaseName (),
287
287
new Command (['buildInfo ' => 1 ]),
288
288
$ readPreference ?: new ReadPreference (ReadPreference::RP_PRIMARY )
289
- );
290
-
291
- $ cursor ->setTypeMap (['root ' => 'array ' , 'document ' => 'array ' ]);
292
- $ document = current ($ cursor ->toArray ());
289
+ )->toArray ()[0 ];
293
290
294
- if (isset ($ document [ ' version ' ] ) && is_string ($ document [ ' version ' ] )) {
295
- return preg_replace ('#^(\d+\.\d+\.\d+).*$# ' , '\1 ' , $ document [ ' version ' ] );
291
+ if (isset ($ buildInfo -> version ) && is_string ($ buildInfo -> version )) {
292
+ return preg_replace ('#^(\d+\.\d+\.\d+).*$# ' , '\1 ' , $ buildInfo -> version );
296
293
}
297
294
298
295
throw new UnexpectedValueException ('Could not determine server version ' );
Original file line number Diff line number Diff line change 25
25
use function PHPUnit \Framework \assertIsString ;
26
26
use function PHPUnit \Framework \assertNotEmpty ;
27
27
use function preg_match ;
28
+ use function preg_replace ;
28
29
use function sprintf ;
29
30
use function strpos ;
30
31
use function version_compare ;
@@ -332,7 +333,7 @@ private function getServerVersion() : string
332
333
$ buildInfo = $ database ->command (['buildInfo ' => 1 ])->toArray ()[0 ];
333
334
334
335
if (isset ($ buildInfo ->version ) && is_string ($ buildInfo ->version )) {
335
- return $ buildInfo ->version ;
336
+ return preg_replace ( ' #^(\d+\.\d+\.\d+).*$# ' , ' \1 ' , $ buildInfo ->version ) ;
336
337
}
337
338
338
339
throw new UnexpectedValueException ('Could not determine server version ' );
You can’t perform that action at this time.
0 commit comments