Skip to content

PHPC-578: phongo_execute_command() should still throw ExecutionTimeoutException #809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2018
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
8 changes: 6 additions & 2 deletions php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_d
}

if (domain == MONGOC_ERROR_SERVER) {
if (code == 50) {
if (code == PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT) {
return php_phongo_executiontimeoutexception_ce;
}

Expand Down Expand Up @@ -865,7 +865,11 @@ int phongo_execute_command(mongoc_client_t* client, php_phongo_command_type_t ty
return false;
}
if (!result) {
if (error.domain == MONGOC_ERROR_SERVER || error.domain == MONGOC_ERROR_WRITE_CONCERN) {
/* Server errors (other than ExceededTimeLimit) and write concern errors
* may use CommandException and report the result document for the
* failed command. For BC, ExceededTimeLimit errors will continue to use
* ExcecutionTimeoutException and omit the result document. */
if ((error.domain == MONGOC_ERROR_SERVER && error.code != PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT) || error.domain == MONGOC_ERROR_WRITE_CONCERN) {
#if PHP_VERSION_ID >= 70000
zval zv;
#else
Expand Down
4 changes: 4 additions & 0 deletions php_phongo.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ typedef enum {
PHONGO_ERROR_LOGIC = 9
} php_phongo_error_domain_t;

/* This constant is used for determining if a server error for an exceeded query
* or command should select ExecutionTimeoutException. */
#define PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT 50

zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_domain_t */ domain, uint32_t /* mongoc_error_code_t */ code);
zend_class_entry* phongo_exception_from_phongo_domain(php_phongo_error_domain_t domain);
void phongo_throw_exception(php_phongo_error_domain_t domain TSRMLS_DC, const char* format, ...)
Expand Down