Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/spl/spl_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ static int spl_heap_it_get_current_key(zend_object_iterator *iter, char **str_ke
{
spl_heap_it *iterator = (spl_heap_it *)iter;

*int_key = (ulong) iterator->object->heap->count;
*int_key = (ulong) iterator->object->heap->count - 1;
return HASH_KEY_IS_LONG;
}
/* }}} */
Expand Down
24 changes: 24 additions & 0 deletions ext/spl/tests/bug62073.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
Bug #62073 (different ways of iterating over an SplMaxHeap result in different keys)
--FILE--
<?php
$heap = new SplMaxHeap;
$heap->insert(42);
foreach ($heap as $key => $value) {
break;
}
var_dump($key);
var_dump($value);

$heap = new SplMaxHeap;
$heap->insert(42);
var_dump($heap->key());
var_dump($heap->current());
?>
==DONE==
--EXPECT--
int(0)
int(42)
int(0)
int(42)
==DONE==
200 changes: 100 additions & 100 deletions ext/spl/tests/heap_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,104 +18,104 @@ foreach ($h as $k => $o) {
===DONE===
<?php exit(0); ?>
--EXPECTF--
100 => 1
99 => 2
98 => 3
97 => 4
96 => 5
95 => 6
94 => 7
93 => 8
92 => 9
91 => 10
90 => 11
89 => 12
88 => 13
87 => 14
86 => 15
85 => 16
84 => 17
83 => 18
82 => 19
81 => 20
80 => 21
79 => 22
78 => 23
77 => 24
76 => 25
75 => 26
74 => 27
73 => 28
72 => 29
71 => 30
70 => 31
69 => 32
68 => 33
67 => 34
66 => 35
65 => 36
64 => 37
63 => 38
62 => 39
61 => 40
60 => 41
59 => 42
58 => 43
57 => 44
56 => 45
55 => 46
54 => 47
53 => 48
52 => 49
51 => 50
50 => 51
49 => 52
48 => 53
47 => 54
46 => 55
45 => 56
44 => 57
43 => 58
42 => 59
41 => 60
40 => 61
39 => 62
38 => 63
37 => 64
36 => 65
35 => 66
34 => 67
33 => 68
32 => 69
31 => 70
30 => 71
29 => 72
28 => 73
27 => 74
26 => 75
25 => 76
24 => 77
23 => 78
22 => 79
21 => 80
20 => 81
19 => 82
18 => 83
17 => 84
16 => 85
15 => 86
14 => 87
13 => 88
12 => 89
11 => 90
10 => 91
9 => 92
8 => 93
7 => 94
6 => 95
5 => 96
4 => 97
3 => 98
2 => 99
1 => 100
99 => 1
98 => 2
97 => 3
96 => 4
95 => 5
94 => 6
93 => 7
92 => 8
91 => 9
90 => 10
89 => 11
88 => 12
87 => 13
86 => 14
85 => 15
84 => 16
83 => 17
82 => 18
81 => 19
80 => 20
79 => 21
78 => 22
77 => 23
76 => 24
75 => 25
74 => 26
73 => 27
72 => 28
71 => 29
70 => 30
69 => 31
68 => 32
67 => 33
66 => 34
65 => 35
64 => 36
63 => 37
62 => 38
61 => 39
60 => 40
59 => 41
58 => 42
57 => 43
56 => 44
55 => 45
54 => 46
53 => 47
52 => 48
51 => 49
50 => 50
49 => 51
48 => 52
47 => 53
46 => 54
45 => 55
44 => 56
43 => 57
42 => 58
41 => 59
40 => 60
39 => 61
38 => 62
37 => 63
36 => 64
35 => 65
34 => 66
33 => 67
32 => 68
31 => 69
30 => 70
29 => 71
28 => 72
27 => 73
26 => 74
25 => 75
24 => 76
23 => 77
22 => 78
21 => 79
20 => 80
19 => 81
18 => 82
17 => 83
16 => 84
15 => 85
14 => 86
13 => 87
12 => 88
11 => 89
10 => 90
9 => 91
8 => 92
7 => 93
6 => 94
5 => 95
4 => 96
3 => 97
2 => 98
1 => 99
0 => 100
===DONE===
Loading