Skip to content

Commit 91aaf65

Browse files
committed
PHPC-757: Implement The MongoDB Handshake Protocol
1 parent f7b8905 commit 91aaf65

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

php_phongo.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1874,13 +1874,21 @@ PHP_GINIT_FUNCTION(mongodb)
18741874
/* {{{ PHP_MINIT_FUNCTION */
18751875
PHP_MINIT_FUNCTION(mongodb)
18761876
{
1877-
(void)type; /* We don't care if we are loaded via dl() or extension= */
1877+
char *php_version_string;
18781878

1879+
(void)type; /* We don't care if we are loaded via dl() or extension= */
18791880

18801881
REGISTER_INI_ENTRIES();
18811882

18821883
/* Initialize libmongoc */
18831884
mongoc_init();
1885+
1886+
/* Set handshake options */
1887+
php_version_string = malloc(4 + sizeof(PHP_VERSION) + 1);
1888+
snprintf(php_version_string, 4 + sizeof(PHP_VERSION) + 1, "PHP %s", PHP_VERSION);
1889+
mongoc_handshake_data_append("ext-mongodb:PHP", MONGODB_VERSION_S, php_version_string);
1890+
free(php_version_string);
1891+
18841892
/* Initialize libbson */
18851893
bson_mem_set_vtable(&MONGODB_G(bsonMemVTable));
18861894

0 commit comments

Comments
 (0)