Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/MongoDB/Manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ static HashTable* php_phongo_manager_get_debug_info(zend_object* object, int* is
*is_temp = 1;
intern = Z_OBJ_MANAGER(object);

array_init_size(&retval, 2);
array_init_size(&retval, 3);

ADD_ASSOC_STRING(&retval, "uri", mongoc_uri_get_string(mongoc_client_get_uri(intern->client)));

Expand All @@ -851,6 +851,16 @@ static HashTable* php_phongo_manager_get_debug_info(zend_object* object, int* is

ADD_ASSOC_ZVAL_EX(&retval, "cluster", &cluster);

{
const char* crypt_shared_version = mongoc_client_get_crypt_shared_version(intern->client);

if (crypt_shared_version) {
ADD_ASSOC_STRING(&retval, "cryptSharedVersion", crypt_shared_version);
} else {
ADD_ASSOC_NULL_EX(&retval, "cryptSharedVersion");
}
}

done:
mongoc_server_descriptions_destroy_all(sds, n);

Expand Down
2 changes: 2 additions & 0 deletions tests/manager/bug0940-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ object(MongoDB\Driver\Manager)#%d (%d) {
["cluster"]=>
array(0) {
}
["cryptSharedVersion"]=>
NULL
}
===DONE===
2 changes: 0 additions & 2 deletions tests/manager/manager-ctor-auto_encryption-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ MongoDB\Driver\Manager::__construct(): crypt_shared is required
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_libmongocrypt(); ?>
<?php skip_if_no_crypt_shared(); ?>
--XFAIL--
crypt_shared log output breaks build (PHPC-2156)
--FILE--
<?php

Expand Down
4 changes: 4 additions & 0 deletions tests/manager/manager-ctor-ssl-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ object(MongoDB\Driver\Manager)#%d (%d) {
["cluster"]=>
array(0) {
}
["cryptSharedVersion"]=>
NULL
}
object(MongoDB\Driver\Manager)#%d (%d) {
["uri"]=>
string(20) "mongodb://127.0.0.1/"
["cluster"]=>
array(0) {
}
["cryptSharedVersion"]=>
NULL
}
===DONE===
53 changes: 53 additions & 0 deletions tests/manager/manager-debug-004.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
--TEST--
MongoDB\Driver\Manager debug output with crypt_shared
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_libmongocrypt(); ?>
<?php skip_if_no_crypt_shared(); ?>
--FILE--
<?php

require_once __DIR__ . '/../utils/basic.inc';

// First, create a test manager without auto-encryption
$manager = create_test_manager();

var_dump($manager);
var_dump(get_module_info('crypt_shared library version'));

$autoEncryptionOptions = [
'keyVaultNamespace' => CSFLE_KEY_VAULT_NS,
'kmsProviders' => ['local' => ['key' => new MongoDB\BSON\Binary(CSFLE_LOCAL_KEY, 0)]],
'extraOptions' => ['cryptSharedLibRequired' => true],
];

$manager = create_test_manager(null, [], ['autoEncryption' => $autoEncryptionOptions]);

var_dump($manager);
var_dump(get_module_info('crypt_shared library version'));

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
object(MongoDB\Driver\Manager)#%d (%d) {
["uri"]=>
string(%d) "%s"
["cluster"]=>
array(0) {
}
["cryptSharedVersion"]=>
NULL
}
string(7) "unknown"
object(MongoDB\Driver\Manager)#%d (%d) {
["uri"]=>
string(%d) "%s"
["cluster"]=>
array(0) {
}
["cryptSharedVersion"]=>
string(%d) "mongo_crypt%a"
}
string(7) "unknown"
===DONE===
4 changes: 4 additions & 0 deletions tests/manager/manager-var-dump-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ object(MongoDB\Driver\Manager)#%d (%d) {
["cluster"]=>
array(0) {
}
["cryptSharedVersion"]=>
NULL
}
object(MongoDB\Driver\Manager)#%d (%d) {
["uri"]=>
Expand Down Expand Up @@ -60,5 +62,7 @@ object(MongoDB\Driver\Manager)#%d (%d) {
int(%d)
}
}
["cryptSharedVersion"]=>
NULL
}
===DONE===
4 changes: 4 additions & 0 deletions tests/utils/skipif.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ function skip_if_crypt_shared()

function skip_if_no_crypt_shared()
{
if (PHP_INT_SIZE !== 8) {
exit('skip crypt_shared is only available on 64-bit systems');
}

// Intentionally consider empty values for CRYPT_SHARED_LIB_PATH
if ( ! getenv('CRYPT_SHARED_LIB_PATH')) {
exit('skip crypt_shared is not available');
Expand Down