diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md new file mode 100644 index 000000000..9bbbc1e5f --- /dev/null +++ b/UPGRADE-2.0.md @@ -0,0 +1,6 @@ +UPGRADE FROM 1.x to 2.0 +======================= + + * The `getServer()` method has been removed from the CommandFailedEvent, + CommandStartedEvent, and CommandSucceededEvent event classes. The `getHost()` + and `getPort()` methods have been added in its place. diff --git a/src/MongoDB/Monitoring/CommandFailedEvent.c b/src/MongoDB/Monitoring/CommandFailedEvent.c index 033bd8648..e0b36a8ba 100644 --- a/src/MongoDB/Monitoring/CommandFailedEvent.c +++ b/src/MongoDB/Monitoring/CommandFailedEvent.c @@ -138,17 +138,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId) RETVAL_STRING(request_id); } -static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer) -{ - php_phongo_commandfailedevent_t* intern; - - intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); - - PHONGO_PARSE_PARAMETERS_NONE(); - - phongo_server_init(return_value, &intern->manager, intern->server_id); -} - static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId) { php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); @@ -195,10 +184,6 @@ static void php_phongo_commandfailedevent_free_object(zend_object* object) zval_ptr_dtor(&intern->z_error); } - if (!Z_ISUNDEF(intern->manager)) { - zval_ptr_dtor(&intern->manager); - } - if (intern->reply) { bson_destroy(intern->reply); } @@ -235,7 +220,7 @@ static HashTable* php_phongo_commandfailedevent_get_debug_info(zend_object* obje intern = Z_OBJ_COMMANDFAILEDEVENT(object); *is_temp = 1; - array_init_size(&retval, 11); + array_init_size(&retval, 10); ADD_ASSOC_STRING(&retval, "host", intern->host.host); ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port); @@ -258,13 +243,6 @@ static HashTable* php_phongo_commandfailedevent_get_debug_info(zend_object* obje snprintf(request_id, sizeof(request_id), "%" PRId64, intern->request_id); ADD_ASSOC_STRING(&retval, "requestId", request_id); - { - zval server; - - phongo_server_init(&server, &intern->manager, intern->server_id); - ADD_ASSOC_ZVAL_EX(&retval, "server", &server); - } - if (intern->has_service_id) { zval service_id; diff --git a/src/MongoDB/Monitoring/CommandFailedEvent.stub.php b/src/MongoDB/Monitoring/CommandFailedEvent.stub.php index 87a771e47..390a3ce71 100644 --- a/src/MongoDB/Monitoring/CommandFailedEvent.stub.php +++ b/src/MongoDB/Monitoring/CommandFailedEvent.stub.php @@ -30,9 +30,6 @@ final public function getReply(): object {} final public function getRequestId(): string {} - /** @deprecated */ - final public function getServer(): \MongoDB\Driver\Server {} - final public function getServiceId(): ?\MongoDB\BSON\ObjectId {} final public function getServerConnectionId(): ?int {} diff --git a/src/MongoDB/Monitoring/CommandFailedEvent_arginfo.h b/src/MongoDB/Monitoring/CommandFailedEvent_arginfo.h index 4d7654e76..fcaf5f466 100644 --- a/src/MongoDB/Monitoring/CommandFailedEvent_arginfo.h +++ b/src/MongoDB/Monitoring/CommandFailedEvent_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 46f531ec58d18fa7f4c5910ff14e6c3f5eda9605 */ + * Stub hash: 5ee4ff6e75a00cb4456ef87a15dd1d35fa0d3bdd */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -26,9 +26,6 @@ ZEND_END_ARG_INFO() #define arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getRequestId arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getCommandName -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getServer, 0, 0, MongoDB\\Driver\\Server, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getServiceId, 0, 0, MongoDB\\BSON\\ObjectId, 1) ZEND_END_ARG_INFO() @@ -46,7 +43,6 @@ static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getOperationId) static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getPort); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getReply); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId); -static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServerConnectionId); @@ -62,7 +58,6 @@ static const zend_function_entry class_MongoDB_Driver_Monitoring_CommandFailedEv ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getPort, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getPort, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getReply, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getReply, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getRequestId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) - ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_DEPRECATED) ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getServiceId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getServerConnectionId, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getServerConnectionId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_FE_END diff --git a/src/MongoDB/Monitoring/CommandStartedEvent.c b/src/MongoDB/Monitoring/CommandStartedEvent.c index e2c147514..5b4037659 100644 --- a/src/MongoDB/Monitoring/CommandStartedEvent.c +++ b/src/MongoDB/Monitoring/CommandStartedEvent.c @@ -116,17 +116,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getRequestId) RETVAL_STRING(request_id); } -static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServer) -{ - php_phongo_commandstartedevent_t* intern; - - intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); - - PHONGO_PARSE_PARAMETERS_NONE(); - - phongo_server_init(return_value, &intern->manager, intern->server_id); -} - static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServiceId) { php_phongo_commandstartedevent_t* intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); @@ -169,10 +158,6 @@ static void php_phongo_commandstartedevent_free_object(zend_object* object) zend_object_std_dtor(&intern->std); - if (!Z_ISUNDEF(intern->manager)) { - zval_ptr_dtor(&intern->manager); - } - if (intern->command) { bson_destroy(intern->command); } @@ -209,7 +194,7 @@ static HashTable* php_phongo_commandstartedevent_get_debug_info(zend_object* obj intern = Z_OBJ_COMMANDSTARTEDEVENT(object); *is_temp = 1; - array_init_size(&retval, 10); + array_init_size(&retval, 9); ADD_ASSOC_STRING(&retval, "host", intern->host.host); ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port); @@ -229,13 +214,6 @@ static HashTable* php_phongo_commandstartedevent_get_debug_info(zend_object* obj snprintf(request_id, sizeof(request_id), "%" PRId64, intern->request_id); ADD_ASSOC_STRING(&retval, "requestId", request_id); - { - zval server; - - phongo_server_init(&server, &intern->manager, intern->server_id); - ADD_ASSOC_ZVAL_EX(&retval, "server", &server); - } - if (intern->has_service_id) { zval service_id; diff --git a/src/MongoDB/Monitoring/CommandStartedEvent.stub.php b/src/MongoDB/Monitoring/CommandStartedEvent.stub.php index 76041cad4..5ba20fe87 100644 --- a/src/MongoDB/Monitoring/CommandStartedEvent.stub.php +++ b/src/MongoDB/Monitoring/CommandStartedEvent.stub.php @@ -26,9 +26,6 @@ final public function getPort(): int {} final public function getRequestId(): string {} - /** @deprecated */ - final public function getServer(): \MongoDB\Driver\Server {} - final public function getServiceId(): ?\MongoDB\BSON\ObjectId {} final public function getServerConnectionId(): ?int {} diff --git a/src/MongoDB/Monitoring/CommandStartedEvent_arginfo.h b/src/MongoDB/Monitoring/CommandStartedEvent_arginfo.h index 05035975a..59f0d7a5a 100644 --- a/src/MongoDB/Monitoring/CommandStartedEvent_arginfo.h +++ b/src/MongoDB/Monitoring/CommandStartedEvent_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f3b8360ca99550f786be74dde8a245a544e49286 */ + * Stub hash: c52ae0c5f78d5a61839b24517cc7823f7d9701ad */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -21,9 +21,6 @@ ZEND_END_ARG_INFO() #define arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getRequestId arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getCommandName -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getServer, 0, 0, MongoDB\\Driver\\Server, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getServiceId, 0, 0, MongoDB\\BSON\\ObjectId, 1) ZEND_END_ARG_INFO() @@ -39,7 +36,6 @@ static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getHost); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getOperationId); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getPort); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getRequestId); -static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServer); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServiceId); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServerConnectionId); @@ -53,7 +49,6 @@ static const zend_function_entry class_MongoDB_Driver_Monitoring_CommandStartedE ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getOperationId, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getOperationId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getPort, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getPort, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getRequestId, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getRequestId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) - ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getServer, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_DEPRECATED) ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getServiceId, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getServiceId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getServerConnectionId, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getServerConnectionId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_FE_END diff --git a/src/MongoDB/Monitoring/CommandSucceededEvent.c b/src/MongoDB/Monitoring/CommandSucceededEvent.c index 20a279bcf..cb0a0ccb9 100644 --- a/src/MongoDB/Monitoring/CommandSucceededEvent.c +++ b/src/MongoDB/Monitoring/CommandSucceededEvent.c @@ -127,17 +127,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getRequestId) RETVAL_STRING(request_id); } -static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServer) -{ - php_phongo_commandsucceededevent_t* intern; - - intern = Z_COMMANDSUCCEEDEDEVENT_OBJ_P(getThis()); - - PHONGO_PARSE_PARAMETERS_NONE(); - - phongo_server_init(return_value, &intern->manager, intern->server_id); -} - static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServiceId) { php_phongo_commandsucceededevent_t* intern = Z_COMMANDSUCCEEDEDEVENT_OBJ_P(getThis()); @@ -180,10 +169,6 @@ static void php_phongo_commandsucceededevent_free_object(zend_object* object) zend_object_std_dtor(&intern->std); - if (!Z_ISUNDEF(intern->manager)) { - zval_ptr_dtor(&intern->manager); - } - if (intern->reply) { bson_destroy(intern->reply); } @@ -220,7 +205,7 @@ static HashTable* php_phongo_commandsucceededevent_get_debug_info(zend_object* o intern = Z_OBJ_COMMANDSUCCEEDEDEVENT(object); *is_temp = 1; - array_init_size(&retval, 10); + array_init_size(&retval, 9); ADD_ASSOC_STRING(&retval, "host", intern->host.host); ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port); @@ -240,13 +225,6 @@ static HashTable* php_phongo_commandsucceededevent_get_debug_info(zend_object* o snprintf(request_id, sizeof(request_id), "%" PRId64, intern->request_id); ADD_ASSOC_STRING(&retval, "requestId", request_id); - { - zval server; - - phongo_server_init(&server, &intern->manager, intern->server_id); - ADD_ASSOC_ZVAL_EX(&retval, "server", &server); - } - if (intern->has_service_id) { zval service_id; diff --git a/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php b/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php index d46dcfa55..ecc7607ad 100644 --- a/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php +++ b/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php @@ -28,9 +28,6 @@ final public function getReply(): object {} final public function getRequestId(): string {} - /** @deprecated */ - final public function getServer(): \MongoDB\Driver\Server {} - final public function getServiceId(): ?\MongoDB\BSON\ObjectId {} final public function getServerConnectionId(): ?int {} diff --git a/src/MongoDB/Monitoring/CommandSucceededEvent_arginfo.h b/src/MongoDB/Monitoring/CommandSucceededEvent_arginfo.h index af3d8a452..1421673bc 100644 --- a/src/MongoDB/Monitoring/CommandSucceededEvent_arginfo.h +++ b/src/MongoDB/Monitoring/CommandSucceededEvent_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f1367c3735acf21f72b420fa4adabaf7a3098713 */ + * Stub hash: d2dfb06b218c9da74356d1b8b322eb79d50e4f90 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -23,9 +23,6 @@ ZEND_END_ARG_INFO() #define arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getRequestId arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getCommandName -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getServer, 0, 0, MongoDB\\Driver\\Server, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getServiceId, 0, 0, MongoDB\\BSON\\ObjectId, 1) ZEND_END_ARG_INFO() @@ -42,7 +39,6 @@ static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getOperation static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getPort); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getReply); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getRequestId); -static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServer); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServiceId); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServerConnectionId); @@ -57,7 +53,6 @@ static const zend_function_entry class_MongoDB_Driver_Monitoring_CommandSucceede ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getPort, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getPort, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getReply, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getReply, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getRequestId, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getRequestId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) - ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServer, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_DEPRECATED) ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServiceId, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getServiceId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServerConnectionId, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getServerConnectionId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_FE_END diff --git a/src/phongo_apm.c b/src/phongo_apm.c index d7297f7b7..5fef3d50e 100644 --- a/src/phongo_apm.c +++ b/src/phongo_apm.c @@ -79,33 +79,6 @@ static HashTable* phongo_apm_get_subscribers_to_notify(zend_class_entry* subscri return subscribers; } -/* Search for a Manager associated with the given client in the request-scoped - * registry. If any Manager is found, copy it to @out, increment its ref-count, - * and return true; otherwise, set @out to undefined and return false. */ -static bool phongo_apm_copy_manager_for_client(mongoc_client_t* client, zval* out) -{ - php_phongo_manager_t* manager; - - ZVAL_UNDEF(out); - - if (!MONGODB_G(managers) || zend_hash_num_elements(MONGODB_G(managers)) == 0) { - return false; - } - - ZEND_HASH_FOREACH_PTR(MONGODB_G(managers), manager) - { - if (manager->client == client) { - ZVAL_OBJ(out, &manager->std); - Z_ADDREF_P(out); - - return true; - } - } - ZEND_HASH_FOREACH_END(); - - return false; -} - /* Dispatch an event to all subscribers in a HashTable. The caller is * responsible for ensuring that subscribers implement the correct interface. */ static void phongo_apm_dispatch_event(HashTable* subscribers, const char* function_name, zval* event) @@ -158,13 +131,6 @@ static void phongo_apm_command_started(const mongoc_apm_command_started_t* event bson_oid_copy(mongoc_apm_command_started_get_service_id(event), &p_event->service_id); } - if (!phongo_apm_copy_manager_for_client(client, &p_event->manager)) { - phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Found no Manager for client in APM event context"); - zval_ptr_dtor(&z_event); - - goto cleanup; - } - phongo_apm_dispatch_event(subscribers, "commandStarted", &z_event); zval_ptr_dtor(&z_event); @@ -207,13 +173,6 @@ static void phongo_apm_command_succeeded(const mongoc_apm_command_succeeded_t* e bson_oid_copy(mongoc_apm_command_succeeded_get_service_id(event), &p_event->service_id); } - if (!phongo_apm_copy_manager_for_client(client, &p_event->manager)) { - phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Found no Manager for client in APM event context"); - zval_ptr_dtor(&z_event); - - goto cleanup; - } - phongo_apm_dispatch_event(subscribers, "commandSucceeded", &z_event); zval_ptr_dtor(&z_event); @@ -257,13 +216,6 @@ static void phongo_apm_command_failed(const mongoc_apm_command_failed_t* event) bson_oid_copy(mongoc_apm_command_failed_get_service_id(event), &p_event->service_id); } - if (!phongo_apm_copy_manager_for_client(client, &p_event->manager)) { - phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Found no Manager for client in APM event context"); - zval_ptr_dtor(&z_event); - - goto cleanup; - } - /* We need to process and convert the error right here, otherwise * debug_info will turn into a recursive loop, and with the wrong trace * locations */ diff --git a/src/phongo_structs.h b/src/phongo_structs.h index 488e192db..ff1804a0c 100644 --- a/src/phongo_structs.h +++ b/src/phongo_structs.h @@ -281,7 +281,6 @@ typedef struct { } php_phongo_utcdatetime_t; typedef struct { - zval manager; char* command_name; char* database_name; uint32_t server_id; @@ -298,7 +297,6 @@ typedef struct { } php_phongo_commandfailedevent_t; typedef struct { - zval manager; char* command_name; char* database_name; uint32_t server_id; @@ -313,7 +311,6 @@ typedef struct { } php_phongo_commandstartedevent_t; typedef struct { - zval manager; char* command_name; char* database_name; uint32_t server_id; diff --git a/tests/apm/commandFailedEvent-debug-001.phpt b/tests/apm/commandFailedEvent-debug-001.phpt index a1647d352..fafcc2d82 100644 --- a/tests/apm/commandFailedEvent-debug-001.phpt +++ b/tests/apm/commandFailedEvent-debug-001.phpt @@ -60,9 +60,6 @@ object(MongoDB\Driver\Monitoring\CommandFailedEvent)#%d (%d) { string(%d) "%d" ["requestId"]=> string(%d) "%d" - ["server"]=> - object(MongoDB\Driver\Server)#%d (%d) {%A - } ["serviceId"]=> %r(NULL|object\(MongoDB\\BSON\\ObjectId\).*)%r ["serverConnectionId"]=> diff --git a/tests/apm/commandFailedEvent-getServer-001.phpt b/tests/apm/commandFailedEvent-getServer-001.phpt deleted file mode 100644 index bd7fc0906..000000000 --- a/tests/apm/commandFailedEvent-getServer-001.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -MongoDB\Driver\Monitoring\CommandFailedEvent::getServer() ---SKIPIF-- - - - ---FILE-- -getServer()); - } -} - -$manager = create_test_manager(); - -$subscriber = new MySubscriber(); -MongoDB\Driver\Monitoring\addSubscriber($subscriber); - -$command = new MongoDB\Driver\Command(['unsupportedCommand' => 1]); - -try { - $manager->executeCommand('admin', $command); -} catch (Exception $e) { -} - -?> ---EXPECTF-- -Deprecated: %r(Function|Method)%r MongoDB\Driver\Monitoring\CommandFailedEvent::getServer() is deprecated in %s -object(MongoDB\Driver\Server)#%d (%d) { - %A -} diff --git a/tests/apm/commandStartedEvent-debug-001.phpt b/tests/apm/commandStartedEvent-debug-001.phpt index 3923f030b..30089b3a4 100644 --- a/tests/apm/commandStartedEvent-debug-001.phpt +++ b/tests/apm/commandStartedEvent-debug-001.phpt @@ -48,9 +48,6 @@ object(MongoDB\Driver\Monitoring\CommandStartedEvent)#%d (%d) { string(%d) "%d" ["requestId"]=> string(%d) "%d" - ["server"]=> - object(MongoDB\Driver\Server)#%d (%d) {%A - } ["serviceId"]=> %r(NULL|object\(MongoDB\\BSON\\ObjectId\).*)%r ["serverConnectionId"]=> diff --git a/tests/apm/commandStartedEvent-getServer-001.phpt b/tests/apm/commandStartedEvent-getServer-001.phpt deleted file mode 100644 index 73e0c82b6..000000000 --- a/tests/apm/commandStartedEvent-getServer-001.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -MongoDB\Driver\Monitoring\CommandStartedEvent::getServer() ---SKIPIF-- - - - ---FILE-- -getServer()); - } - - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void - { - } - - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void - { - } -} - -$manager = create_test_manager(); - -$subscriber = new MySubscriber(); -MongoDB\Driver\Monitoring\addSubscriber($subscriber); - -$command = new MongoDB\Driver\Command(['ping' => 1]); -$manager->executeCommand('admin', $command); - -?> ---EXPECTF-- -Deprecated: %r(Function|Method)%r MongoDB\Driver\Monitoring\CommandStartedEvent::getServer() is deprecated in %s -object(MongoDB\Driver\Server)#%d (%d) { - %A -} diff --git a/tests/apm/commandSucceededEvent-debug-001.phpt b/tests/apm/commandSucceededEvent-debug-001.phpt index 696a76b52..18ee5cd58 100644 --- a/tests/apm/commandSucceededEvent-debug-001.phpt +++ b/tests/apm/commandSucceededEvent-debug-001.phpt @@ -48,9 +48,6 @@ object(MongoDB\Driver\Monitoring\CommandSucceededEvent)#%d (%d) { string(%d) "%d" ["requestId"]=> string(%d) "%d" - ["server"]=> - object(MongoDB\Driver\Server)#%d (%d) {%A - } ["serviceId"]=> %r(NULL|object\(MongoDB\\BSON\\ObjectId\).*)%r ["serverConnectionId"]=> diff --git a/tests/apm/commandSucceededEvent-getServer-001.phpt b/tests/apm/commandSucceededEvent-getServer-001.phpt deleted file mode 100644 index a1b0115b9..000000000 --- a/tests/apm/commandSucceededEvent-getServer-001.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -MongoDB\Driver\Monitoring\CommandSucceededEvent::getServer() ---SKIPIF-- - - - ---FILE-- -getServer()); - } - - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void - { - } -} - -$manager = create_test_manager(); - -$subscriber = new MySubscriber(); -MongoDB\Driver\Monitoring\addSubscriber($subscriber); - -$command = new MongoDB\Driver\Command(['ping' => 1]); -$manager->executeCommand('admin', $command); - -?> ---EXPECTF-- -Deprecated: %r(Function|Method)%r MongoDB\Driver\Monitoring\CommandSucceededEvent::getServer() is deprecated in %s -object(MongoDB\Driver\Server)#%d (%d) { - %A -} diff --git a/tests/manager/manager-ctor-disableClientPersistence-008.phpt b/tests/manager/manager-ctor-disableClientPersistence-008.phpt deleted file mode 100644 index 7a388c582..000000000 --- a/tests/manager/manager-ctor-disableClientPersistence-008.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -MongoDB\Driver\Manager with disableClientPersistence=true referenced by CommandStartedEvent ---SKIPIF-- - - ---FILE-- -getCommandName()); - $this->events[] = $event; - } - - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void - { - } - - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void - { - } -} - -$subscriber = new MySubscriber; - - -ini_set('mongodb.debug', 'stderr'); -$manager = create_test_manager(URI, [], ['disableClientPersistence' => true]); -ini_set('mongodb.debug', ''); - -MongoDB\Driver\Monitoring\addSubscriber($subscriber); -$command = new MongoDB\Driver\Command(['ping' => 1]); -$manager->executeCommand(DATABASE_NAME, $command); - -/* Remove the subscriber to ensure that the extension does not hold an internal - * reference to it. This guarantees that the event object (and final Manager - * reference) will be freed when the subscriber is later unset. */ -MongoDB\Driver\Monitoring\removeSubscriber($subscriber); - -echo "Unsetting manager\n"; -ini_set('mongodb.debug', 'stderr'); -unset($manager); -ini_set('mongodb.debug', ''); - -echo "Unsetting subscriber\n"; -ini_set('mongodb.debug', 'stderr'); -unset($subscriber); -ini_set('mongodb.debug', ''); - -?> -===DONE=== - ---EXPECTF-- -%A -[%s] PHONGO: DEBUG > Created client with hash: %s -[%s] PHONGO: DEBUG > Stored non-persistent client -Command started: ping -Unsetting manager -Unsetting subscriber%A -[%s] PHONGO: DEBUG > Destroying non-persistent client for Manager%A -===DONE=== diff --git a/tests/manager/manager-ctor-disableClientPersistence-009.phpt b/tests/manager/manager-ctor-disableClientPersistence-009.phpt deleted file mode 100644 index 62209a103..000000000 --- a/tests/manager/manager-ctor-disableClientPersistence-009.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -MongoDB\Driver\Manager with disableClientPersistence=true referenced by CommandSucceededEvent ---SKIPIF-- - - ---FILE-- -getCommandName()); - $this->events[] = $event; - } - - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void - { - } -} - -$subscriber = new MySubscriber; - - -ini_set('mongodb.debug', 'stderr'); -$manager = create_test_manager(URI, [], ['disableClientPersistence' => true]); -ini_set('mongodb.debug', ''); - -MongoDB\Driver\Monitoring\addSubscriber($subscriber); -$command = new MongoDB\Driver\Command(['ping' => 1]); -$manager->executeCommand(DATABASE_NAME, $command); - -/* Remove the subscriber to ensure that the extension does not hold an internal - * reference to it. This guarantees that the event object (and final Manager - * reference) will be freed when the subscriber is later unset. */ -MongoDB\Driver\Monitoring\removeSubscriber($subscriber); - -echo "Unsetting manager\n"; -ini_set('mongodb.debug', 'stderr'); -unset($manager); -ini_set('mongodb.debug', ''); - -echo "Unsetting subscriber\n"; -ini_set('mongodb.debug', 'stderr'); -unset($subscriber); -ini_set('mongodb.debug', ''); - -?> -===DONE=== - ---EXPECTF-- -%A -[%s] PHONGO: DEBUG > Created client with hash: %s -[%s] PHONGO: DEBUG > Stored non-persistent client -Command succeeded: ping -Unsetting manager -Unsetting subscriber%A -[%s] PHONGO: DEBUG > Destroying non-persistent client for Manager%A -===DONE=== diff --git a/tests/manager/manager-ctor-disableClientPersistence-010.phpt b/tests/manager/manager-ctor-disableClientPersistence-010.phpt deleted file mode 100644 index e09e6fe6c..000000000 --- a/tests/manager/manager-ctor-disableClientPersistence-010.phpt +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -MongoDB\Driver\Manager with disableClientPersistence=true referenced by CommandFailedEvent ---SKIPIF-- - - ---FILE-- -getCommandName()); - $this->events[] = $event; - } -} - -$subscriber = new MySubscriber; - - -ini_set('mongodb.debug', 'stderr'); -$manager = create_test_manager(URI, [], ['disableClientPersistence' => true]); -ini_set('mongodb.debug', ''); - -MongoDB\Driver\Monitoring\addSubscriber($subscriber); -$command = new MongoDB\Driver\Command(['unsupportedCommand' => 1]); -throws(function () use ($manager, $command) { - $manager->executeCommand(DATABASE_NAME, $command); -}, MongoDB\Driver\Exception\CommandException::class); - -/* Remove the subscriber to ensure that the extension does not hold an internal - * reference to it. This guarantees that the event object (and final Manager - * reference) will be freed when the subscriber is later unset. */ -MongoDB\Driver\Monitoring\removeSubscriber($subscriber); - -echo "Unsetting manager\n"; -ini_set('mongodb.debug', 'stderr'); -unset($manager); -ini_set('mongodb.debug', ''); - -echo "Unsetting subscriber\n"; -ini_set('mongodb.debug', 'stderr'); -unset($subscriber); -ini_set('mongodb.debug', ''); - -?> -===DONE=== - ---EXPECTF-- -%A -[%s] PHONGO: DEBUG > Created client with hash: %s -[%s] PHONGO: DEBUG > Stored non-persistent client -Command failed: unsupportedCommand -OK: Got MongoDB\Driver\Exception\CommandException -Unsetting manager -Unsetting subscriber%A -[%s] PHONGO: DEBUG > Destroying non-persistent client for Manager%A -===DONE=== diff --git a/tests/manager/manager-ctor-disableClientPersistence-011.phpt b/tests/manager/manager-ctor-disableClientPersistence-011.phpt deleted file mode 100644 index 3e8a53353..000000000 --- a/tests/manager/manager-ctor-disableClientPersistence-011.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -MongoDB\Driver\Manager with disableClientPersistence=true referenced by APM subscriber freed in RSHUTDOWN ---SKIPIF-- - - ---FILE-- -getCommandName()); - $this->events[] = $event; - } - - public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void - { - } - - public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void - { - } -} - -$subscriber = new MySubscriber; - - -ini_set('mongodb.debug', 'stderr'); -$manager = create_test_manager(URI, [], ['disableClientPersistence' => true]); -ini_set('mongodb.debug', ''); - -MongoDB\Driver\Monitoring\addSubscriber($subscriber); -$command = new MongoDB\Driver\Command(['ping' => 1]); -$manager->executeCommand(DATABASE_NAME, $command); - -ini_set('mongodb.debug', 'stderr'); - -echo "Unsetting manager\n"; -unset($manager); - -echo "Unsetting subscriber\n"; -unset($subscriber); - -/* Since the subscriber has not been removed, the remaining internal reference to - * it will be freed during RSHUTDOWN. */ - -?> -===DONE=== - ---EXPECTF-- -%A -[%s] PHONGO: DEBUG > Created client with hash: %s -[%s] PHONGO: DEBUG > Stored non-persistent client -Command started: ping -Unsetting manager -Unsetting subscriber -===DONE===%A -[%s] PHONGO: DEBUG > Destroying non-persistent client for Manager%A