Skip to content

Commit cc90304

Browse files
committed
PHPC-1151: Add Session to Cursor debug output
1 parent 21307de commit cc90304

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

src/MongoDB/Cursor.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,18 @@ static HashTable *php_phongo_cursor_get_debug_info(zval *object, int *is_temp TS
490490
ADD_ASSOC_NULL_EX(&retval, "readPreference");
491491
}
492492

493+
if (!Z_ISUNDEF(intern->session)) {
494+
#if PHP_VERSION_ID >= 70000
495+
ADD_ASSOC_ZVAL_EX(&retval, "session", &intern->session);
496+
Z_ADDREF(intern->session);
497+
#else
498+
ADD_ASSOC_ZVAL_EX(&retval, "session", intern->session);
499+
Z_ADDREF_P(intern->session);
500+
#endif
501+
} else {
502+
ADD_ASSOC_NULL_EX(&retval, "session");
503+
}
504+
493505
ADD_ASSOC_BOOL_EX(&retval, "isDead", !mongoc_cursor_is_alive(intern->cursor));
494506

495507
ADD_ASSOC_LONG_EX(&retval, "currentIndex", intern->current);

tests/manager/manager-executeCommand-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
5454
}
5555
["readPreference"]=>
5656
NULL
57+
["session"]=>
58+
NULL
5759
["isDead"]=>
5860
bool(false)
5961
["currentIndex"]=>

tests/manager/manager-executeQuery-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
6464
NULL
6565
["readPreference"]=>
6666
NULL
67+
["session"]=>
68+
NULL
6769
["isDead"]=>
6870
bool(false)
6971
["currentIndex"]=>

tests/manager/manager-executeQuery-002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
6464
NULL
6565
["readPreference"]=>
6666
NULL
67+
["session"]=>
68+
NULL
6769
["isDead"]=>
6870
bool(false)
6971
["currentIndex"]=>

tests/readPreference/bug0146-001.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
5858
["mode"]=>
5959
string(7) "primary"
6060
}
61+
["session"]=>
62+
NULL
6163
["isDead"]=>
6264
bool(true)
6365
["currentIndex"]=>
@@ -96,6 +98,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
9698
["mode"]=>
9799
string(16) "primaryPreferred"
98100
}
101+
["session"]=>
102+
NULL
99103
["isDead"]=>
100104
bool(true)
101105
["currentIndex"]=>
@@ -134,6 +138,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
134138
["mode"]=>
135139
string(9) "secondary"
136140
}
141+
["session"]=>
142+
NULL
137143
["isDead"]=>
138144
bool(true)
139145
["currentIndex"]=>
@@ -172,6 +178,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
172178
["mode"]=>
173179
string(18) "secondaryPreferred"
174180
}
181+
["session"]=>
182+
NULL
175183
["isDead"]=>
176184
bool(true)
177185
["currentIndex"]=>
@@ -210,6 +218,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
210218
["mode"]=>
211219
string(7) "nearest"
212220
}
221+
["session"]=>
222+
NULL
213223
["isDead"]=>
214224
bool(true)
215225
["currentIndex"]=>

tests/readPreference/bug0146-002.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
5858
["mode"]=>
5959
string(7) "primary"
6060
}
61+
["session"]=>
62+
NULL
6163
["isDead"]=>
6264
bool(true)
6365
["currentIndex"]=>
@@ -96,6 +98,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
9698
["mode"]=>
9799
string(16) "primaryPreferred"
98100
}
101+
["session"]=>
102+
NULL
99103
["isDead"]=>
100104
bool(true)
101105
["currentIndex"]=>
@@ -134,6 +138,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
134138
["mode"]=>
135139
string(9) "secondary"
136140
}
141+
["session"]=>
142+
NULL
137143
["isDead"]=>
138144
bool(true)
139145
["currentIndex"]=>
@@ -172,6 +178,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
172178
["mode"]=>
173179
string(18) "secondaryPreferred"
174180
}
181+
["session"]=>
182+
NULL
175183
["isDead"]=>
176184
bool(true)
177185
["currentIndex"]=>
@@ -210,6 +218,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
210218
["mode"]=>
211219
string(7) "nearest"
212220
}
221+
["session"]=>
222+
NULL
213223
["isDead"]=>
214224
bool(true)
215225
["currentIndex"]=>

tests/server/server-executeCommand-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
4343
}
4444
["readPreference"]=>
4545
NULL
46+
["session"]=>
47+
NULL
4648
["isDead"]=>
4749
bool(false)
4850
["currentIndex"]=>

0 commit comments

Comments
 (0)