diff --git a/src/MongoDB/Monitoring/CommandFailedEvent.c b/src/MongoDB/Monitoring/CommandFailedEvent.c index 75a8e3e2e..bec83a1fa 100644 --- a/src/MongoDB/Monitoring/CommandFailedEvent.c +++ b/src/MongoDB/Monitoring/CommandFailedEvent.c @@ -31,7 +31,6 @@ zend_class_entry* php_phongo_commandfailedevent_ce; PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_CommandFailedEvent) -/* Returns the command name for this event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getCommandName) { php_phongo_commandfailedevent_t* intern; @@ -43,7 +42,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getCommandName) RETVAL_STRING(intern->command_name); } -/* Returns the database name for this event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDatabaseName) { php_phongo_commandfailedevent_t* intern; @@ -55,7 +53,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDatabaseName) RETVAL_STRING(intern->database_name); } -/* Returns the event's duration in microseconds */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDurationMicros) { php_phongo_commandfailedevent_t* intern; @@ -67,7 +64,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDurationMicro RETURN_LONG(intern->duration_micros); } -/* Returns the error document associated with the event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getError) { php_phongo_commandfailedevent_t* intern; @@ -79,7 +75,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getError) RETURN_ZVAL(&intern->z_error, 1, 0); } -/* Returns the event's operation ID */ +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getHost) +{ + php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); + + PHONGO_PARSE_PARAMETERS_NONE(); + + RETVAL_STRING(intern->host.host); +} + static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getOperationId) { php_phongo_commandfailedevent_t* intern; @@ -93,7 +97,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getOperationId) RETVAL_STRING(operation_id); } -/* Returns the reply document associated with the event */ +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getPort) +{ + php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); + + PHONGO_PARSE_PARAMETERS_NONE(); + + RETVAL_LONG(intern->host.port); +} + static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getReply) { php_phongo_commandfailedevent_t* intern; @@ -113,7 +125,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getReply) RETURN_ZVAL(&state.zchild, 0, 1); } -/* Returns the event's request ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId) { php_phongo_commandfailedevent_t* intern; @@ -127,7 +138,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId) RETVAL_STRING(request_id); } -/* Returns the Server from which the event originated */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer) { php_phongo_commandfailedevent_t* intern; @@ -139,7 +149,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer) phongo_server_init(return_value, &intern->manager, intern->server_id); } -/* Returns the event's service ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId) { php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); @@ -153,7 +162,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId) phongo_objectid_new(return_value, &intern->service_id); } -/* Returns the event's server connection ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServerConnectionId) { php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis()); @@ -174,12 +182,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServerConnect RETURN_LONG(intern->server_connection_id); } -/** - * Event thrown when a command has failed to execute. - * - * This class is only constructed internally. - */ - /* MongoDB\Driver\Monitoring\CommandFailedEvent object handlers */ static zend_object_handlers php_phongo_handler_commandfailedevent; @@ -233,17 +235,16 @@ static HashTable* php_phongo_commandfailedevent_get_debug_info(phongo_compat_obj intern = Z_OBJ_COMMANDFAILEDEVENT(PHONGO_COMPAT_GET_OBJ(object)); *is_temp = 1; - array_init_size(&retval, 6); + array_init_size(&retval, 11); + ADD_ASSOC_STRING(&retval, "host", intern->host.host); + ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port); ADD_ASSOC_STRING(&retval, "commandName", intern->command_name); ADD_ASSOC_INT64(&retval, "durationMicros", intern->duration_micros); ADD_ASSOC_ZVAL_EX(&retval, "error", &intern->z_error); Z_ADDREF(intern->z_error); - snprintf(operation_id, sizeof(operation_id), "%" PRId64, intern->operation_id); - ADD_ASSOC_STRING(&retval, "operationId", operation_id); - if (!php_phongo_bson_to_zval_ex(intern->reply, &reply_state)) { zval_ptr_dtor(&reply_state.zchild); goto done; @@ -251,6 +252,9 @@ static HashTable* php_phongo_commandfailedevent_get_debug_info(phongo_compat_obj ADD_ASSOC_ZVAL(&retval, "reply", &reply_state.zchild); + snprintf(operation_id, sizeof(operation_id), "%" PRId64, intern->operation_id); + ADD_ASSOC_STRING(&retval, "operationId", operation_id); + snprintf(request_id, sizeof(request_id), "%" PRId64, intern->request_id); ADD_ASSOC_STRING(&retval, "requestId", request_id); diff --git a/src/MongoDB/Monitoring/CommandFailedEvent.stub.php b/src/MongoDB/Monitoring/CommandFailedEvent.stub.php index 9c8c9041b..22dc30616 100644 --- a/src/MongoDB/Monitoring/CommandFailedEvent.stub.php +++ b/src/MongoDB/Monitoring/CommandFailedEvent.stub.php @@ -19,12 +19,17 @@ final public function getDurationMicros(): int {} final public function getError(): \Exception {} + final public function getHost(): string {} + final public function getOperationId(): string {} + final public function getPort(): int {} + 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 {} diff --git a/src/MongoDB/Monitoring/CommandFailedEvent_arginfo.h b/src/MongoDB/Monitoring/CommandFailedEvent_arginfo.h index d193f7075..39d94c991 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: 6fd7c6597ad8e67b399cf4e7c41bb6cc5e6666d6 */ + * Stub hash: 3e04d69c1e4a42ee94149ac14ce1f3595448b472 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -15,8 +15,12 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getError, 0, 0, Exception, 0) ZEND_END_ARG_INFO() +#define arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getHost arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getCommandName + #define arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getOperationId arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getCommandName +#define arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getPort arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getDurationMicros + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getReply, 0, 0, IS_OBJECT, 0) ZEND_END_ARG_INFO() @@ -37,7 +41,9 @@ static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getCommandName) static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDatabaseName); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDurationMicros); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getError); +static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getHost); 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); @@ -51,10 +57,12 @@ static const zend_function_entry class_MongoDB_Driver_Monitoring_CommandFailedEv ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getDatabaseName, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getDatabaseName, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getDurationMicros, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getDurationMicros, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getError, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getError, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getHost, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getHost, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandFailedEvent, getOperationId, arginfo_class_MongoDB_Driver_Monitoring_CommandFailedEvent_getOperationId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + 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_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 f45159e8c..5c9f7446b 100644 --- a/src/MongoDB/Monitoring/CommandStartedEvent.c +++ b/src/MongoDB/Monitoring/CommandStartedEvent.c @@ -31,7 +31,6 @@ zend_class_entry* php_phongo_commandstartedevent_ce; PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_CommandStartedEvent) -/* Returns the command document associated with the event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommand) { php_phongo_commandstartedevent_t* intern; @@ -51,7 +50,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommand) RETURN_ZVAL(&state.zchild, 0, 1); } -/* Returns the command name for this event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommandName) { php_phongo_commandstartedevent_t* intern; @@ -63,7 +61,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommandName) RETVAL_STRING(intern->command_name); } -/* Returns the database name for this event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getDatabaseName) { php_phongo_commandstartedevent_t* intern; @@ -75,7 +72,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getDatabaseName RETVAL_STRING(intern->database_name); } -/* Returns the event's operation ID */ +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getHost) +{ + php_phongo_commandstartedevent_t* intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); + + PHONGO_PARSE_PARAMETERS_NONE(); + + RETVAL_STRING(intern->host.host); +} + static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getOperationId) { php_phongo_commandstartedevent_t* intern; @@ -89,7 +94,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getOperationId) RETVAL_STRING(operation_id); } -/* Returns the event's request ID */ +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getPort) +{ + php_phongo_commandstartedevent_t* intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); + + PHONGO_PARSE_PARAMETERS_NONE(); + + RETVAL_LONG(intern->host.port); +} + static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getRequestId) { php_phongo_commandstartedevent_t* intern; @@ -103,7 +116,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getRequestId) RETVAL_STRING(request_id); } -/* Returns the Server from which the event originated */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServer) { php_phongo_commandstartedevent_t* intern; @@ -115,7 +127,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServer) phongo_server_init(return_value, &intern->manager, intern->server_id); } -/* Returns the event's service ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServiceId) { php_phongo_commandstartedevent_t* intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); @@ -129,7 +140,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServiceId) phongo_objectid_new(return_value, &intern->service_id); } -/* Returns the event's server connection ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServerConnectionId) { php_phongo_commandstartedevent_t* intern = Z_COMMANDSTARTEDEVENT_OBJ_P(getThis()); @@ -150,12 +160,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getServerConnec RETURN_LONG(intern->server_connection_id); } -/** - * Event thrown when a command has started to execute. - * - * This class is only constructed internally. - */ - /* MongoDB\Driver\Monitoring\CommandStartedEvent object handlers */ static zend_object_handlers php_phongo_handler_commandstartedevent; @@ -205,7 +209,12 @@ static HashTable* php_phongo_commandstartedevent_get_debug_info(phongo_compat_ob intern = Z_OBJ_COMMANDSTARTEDEVENT(PHONGO_COMPAT_GET_OBJ(object)); *is_temp = 1; - array_init_size(&retval, 6); + array_init_size(&retval, 10); + + ADD_ASSOC_STRING(&retval, "host", intern->host.host); + ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port); + ADD_ASSOC_STRING(&retval, "commandName", intern->command_name); + ADD_ASSOC_STRING(&retval, "databaseName", intern->database_name); if (!php_phongo_bson_to_zval_ex(intern->command, &command_state)) { zval_ptr_dtor(&command_state.zchild); @@ -214,9 +223,6 @@ static HashTable* php_phongo_commandstartedevent_get_debug_info(phongo_compat_ob ADD_ASSOC_ZVAL(&retval, "command", &command_state.zchild); - ADD_ASSOC_STRING(&retval, "commandName", intern->command_name); - ADD_ASSOC_STRING(&retval, "databaseName", intern->database_name); - snprintf(operation_id, sizeof(operation_id), "%" PRId64, intern->operation_id); ADD_ASSOC_STRING(&retval, "operationId", operation_id); diff --git a/src/MongoDB/Monitoring/CommandStartedEvent.stub.php b/src/MongoDB/Monitoring/CommandStartedEvent.stub.php index c3dbf3718..f0ce09513 100644 --- a/src/MongoDB/Monitoring/CommandStartedEvent.stub.php +++ b/src/MongoDB/Monitoring/CommandStartedEvent.stub.php @@ -17,10 +17,15 @@ final public function getCommandName(): string {} final public function getDatabaseName(): string {} + final public function getHost(): string {} + final public function getOperationId(): string {} + 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 {} diff --git a/src/MongoDB/Monitoring/CommandStartedEvent_arginfo.h b/src/MongoDB/Monitoring/CommandStartedEvent_arginfo.h index f52bb79e1..34d7bd51c 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: 4ff134c852d47ac645fcc505d3b9319eb46a3899 */ + * Stub hash: be9f02816a4b44d256cb139d12c55cc9ac5d15e5 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -12,8 +12,13 @@ ZEND_END_ARG_INFO() #define arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getDatabaseName arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getCommandName +#define arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getHost arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getCommandName + #define arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getOperationId arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getCommandName +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getPort, 0, 0, IS_LONG, 0) +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) @@ -30,7 +35,9 @@ static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, __construct); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommand); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommandName); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandStartedEvent, getDatabaseName); +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); @@ -42,9 +49,11 @@ static const zend_function_entry class_MongoDB_Driver_Monitoring_CommandStartedE ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommand, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getCommandName, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getCommandName, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getDatabaseName, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getDatabaseName, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Monitoring_CommandStartedEvent, getHost, arginfo_class_MongoDB_Driver_Monitoring_CommandStartedEvent_getHost, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) 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_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 e635850a1..6902a6ef2 100644 --- a/src/MongoDB/Monitoring/CommandSucceededEvent.c +++ b/src/MongoDB/Monitoring/CommandSucceededEvent.c @@ -31,7 +31,6 @@ zend_class_entry* php_phongo_commandsucceededevent_ce; PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_CommandSucceededEvent) -/* Returns the command name for this event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getCommandName) { php_phongo_commandsucceededevent_t* intern; @@ -43,7 +42,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getCommandNam RETVAL_STRING(intern->command_name); } -/* Returns the database name for this event */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDatabaseName) { php_phongo_commandsucceededevent_t* intern; @@ -55,7 +53,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDatabaseNa RETVAL_STRING(intern->database_name); } -/* Returns the event's duration in microseconds */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDurationMicros) { php_phongo_commandsucceededevent_t* intern; @@ -67,7 +64,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDurationMi RETURN_LONG(intern->duration_micros); } -/* Returns the event's operation ID */ +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getHost) +{ + php_phongo_commandsucceededevent_t* intern = Z_COMMANDSUCCEEDEDEVENT_OBJ_P(getThis()); + + PHONGO_PARSE_PARAMETERS_NONE(); + + RETVAL_STRING(intern->host.host); +} + static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getOperationId) { php_phongo_commandsucceededevent_t* intern; @@ -81,7 +86,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getOperationI RETVAL_STRING(operation_id); } -/* Returns the reply document associated with the event */ +static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getPort) +{ + php_phongo_commandsucceededevent_t* intern = Z_COMMANDSUCCEEDEDEVENT_OBJ_P(getThis()); + + PHONGO_PARSE_PARAMETERS_NONE(); + + RETVAL_LONG(intern->host.port); +} + static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getReply) { php_phongo_commandsucceededevent_t* intern; @@ -101,7 +114,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getReply) RETURN_ZVAL(&state.zchild, 0, 1); } -/* Returns the event's request ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getRequestId) { php_phongo_commandsucceededevent_t* intern; @@ -115,7 +127,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getRequestId) RETVAL_STRING(request_id); } -/* Returns the Server from which the event originated */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServer) { php_phongo_commandsucceededevent_t* intern; @@ -127,7 +138,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServer) phongo_server_init(return_value, &intern->manager, intern->server_id); } -/* Returns the event's service ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServiceId) { php_phongo_commandsucceededevent_t* intern = Z_COMMANDSUCCEEDEDEVENT_OBJ_P(getThis()); @@ -141,7 +151,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServiceId) phongo_objectid_new(return_value, &intern->service_id); } -/* Returns the event's server connection ID */ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServerConnectionId) { php_phongo_commandsucceededevent_t* intern = Z_COMMANDSUCCEEDEDEVENT_OBJ_P(getThis()); @@ -162,12 +171,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getServerConn RETURN_LONG(intern->server_connection_id); } -/** - * Event thrown when a command has succeeded to execute. - * - * This class is only constructed internally. - */ - /* MongoDB\Driver\Monitoring\CommandSucceededEvent object handlers */ static zend_object_handlers php_phongo_handler_commandsucceededevent; @@ -217,14 +220,13 @@ static HashTable* php_phongo_commandsucceededevent_get_debug_info(phongo_compat_ intern = Z_OBJ_COMMANDSUCCEEDEDEVENT(PHONGO_COMPAT_GET_OBJ(object)); *is_temp = 1; - array_init_size(&retval, 6); + array_init_size(&retval, 10); + ADD_ASSOC_STRING(&retval, "host", intern->host.host); + ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port); ADD_ASSOC_STRING(&retval, "commandName", intern->command_name); ADD_ASSOC_INT64(&retval, "durationMicros", intern->duration_micros); - snprintf(operation_id, sizeof(operation_id), "%" PRId64, intern->operation_id); - ADD_ASSOC_STRING(&retval, "operationId", operation_id); - if (!php_phongo_bson_to_zval_ex(intern->reply, &reply_state)) { zval_ptr_dtor(&reply_state.zchild); goto done; @@ -232,6 +234,9 @@ static HashTable* php_phongo_commandsucceededevent_get_debug_info(phongo_compat_ ADD_ASSOC_ZVAL(&retval, "reply", &reply_state.zchild); + snprintf(operation_id, sizeof(operation_id), "%" PRId64, intern->operation_id); + ADD_ASSOC_STRING(&retval, "operationId", operation_id); + snprintf(request_id, sizeof(request_id), "%" PRId64, intern->request_id); ADD_ASSOC_STRING(&retval, "requestId", request_id); diff --git a/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php b/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php index e671c06b6..4f2ec888a 100644 --- a/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php +++ b/src/MongoDB/Monitoring/CommandSucceededEvent.stub.php @@ -17,12 +17,17 @@ final public function getDatabaseName(): string {} final public function getDurationMicros(): int {} + final public function getHost(): string {} + final public function getOperationId(): string {} + final public function getPort(): int {} + 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 {} diff --git a/src/MongoDB/Monitoring/CommandSucceededEvent_arginfo.h b/src/MongoDB/Monitoring/CommandSucceededEvent_arginfo.h index 8ccdb3bb5..047fdcf8f 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: 86e4fd7aeffe8b4d03c32f4221450d80b3f322a9 */ + * Stub hash: c29b3eb0f340867cc1707b29e935f42fdbc0f031 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -12,8 +12,12 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getDurationMicros, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() +#define arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getHost arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getCommandName + #define arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getOperationId arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getCommandName +#define arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getPort arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getDurationMicros + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getReply, 0, 0, IS_OBJECT, 0) ZEND_END_ARG_INFO() @@ -33,7 +37,9 @@ static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, __construct) static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getCommandName); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDatabaseName); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDurationMicros); +static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getHost); static ZEND_METHOD(MongoDB_Driver_Monitoring_CommandSucceededEvent, getOperationId); +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); @@ -46,10 +52,12 @@ static const zend_function_entry class_MongoDB_Driver_Monitoring_CommandSucceede ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getCommandName, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getCommandName, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDatabaseName, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getDatabaseName, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getDurationMicros, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getDurationMicros, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getHost, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getHost, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) ZEND_ME(MongoDB_Driver_Monitoring_CommandSucceededEvent, getOperationId, arginfo_class_MongoDB_Driver_Monitoring_CommandSucceededEvent_getOperationId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) + 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_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 b0c3d1a6c..0f622d002 100644 --- a/src/phongo_apm.c +++ b/src/phongo_apm.c @@ -143,6 +143,8 @@ static void phongo_apm_command_started(const mongoc_apm_command_started_t* event object_init_ex(&z_event, php_phongo_commandstartedevent_ce); p_event = Z_COMMANDSTARTEDEVENT_OBJ_P(&z_event); + memcpy(&p_event->host, mongoc_apm_command_started_get_host(event), sizeof(mongoc_host_list_t)); + p_event->command_name = estrdup(mongoc_apm_command_started_get_command_name(event)); p_event->database_name = estrdup(mongoc_apm_command_started_get_database_name(event)); p_event->server_id = mongoc_apm_command_started_get_server_id(event); @@ -189,6 +191,8 @@ static void phongo_apm_command_succeeded(const mongoc_apm_command_succeeded_t* e object_init_ex(&z_event, php_phongo_commandsucceededevent_ce); p_event = Z_COMMANDSUCCEEDEDEVENT_OBJ_P(&z_event); + memcpy(&p_event->host, mongoc_apm_command_succeeded_get_host(event), sizeof(mongoc_host_list_t)); + p_event->command_name = estrdup(mongoc_apm_command_succeeded_get_command_name(event)); p_event->database_name = estrdup(mongoc_apm_command_succeeded_get_database_name(event)); p_event->server_id = mongoc_apm_command_succeeded_get_server_id(event); @@ -237,6 +241,8 @@ static void phongo_apm_command_failed(const mongoc_apm_command_failed_t* event) object_init_ex(&z_event, php_phongo_commandfailedevent_ce); p_event = Z_COMMANDFAILEDEVENT_OBJ_P(&z_event); + memcpy(&p_event->host, mongoc_apm_command_failed_get_host(event), sizeof(mongoc_host_list_t)); + p_event->command_name = estrdup(mongoc_apm_command_failed_get_command_name(event)); p_event->database_name = estrdup(mongoc_apm_command_failed_get_database_name(event)); p_event->server_id = mongoc_apm_command_failed_get_server_id(event); diff --git a/src/phongo_structs.h b/src/phongo_structs.h index 3c0979438..488e192db 100644 --- a/src/phongo_structs.h +++ b/src/phongo_structs.h @@ -281,48 +281,51 @@ typedef struct { } php_phongo_utcdatetime_t; typedef struct { - zval manager; - char* command_name; - char* database_name; - uint32_t server_id; - int64_t operation_id; - int64_t request_id; - int64_t duration_micros; - bson_t* reply; - zval z_error; - bool has_service_id; - bson_oid_t service_id; - int64_t server_connection_id; - zend_object std; + zval manager; + char* command_name; + char* database_name; + uint32_t server_id; + int64_t operation_id; + int64_t request_id; + int64_t duration_micros; + bson_t* reply; + zval z_error; + bool has_service_id; + bson_oid_t service_id; + int64_t server_connection_id; + mongoc_host_list_t host; + zend_object std; } php_phongo_commandfailedevent_t; typedef struct { - zval manager; - char* command_name; - char* database_name; - uint32_t server_id; - int64_t operation_id; - int64_t request_id; - bson_t* command; - bool has_service_id; - bson_oid_t service_id; - int64_t server_connection_id; - zend_object std; + zval manager; + char* command_name; + char* database_name; + uint32_t server_id; + int64_t operation_id; + int64_t request_id; + bson_t* command; + bool has_service_id; + bson_oid_t service_id; + int64_t server_connection_id; + mongoc_host_list_t host; + zend_object std; } php_phongo_commandstartedevent_t; typedef struct { - zval manager; - char* command_name; - char* database_name; - uint32_t server_id; - int64_t operation_id; - int64_t request_id; - int64_t duration_micros; - bson_t* reply; - bool has_service_id; - bson_oid_t service_id; - int64_t server_connection_id; - zend_object std; + zval manager; + char* command_name; + char* database_name; + uint32_t server_id; + int64_t operation_id; + int64_t request_id; + int64_t duration_micros; + bson_t* reply; + bool has_service_id; + bson_oid_t service_id; + int64_t server_connection_id; + mongoc_host_list_t host; + zend_object std; } php_phongo_commandsucceededevent_t; typedef struct { diff --git a/tests/apm/commandFailedEvent-001.phpt b/tests/apm/commandFailedEvent-001.phpt index 14b409a9b..ac09b30f4 100644 --- a/tests/apm/commandFailedEvent-001.phpt +++ b/tests/apm/commandFailedEvent-001.phpt @@ -31,10 +31,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($event->getDurationMicros()); echo "getDurationMicros() returns > 0: ", $event->getDurationMicros() > 0 ? 'yes' : 'no', "\n"; var_dump($event->getError() instanceof MongoDB\Driver\Exception\Exception); + var_dump($event->getHost()); var_dump($event->getOperationId()); + var_dump($event->getPort()); var_dump($event->getReply()); var_dump($event->getRequestId()); - var_dump($event->getServer()); /* Note: getServerConnectionId() and getServiceId() have more stringent * requirements and are tested separately. */ @@ -60,11 +61,10 @@ string(5) "admin" int(%d) getDurationMicros() returns > 0: yes bool(true) +string(%d) "%s" string(%d) "%d" +int(%d) object(stdClass)#%d (%d) { %A } string(%d) "%d" -object(MongoDB\Driver\Server)#%d (%d) { - %A -} diff --git a/tests/apm/commandFailedEvent-debug-001.phpt b/tests/apm/commandFailedEvent-debug-001.phpt index ba8383b3b..a1647d352 100644 --- a/tests/apm/commandFailedEvent-debug-001.phpt +++ b/tests/apm/commandFailedEvent-debug-001.phpt @@ -42,6 +42,10 @@ throws(function() use ($manager, $command) { --EXPECTF-- object(MongoDB\Driver\Monitoring\CommandFailedEvent)#%d (%d) { + ["host"]=> + string(%d) "%s" + ["port"]=> + int(%d) ["commandName"]=> string(9) "aggregate" ["durationMicros"]=> @@ -49,11 +53,11 @@ object(MongoDB\Driver\Monitoring\CommandFailedEvent)#%d (%d) { ["error"]=> object(MongoDB\Driver\Exception\ServerException)#%d (%d) {%A } - ["operationId"]=> - string(%d) "%d" ["reply"]=> object(stdClass)#%d (%d) {%A } + ["operationId"]=> + string(%d) "%d" ["requestId"]=> string(%d) "%d" ["server"]=> diff --git a/tests/apm/commandFailedEvent-getServer-001.phpt b/tests/apm/commandFailedEvent-getServer-001.phpt new file mode 100644 index 000000000..bd7fc0906 --- /dev/null +++ b/tests/apm/commandFailedEvent-getServer-001.phpt @@ -0,0 +1,44 @@ +--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-001.phpt b/tests/apm/commandStartedEvent-001.phpt index 4c240cbe5..972685341 100644 --- a/tests/apm/commandStartedEvent-001.phpt +++ b/tests/apm/commandStartedEvent-001.phpt @@ -15,9 +15,10 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($event->getCommand()); var_dump($event->getCommandName()); var_dump($event->getDatabaseName()); + var_dump($event->getHost()); var_dump($event->getOperationId()); + var_dump($event->getPort()); var_dump($event->getRequestId()); - var_dump($event->getServer()); /* Note: getServerConnectionId() and getServiceId() have more stringent * requirements and are tested separately. */ @@ -47,8 +48,7 @@ object(stdClass)#%d (%d) { } string(4) "ping" string(5) "admin" +string(%d) "%s" string(%d) "%d" +int(%d) string(%d) "%d" -object(MongoDB\Driver\Server)#%d (%d) { - %A -} diff --git a/tests/apm/commandStartedEvent-debug-001.phpt b/tests/apm/commandStartedEvent-debug-001.phpt index b9b090554..3923f030b 100644 --- a/tests/apm/commandStartedEvent-debug-001.phpt +++ b/tests/apm/commandStartedEvent-debug-001.phpt @@ -33,13 +33,17 @@ $manager->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(['ping' => 1] --EXPECTF-- object(MongoDB\Driver\Monitoring\CommandStartedEvent)#%d (%d) { - ["command"]=> - object(stdClass)#%d (%d) {%A - } + ["host"]=> + string(%d) "%s" + ["port"]=> + int(%d) ["commandName"]=> string(4) "ping" ["databaseName"]=> string(%d) "%s" + ["command"]=> + object(stdClass)#%d (%d) {%A + } ["operationId"]=> string(%d) "%d" ["requestId"]=> diff --git a/tests/apm/commandStartedEvent-getServer-001.phpt b/tests/apm/commandStartedEvent-getServer-001.phpt new file mode 100644 index 000000000..73e0c82b6 --- /dev/null +++ b/tests/apm/commandStartedEvent-getServer-001.phpt @@ -0,0 +1,40 @@ +--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-001.phpt b/tests/apm/commandSucceededEvent-001.phpt index c502dac4d..988dc5b41 100644 --- a/tests/apm/commandSucceededEvent-001.phpt +++ b/tests/apm/commandSucceededEvent-001.phpt @@ -28,10 +28,11 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber var_dump($event->getDatabaseName()); var_dump($event->getDurationMicros()); echo "getDurationMicros() returns > 0: ", $event->getDurationMicros() > 0 ? 'yes' : 'no', "\n"; + var_dump($event->getHost()); var_dump($event->getOperationId()); + var_dump($event->getPort()); var_dump($event->getReply()); var_dump($event->getRequestId()); - var_dump($event->getServer()); /* Note: getServerConnectionId() and getServiceId() have more stringent * requirements and are tested separately. */ @@ -56,11 +57,10 @@ string(4) "ping" string(5) "admin" int(%d) getDurationMicros() returns > 0: yes +string(%d) "%s" string(%d) "%d" +int(%d) object(stdClass)#%d (%d) { %A } string(%d) "%d" -object(MongoDB\Driver\Server)#%d (%d) { - %A -} diff --git a/tests/apm/commandSucceededEvent-debug-001.phpt b/tests/apm/commandSucceededEvent-debug-001.phpt index 361d2be23..696a76b52 100644 --- a/tests/apm/commandSucceededEvent-debug-001.phpt +++ b/tests/apm/commandSucceededEvent-debug-001.phpt @@ -33,15 +33,19 @@ $manager->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(['ping' => 1] --EXPECTF-- object(MongoDB\Driver\Monitoring\CommandSucceededEvent)#%d (%d) { + ["host"]=> + string(%d) "%s" + ["port"]=> + int(%d) ["commandName"]=> string(4) "ping" ["durationMicros"]=> int(%d) - ["operationId"]=> - string(%d) "%d" ["reply"]=> object(stdClass)#%d (%d) {%A } + ["operationId"]=> + string(%d) "%d" ["requestId"]=> string(%d) "%d" ["server"]=> diff --git a/tests/apm/commandSucceededEvent-getServer-001.phpt b/tests/apm/commandSucceededEvent-getServer-001.phpt new file mode 100644 index 000000000..a1b0115b9 --- /dev/null +++ b/tests/apm/commandSucceededEvent-getServer-001.phpt @@ -0,0 +1,42 @@ +--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 +}