File tree Expand file tree Collapse file tree 5 files changed +57
-3
lines changed Expand file tree Collapse file tree 5 files changed +57
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ PHP NEWS
15
15
. Fixed zend call stack size for macOs/arm64. (David Carlier)
16
16
. Added support for Zend Max Execution Timers on FreeBSD. (Kévin Dunglas)
17
17
. Ensure fiber stack is not backed by THP. (crrodriguez)
18
+ . Implement GH-13609 (Dump wrapped object in WeakReference class). (nielsdos)
18
19
19
20
- Curl:
20
21
. Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76)
Original file line number Diff line number Diff line change @@ -164,6 +164,8 @@ PHP 8.4 UPGRADE NOTES
164
164
. Added request_parse_body() function that allows parsing RFC1867 (multipart)
165
165
requests in non-POST HTTP requests.
166
166
RFC: https://wiki.php.net/rfc/rfc1867-non-post
167
+ . Getting the debug info for WeakReference will now also output the object
168
+ it references, or null if the reference is no longer valid.
167
169
168
170
- Curl:
169
171
. curl_version() returns an additional feature_list value, which is an
Original file line number Diff line number Diff line change @@ -26,14 +26,19 @@ object(stdClass)#1 (0) refcount(2){
26
26
}
27
27
object(stdClass)#1 (0) refcount(2){
28
28
}
29
- object(WeakReference)#2 (0) {
29
+ object(WeakReference)#2 (1) {
30
+ ["object"]=>
31
+ object(stdClass)#1 (0) {
32
+ }
30
33
}
31
- object(WeakReference)#2 (0) {
34
+ object(WeakReference)#2 (1) {
35
+ ["object"]=>
36
+ object(stdClass)#1 (0) {
37
+ }
32
38
}
33
39
object(stdClass)#1 (0) refcount(2){
34
40
}
35
41
object(stdClass)#1 (0) refcount(2){
36
42
}
37
43
NULL
38
44
NULL
39
-
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Weakrefs debug dump
3
+ --FILE--
4
+ <?php
5
+
6
+ $ s = new stdClass ;
7
+ $ s ->hello = 'world ' ;
8
+
9
+ $ weak = WeakReference::create ($ s );
10
+ var_dump ($ weak );
11
+ unset($ s );
12
+ var_dump ($ weak );
13
+
14
+ ?>
15
+ --EXPECT--
16
+ object(WeakReference)#2 (1) {
17
+ ["object"]=>
18
+ object(stdClass)#1 (1) {
19
+ ["hello"]=>
20
+ string(5) "world"
21
+ }
22
+ }
23
+ object(WeakReference)#2 (1) {
24
+ ["object"]=>
25
+ NULL
26
+ }
Original file line number Diff line number Diff line change @@ -271,6 +271,25 @@ static void zend_weakref_free(zend_object *zo) {
271
271
zend_object_std_dtor (& wr -> std );
272
272
}
273
273
274
+ static HashTable * zend_weakref_get_debug_info (zend_object * object , int * is_temp )
275
+ {
276
+ * is_temp = 1 ;
277
+
278
+ HashTable * ht = zend_new_array (1 );
279
+
280
+ zend_object * referent = zend_weakref_from (object )-> referent ;
281
+ zval value ;
282
+ if (referent ) {
283
+ ZVAL_OBJ_COPY (& value , referent );
284
+ } else {
285
+ ZVAL_NULL (& value );
286
+ }
287
+
288
+ zend_hash_update (ht , ZSTR_KNOWN (ZEND_STR_OBJECT ), & value );
289
+
290
+ return ht ;
291
+ }
292
+
274
293
ZEND_COLD ZEND_METHOD (WeakReference , __construct )
275
294
{
276
295
zend_throw_error (NULL , "Direct instantiation of WeakReference is not allowed, use WeakReference::create instead" );
@@ -749,6 +768,7 @@ void zend_register_weakref_ce(void) /* {{{ */
749
768
zend_weakref_handlers .offset = XtOffsetOf (zend_weakref , std );
750
769
751
770
zend_weakref_handlers .free_obj = zend_weakref_free ;
771
+ zend_weakref_handlers .get_debug_info = zend_weakref_get_debug_info ;
752
772
zend_weakref_handlers .clone_obj = NULL ;
753
773
754
774
zend_ce_weakmap = register_class_WeakMap (zend_ce_arrayaccess , zend_ce_countable , zend_ce_aggregate );
You can’t perform that action at this time.
0 commit comments