Bug #71321 [NEW]: User __debugInfo method ignored

From: Date: Sat, 09 Jan 2016 16:20:30 +0000
Subject: Bug #71321 [NEW]: User __debugInfo method ignored
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198548@lists.php.net to get a copy of this message
From:             zaq178miami at gmail dot com
Operating system: Debian GNU/Linux 8.2 (jessie)
PHP version:      7.0.2
Package:          *General Issues
Bug Type:         Bug
Bug description:User __debugInfo method ignored

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){
  }
}


-- 
Edit bug report at https://bugs.php.net/bug.php?id=71321&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71321&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71321&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71321&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71321&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71321&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71321&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71321&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71321&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71321&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71321&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71321&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71321&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71321&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71321&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71321&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71321&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71321&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71321&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71321&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71321&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#198548) next »