Skip to content

Commit 9ddc272

Browse files
authored
PHPLIB-634 Ignore pre-release flags in server version numbers (#823)
1 parent a9e2977 commit 9ddc272

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

tests/FunctionalTestCase.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,14 @@ protected function getPrimaryServer()
282282

283283
protected function getServerVersion(ReadPreference $readPreference = null)
284284
{
285-
$cursor = $this->manager->executeCommand(
285+
$buildInfo = $this->manager->executeCommand(
286286
$this->getDatabaseName(),
287287
new Command(['buildInfo' => 1]),
288288
$readPreference ?: new ReadPreference(ReadPreference::RP_PRIMARY)
289-
);
290-
291-
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
292-
$document = current($cursor->toArray());
289+
)->toArray()[0];
293290

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);
296293
}
297294

298295
throw new UnexpectedValueException('Could not determine server version');

tests/UnifiedSpecTests/UnifiedTestRunner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use function PHPUnit\Framework\assertIsString;
2626
use function PHPUnit\Framework\assertNotEmpty;
2727
use function preg_match;
28+
use function preg_replace;
2829
use function sprintf;
2930
use function strpos;
3031
use function version_compare;
@@ -332,7 +333,7 @@ private function getServerVersion() : string
332333
$buildInfo = $database->command(['buildInfo' => 1])->toArray()[0];
333334

334335
if (isset($buildInfo->version) && is_string($buildInfo->version)) {
335-
return $buildInfo->version;
336+
return preg_replace('#^(\d+\.\d+\.\d+).*$#', '\1', $buildInfo->version);
336337
}
337338

338339
throw new UnexpectedValueException('Could not determine server version');

0 commit comments

Comments
 (0)