File tree Expand file tree Collapse file tree 3 files changed +55
-20
lines changed Expand file tree Collapse file tree 3 files changed +55
-20
lines changed Original file line number Diff line number Diff line change @@ -75,11 +75,7 @@ static HashTable* php_phongo_cursorid_get_properties_hash(phongo_compat_object_h
75
75
zval value ;
76
76
77
77
if (is_serialize ) {
78
- if (intern -> id > INT32_MAX || intern -> id < INT32_MIN ) {
79
- ZVAL_INT64_STRING (& value , intern -> id );
80
- } else {
81
- ZVAL_LONG (& value , intern -> id );
82
- }
78
+ ZVAL_INT64_STRING (& value , intern -> id );
83
79
} else {
84
80
#if SIZEOF_ZEND_LONG == 4
85
81
if (intern -> id > INT32_MAX || intern -> id < INT32_MIN ) {
Original file line number Diff line number Diff line change @@ -8,22 +8,43 @@ MongoDB\Driver\CursorId serialization (Serializable interface)
8
8
9
9
require_once __DIR__ . "/../utils/basic.inc " ;
10
10
11
- $ serialized = 'C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}} ' ;
11
+ $ tests = [
12
+ unserialize ('C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}} ' ),
13
+ unserialize ('C:23:"MongoDB\Driver\CursorId":23:{a:1:{s:2:"id";s:1:"0";}} ' ),
14
+ ];
12
15
13
- $ cursorId = unserialize ($ serialized );
14
-
15
- var_dump ($ cursorId );
16
- var_dump ($ cursorId instanceof Serializable);
17
- echo serialize ($ cursorId ), "\n" ;
16
+ foreach ($ tests as $ test ) {
17
+ var_dump ($ test );
18
+ var_dump ($ test instanceof Serializable);
19
+ echo $ s = serialize ($ test ), "\n" ;
20
+ var_dump (unserialize ($ s ));
21
+ echo "\n" ;
22
+ }
18
23
19
24
?>
20
25
===DONE===
21
26
<?php exit (0 ); ?>
22
27
--EXPECTF--
23
28
object(MongoDB\Driver\CursorId)#%d (%d) {
24
29
["id"]=>
25
- %rint\(\d+\ )|string\(\d+\ ) "\d+ "%r
30
+ %rint\(7250031947823432848\ )|string\(19\ ) "7250031947823432848 "%r
26
31
}
27
32
bool(true)
28
33
C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}}
34
+ object(MongoDB\Driver\CursorId)#%d (%d) {
35
+ ["id"]=>
36
+ %rint\(7250031947823432848\)|string\(19\) "7250031947823432848"%r
37
+ }
38
+
39
+ object(MongoDB\Driver\CursorId)#%d (%d) {
40
+ ["id"]=>
41
+ int(0)
42
+ }
43
+ bool(true)
44
+ C:23:"MongoDB\Driver\CursorId":23:{a:1:{s:2:"id";s:1:"0";}}
45
+ object(MongoDB\Driver\CursorId)#%d (%d) {
46
+ ["id"]=>
47
+ int(0)
48
+ }
49
+
29
50
===DONE===
Original file line number Diff line number Diff line change @@ -8,22 +8,40 @@ MongoDB\Driver\CursorId serialization (__serialize and __unserialize)
8
8
9
9
require_once __DIR__ . "/../utils/basic.inc " ;
10
10
11
- $ serialized = 'O:23:"MongoDB\Driver\CursorId":1:{s:2:"id";s:19:"7250031947823432848";} ' ;
11
+ $ tests = [
12
+ unserialize ('O:23:"MongoDB\Driver\CursorId":1:{s:2:"id";s:19:"7250031947823432848";} ' ),
13
+ unserialize ('O:23:"MongoDB\Driver\CursorId":1:{s:2:"id";s:1:"0";} ' ),
14
+ ];
12
15
13
- $ cursorId = unserialize ($ serialized );
14
-
15
- var_dump ($ cursorId );
16
- var_dump ($ cursorId instanceof Serializable);
17
- echo serialize ($ cursorId ), "\n" ;
16
+ foreach ($ tests as $ test ) {
17
+ var_dump ($ test );
18
+ echo $ s = serialize ($ test ), "\n" ;
19
+ var_dump (unserialize ($ s ));
20
+ echo "\n" ;
21
+ }
18
22
19
23
?>
20
24
===DONE===
21
25
<?php exit (0 ); ?>
22
26
--EXPECTF--
23
27
object(MongoDB\Driver\CursorId)#%d (%d) {
24
28
["id"]=>
25
- %rint\(\d+\ )|string\(\d+\ ) "\d+ "%r
29
+ %rint\(7250031947823432848\ )|string\(19\ ) "7250031947823432848 "%r
26
30
}
27
- bool(true)
28
31
O:23:"MongoDB\Driver\CursorId":1:{s:2:"id";s:19:"7250031947823432848";}
32
+ object(MongoDB\Driver\CursorId)#%d (%d) {
33
+ ["id"]=>
34
+ %rint\(7250031947823432848\)|string\(19\) "7250031947823432848"%r
35
+ }
36
+
37
+ object(MongoDB\Driver\CursorId)#%d (%d) {
38
+ ["id"]=>
39
+ int(0)
40
+ }
41
+ O:23:"MongoDB\Driver\CursorId":1:{s:2:"id";s:1:"0";}
42
+ object(MongoDB\Driver\CursorId)#%d (%d) {
43
+ ["id"]=>
44
+ int(0)
45
+ }
46
+
29
47
===DONE===
You can’t perform that action at this time.
0 commit comments