@@ -1015,7 +1015,8 @@ static mongoc_uri_t *php_phongo_make_uri(const char *uri_string, bson_t *options
10151015 !strcasecmp (key , "slaveok" ) ||
10161016 !strcasecmp (key , "w" ) ||
10171017 !strcasecmp (key , "wtimeoutms" ) ||
1018- !strcasecmp (key , "maxstalenessms" )
1018+ !strcasecmp (key , "maxstalenessms" ) ||
1019+ !strcasecmp (key , "appname" )
10191020 ) {
10201021 continue ;
10211022 }
@@ -1524,6 +1525,7 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
15241525 bson_t bson_options = BSON_INITIALIZER ;
15251526 mongoc_uri_t * uri = NULL ;
15261527 mongoc_ssl_opt_t * ssl_opt = NULL ;
1528+ bson_iter_t iter ;
15271529
15281530#if PHP_VERSION_ID >= 70000
15291531 zval * client_ptr ;
@@ -1572,6 +1574,15 @@ void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
15721574 goto cleanup ;
15731575 }
15741576
1577+ if (bson_iter_init_find_case (& iter , & bson_options , "appname" ) && BSON_ITER_HOLDS_UTF8 (& iter )) {
1578+ const char * str = bson_iter_utf8 (& iter , NULL );
1579+
1580+ if (!mongoc_uri_set_appname (uri , str )) {
1581+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Invalid appname value: '%s'" , str );
1582+ goto cleanup ;
1583+ }
1584+ }
1585+
15751586 ssl_opt = php_phongo_make_ssl_opt (driverOptions TSRMLS_CC );
15761587
15771588 /* An exception may be thrown during SSL option creation */
0 commit comments