Skip to content

Commit ba167a3

Browse files
committed
Merge pull request #348
2 parents 00c0930 + c3fa0c1 commit ba167a3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/MongoDB/CursorId.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@ zend_object_handlers php_phongo_handler_cursorid;
5151
PHP_METHOD(CursorId, __toString)
5252
{
5353
php_phongo_cursorid_t *intern;
54+
char *tmp;
55+
int tmp_len;
5456
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
5557

56-
5758
intern = Z_CURSORID_OBJ_P(getThis());
5859

5960
if (zend_parse_parameters_none() == FAILURE) {
6061
return;
6162
}
6263

63-
RETVAL_LONG(intern->id);
64-
convert_to_string(return_value);
64+
tmp_len = spprintf(&tmp, 0, "%" PRIu64, intern->id);
65+
PHONGO_RETVAL_STRINGL(tmp, tmp_len);
66+
efree(tmp);
6567
}
6668
/* }}} */
6769

@@ -131,10 +133,19 @@ HashTable *php_phongo_cursorid_get_debug_info(zval *object, int *is_temp TSRMLS_
131133

132134
array_init(&retval);
133135

136+
#if SIZEOF_LONG == 4
137+
{
138+
char tmp[24];
139+
int tmp_len;
140+
141+
tmp_len = snprintf(tmp, sizeof(tmp), "%" PRIu64, intern->id);
142+
ADD_ASSOC_STRINGL(&retval, "id", tmp, tmp_len);
143+
}
144+
#else
134145
ADD_ASSOC_LONG_EX(&retval, "id", intern->id);
146+
#endif
135147

136148
return Z_ARRVAL(retval);
137-
138149
} /* }}} */
139150
/* }}} */
140151

tests/functional/cursorid-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var_dump($s1 > 0);
3232
--EXPECTF--
3333
object(MongoDB\Driver\CursorId)#%d (%d) {
3434
["id"]=>
35-
%s(%d)
35+
%rint\(\d+\)|string\(\d+\) "\d+"%r
3636
}
3737
string(%d) "%d"
3838
bool(true)

0 commit comments

Comments
 (0)