php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71321 User __debugInfo method ignored for internal classes
Submitted: 2016-01-09 16:20 UTC Modified: 2018-08-13 08:04 UTC
Votes:6
Avg. Score:3.7 ± 0.7
Reproduced:4 of 5 (80.0%)
Same Version:0 (0.0%)
Same OS:1 (25.0%)
From: zaq178miami at gmail dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 7.0.2 OS: Debian GNU/Linux 8.2 (jessie)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zaq178miami at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-09 16:20 UTC] zaq178miami at gmail dot com
Description:
------------
When user class extends internal class with get_debug_info object handler set and defined userland __debugInfo() method, that method totally ignored.


As a workaround, Z_OBJDEBUG macro may be changed to looks like

    #define Z_OBJDEBUG(zval,tmp)		(Z_OBJCE(zval)->__debugInfo?std_object_handlers.get_debug_info(&(zval),&tmp):(Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&tmp):(tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL)))

From Bob Weinand notes:

Then comes a question about parent::__debugInfo() in userland __debugInfo() 
comes: should it be accessible? Should it return what get_debug_info returns? Or should get_debug_info moved to ce->__debugInfo (internally too)? BC?


Test script:
---------------
class CustomSplStorage extends SplObjectStorage {
    public function __debugInfo()
    {
        return ['this is' => 'annoying'];
    }
}

var_dump(new CustomSplStorage());
debug_zval_dump(new CustomSplStorage());

Expected result:
----------------
object(CustomSplStorage)#1 (1) {
  ["this is"]=>
  string(8) "annoying"
}
object(CustomSplStorage)#1 (1) refcount(1){
  ["storage":"SplObjectStorage":private]=>
  ["this is"]=>
  string(8) "annoying" refcount(2)
}


Actual result:
--------------
object(CustomSplStorage)#1 (1) {
  ["storage":"SplObjectStorage":private]=>
  array(0) {
  }
}
object(CustomSplStorage)#1 (1) refcount(1){
  ["storage":"SplObjectStorage":private]=>
  array(0) refcount(1){
  }
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-09 16:22 UTC] zaq178miami at gmail dot com
This is not about just SPL (https://bugs.php.net/bug.php?id=69264), but about all internal classes that set their get_debug_info.
 [2016-07-19 15:10 UTC] bishop@php.net
-Summary: User __debugInfo method ignored +Summary: User __debugInfo method ignored for internal classes -Status: Open +Status: Assigned -Assigned To: +Assigned To: bishop
 [2017-10-24 06:04 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: bishop +Assigned To:
 [2018-08-13 08:01 UTC] zerterone at gmail dot com
duplicate of #69264
 [2018-08-13 08:04 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2018-08-13 08:04 UTC] requinix@php.net
Mentioning bug #69264 for linkage.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC