Skip to content

Commit 81143f4

Browse files
committed
Merge pull request #809
2 parents 26a70b4 + c154b49 commit 81143f4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

php_phongo.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_d
143143
}
144144

145145
if (domain == MONGOC_ERROR_SERVER) {
146-
if (code == 50) {
146+
if (code == PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT) {
147147
return php_phongo_executiontimeoutexception_ce;
148148
}
149149

@@ -865,7 +865,11 @@ int phongo_execute_command(mongoc_client_t* client, php_phongo_command_type_t ty
865865
return false;
866866
}
867867
if (!result) {
868-
if (error.domain == MONGOC_ERROR_SERVER || error.domain == MONGOC_ERROR_WRITE_CONCERN) {
868+
/* Server errors (other than ExceededTimeLimit) and write concern errors
869+
* may use CommandException and report the result document for the
870+
* failed command. For BC, ExceededTimeLimit errors will continue to use
871+
* ExcecutionTimeoutException and omit the result document. */
872+
if ((error.domain == MONGOC_ERROR_SERVER && error.code != PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT) || error.domain == MONGOC_ERROR_WRITE_CONCERN) {
869873
#if PHP_VERSION_ID >= 70000
870874
zval zv;
871875
#else

php_phongo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ typedef enum {
9393
PHONGO_ERROR_LOGIC = 9
9494
} php_phongo_error_domain_t;
9595

96+
/* This constant is used for determining if a server error for an exceeded query
97+
* or command should select ExecutionTimeoutException. */
98+
#define PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT 50
99+
96100
zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_domain_t */ domain, uint32_t /* mongoc_error_code_t */ code);
97101
zend_class_entry* phongo_exception_from_phongo_domain(php_phongo_error_domain_t domain);
98102
void phongo_throw_exception(php_phongo_error_domain_t domain TSRMLS_DC, const char* format, ...)

0 commit comments

Comments
 (0)