php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53895 debug_zval_dump should be by ref
Submitted: 2011-01-31 23:43 UTC Modified: 2011-02-04 22:15 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: + at ni-po dot com Assigned:
Status: Wont fix Package: Variables related
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: + at ni-po dot com
New email:
PHP Version: OS:

 

 [2011-01-31 23:43 UTC] + at ni-po dot com
Description:
------------
debug_zval_dump should accept the variable by reference.

Currently one can call the function either via debug_zval_dump($var) or debug_zval_dump(&$var). As the latter is as deprecated as it gets (i.e. parse-time deprecated) and is even removed in trunk, the function should be defined as accepting the variable by reference, because this is the usual use case.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-01 05:35 UTC] aharvey@php.net
-Type: Bug +Type: Feature/Change Request -Package: Unknown/Other Function +Package: Variables related
 [2011-02-01 13:49 UTC] cataphract@php.net
-Status: Open +Status: Wont fix
 [2011-02-01 13:49 UTC] cataphract@php.net
I disagree. Receiving the variable by reference would solve nothing, as it would force a separation on zvals with refcount > 1.

What actually ought to be done is make debug_zval_dump work like xdebug's version and accepting a string.
 [2011-02-01 15:13 UTC] + at ni-po dot com
That would obviously be even better. I just wanted to note, that something must be changed about it.
 [2011-02-04 22:15 UTC] johannes@php.net
The string version won't help for all cases, as you can't adress array elements or objects properly then. So there's no good way.
 [2011-02-05 11:47 UTC] + at ni-po dot com
Hm, the problem seems to be more complicated when I thought. The only thing I can think of, that would allow arrays and objects, too, is to provide a function zval_is_ref that checks, whether the zval is_ref and then provide two function, zval_dump_by_ref and zval_dump_by_val.

Imho this would cover all cases, but I assume that that's too many functions.
 [2014-08-15 03:46 UTC] ky dot patterson at adlinkr dot com
As others have pointed out, debug_zval_dump is fundamentally limited because it is a function, and so zend will alter or copy the argument's zval.

I *think* the solution is actually to add new language constructs, and I have opened a bug to discuss that:
https://bugs.php.net/bug.php?id=67847

Posting here because the people on this bug may have something to say about the one I just submitted.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC