php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73916 zend_print_flat_zval_r doesn't consider reference
Submitted: 2017-01-12 05:44 UTC Modified: 2017-01-12 08:33 UTC
From: x dot xiang at outlook dot com Assigned:
Status: Closed Package: Output Control
PHP Version: 7.0.14 OS: ALL
Private report: No CVE-ID:
 [2017-01-12 05:44 UTC] x dot xiang at outlook dot com
Description:
------------
zend_print_flat_zval_r and zend_print_zval_r_ex doesn't consider reference in php 7.0.x.

The following error may be triggered:
PHP Notice:  Array to string conversion;
Catchable fatal error: Object could not be converted to string.

This bug has been fixed in php 7.1, why php 7.0.x is not fixed.

Test script:
---------------
$a = array('a');
class b{};
$b = new b;
$test[] =& $a;
$test[] =& $b;
test($test);
function test() {
    debug_print_backtrace();
}


Expected result:
----------------
#0  test(Array ([0] => Array ([0] => a),[1] => b Object ())) called at [/Users/playcrab/Documents/code/php/test/test7.php:7]

Actual result:
--------------
#0  test(Array ([0] => PHP Notice:  Array to string conversion in /Users/playcrab/Documents/code/php/test/test7.php on line 9
PHP Stack trace:
PHP   1. {main}() /Users/playcrab/Documents/code/php/test/test7.php:0
PHP   2. test() /Users/playcrab/Documents/code/php/test/test7.php:7
PHP   3. debug_print_backtrace() /Users/playcrab/Documents/code/php/test/test7.php:9
PHP Catchable fatal error:  Object of class b could not be converted to string in /Users/playcrab/Documents/code/php/test/test7.php on line 9
PHP Stack trace:
PHP   1. {main}() /Users/playcrab/Documents/code/php/test/test7.php:0
PHP   2. test() /Users/playcrab/Documents/code/php/test/test7.php:7
PHP   3. debug_print_backtrace() /Users/playcrab/Documents/code/php/test/test7.php:9

Notice: Array to string conversion in /Users/playcrab/Documents/code/php/test/test7.php on line 9

Call Stack:
    0.0068     353088   1. {main}() /Users/playcrab/Documents/code/php/test/test7.php:0
    0.0080     353928   2. test() /Users/playcrab/Documents/code/php/test/test7.php:7
    0.0080     353928   3. debug_print_backtrace() /Users/playcrab/Documents/code/php/test/test7.php:9

Array,[1] => 
Catchable fatal error: Object of class b could not be converted to string in /Users/playcrab/Documents/code/php/test/test7.php on line 9

Call Stack:
    0.0068     353088   1. {main}() /Users/playcrab/Documents/code/php/test/test7.php:0
    0.0080     353928   2. test() /Users/playcrab/Documents/code/php/test/test7.php:7
    0.0080     353928   3. debug_print_backtrace() /Users/playcrab/Documents/code/php/test/test7.php:9

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-12 08:33 UTC] x dot xiang at outlook dot com
-Summary: zend_print_flat_zval_r and zend_print_zval_r_ex doesn't consider reference +Summary: zend_print_flat_zval_r doesn't consider reference
 [2017-01-12 08:33 UTC] x dot xiang at outlook dot com
I realized that zend_print_zval_r_ex dealt with the case of reference.
 [2017-01-13 05:08 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=04379bcb1df25a9f9cc1d440f5c12105b9fbaf97
Log: Fixed bug #73916 (zend_print_flat_zval_r doesn't consider reference)
 [2017-01-13 05:08 UTC] laruence@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Feb 28 14:01:40 2017 UTC