Skip to content

Commit 1fe351f

Browse files
committed
PHPC-278: nModified may be null for legacy writes
1 parent 322068c commit 1fe351f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/MongoDB/WriteResult.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ PHP_METHOD(WriteResult, getMatchedCount)
8383
RETURN_LONG(intern->write_result.nMatched);
8484
}
8585
/* }}} */
86-
/* {{{ proto integer WriteResult::getModifiedCount()
86+
/* {{{ proto integer|null WriteResult::getModifiedCount()
8787
Returns the number of documents that were actually modified by an update */
8888
PHP_METHOD(WriteResult, getModifiedCount)
8989
{
@@ -97,6 +97,9 @@ PHP_METHOD(WriteResult, getModifiedCount)
9797
return;
9898
}
9999

100+
if (intern->write_result.omit_nModified) {
101+
RETURN_NULL();
102+
}
100103

101104
RETURN_LONG(intern->write_result.nModified);
102105
}
@@ -433,7 +436,11 @@ HashTable *php_phongo_writeresult_get_debug_info(zval *object, int *is_temp TSRM
433436

434437
add_assoc_long_ex(&retval, ZEND_STRS("nInserted"), intern->write_result.nInserted);
435438
add_assoc_long_ex(&retval, ZEND_STRS("nMatched"), intern->write_result.nMatched);
436-
add_assoc_long_ex(&retval, ZEND_STRS("nModified"), intern->write_result.nModified);
439+
if (intern->write_result.omit_nModified) {
440+
add_assoc_null_ex(&retval, ZEND_STRS("nModified"));
441+
} else {
442+
add_assoc_long_ex(&retval, ZEND_STRS("nModified"), intern->write_result.nModified);
443+
}
437444
add_assoc_long_ex(&retval, ZEND_STRS("nRemoved"), intern->write_result.nRemoved);
438445
add_assoc_long_ex(&retval, ZEND_STRS("nUpserted"), intern->write_result.nUpserted);
439446

0 commit comments

Comments
 (0)