File tree Expand file tree Collapse file tree 2 files changed +47
-2
lines changed
Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -126,11 +126,12 @@ static void php_phongo_cursor_iterator_move_forward(zend_object_iterator* iter T
126126 php_phongo_bson_to_zval_ex (bson_get_data (doc ), doc -> len , & cursor -> visitor_data );
127127 } else {
128128 bson_error_t error = { 0 };
129+ const bson_t * doc = NULL ;
129130
130- if (mongoc_cursor_error (cursor -> cursor , & error )) {
131+ if (mongoc_cursor_error_document (cursor -> cursor , & error , & doc )) {
131132 /* Intentionally not destroying the cursor as it will happen
132133 * naturally now that there are no more results */
133- phongo_throw_exception_from_bson_error_t (& error TSRMLS_CC );
134+ phongo_throw_exception_from_bson_error_t_and_reply (& error , doc TSRMLS_CC );
134135 }
135136 }
136137
Original file line number Diff line number Diff line change 1+ --TEST--
2+ PHPC-1419: error labels from getMore are not exposed
3+ --SKIPIF--
4+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ; ?>
5+ <?php skip_if_not_libmongoc_crypto (); ?>
6+ <?php skip_if_no_failcommand_failpoint (); ?>
7+ <?php skip_if_server_version ('< ' , '4.1.11 ' ); ?>
8+ <?php skip_if_not_clean (); ?>
9+ --FILE--
10+ <?php
11+ require_once __DIR__ . "/../utils/basic.inc " ;
12+
13+ $ manager = new MongoDB \Driver \Manager (URI );
14+
15+ // Select a specific server for future operations to avoid mongos switching in sharded clusters
16+ $ server = $ manager ->selectServer (new \MongoDB \Driver \ReadPreference ('primary ' ));
17+
18+ $ bulk = new MongoDB \Driver \BulkWrite ;
19+ $ bulk ->insert (['_id ' => 1 ]);
20+ $ bulk ->insert (['_id ' => 2 ]);
21+ $ bulk ->insert (['_id ' => 3 ]);
22+ $ manager ->executeBulkWrite (NS , $ bulk );
23+
24+ $ cursor = $ server ->executeQuery (NS , new \MongoDB \Driver \Query ([], ['batchSize ' => 1 ]));
25+ $ iterator = new IteratorIterator ($ cursor );
26+
27+ configureTargetedFailPoint (
28+ $ server ,
29+ 'failCommand ' ,
30+ [ 'times ' => 1 ] ,
31+ [ 'errorCode ' => 280 , 'failCommands ' => ['getMore ' ] ]
32+ );
33+
34+ try {
35+ $ iterator ->next ();
36+ } catch (\MongoDB \Driver \Exception \ServerException $ e ) {
37+ var_dump ($ e ->hasErrorLabel ('NonResumableChangeStreamError ' ));
38+ }
39+
40+ ?>
41+ ===DONE===
42+ --EXPECT--
43+ bool(true)
44+ ===DONE===
You can’t perform that action at this time.
0 commit comments