php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81048 Regression from #80915 - phpinfo(INFO_VARIABLES) "Array to string conversion"
Submitted: 2021-05-18 23:24 UTC Modified: 2021-05-19 10:10 UTC
From: webmaster at deltik dot org Assigned: cmb (profile)
Status: Closed Package: Arrays related
PHP Version: 7.4.18 OS: Ubuntu 20.04
Private report: No CVE-ID: None
 [2021-05-18 23:24 UTC] webmaster at deltik dot org
Description:
------------
The fix for https://bugs.php.net/bug.php?id=80915 introduced a regression where phpinfo(INFO_VARIABLES) will emit an E_NOTICE reading:

> PHP Notice:  Array to string conversion …

This happens if array_walk() iterates over $_SERVER prior to phpinfo().

The regression was introduced in:
* PHP 8.0.5
* PHP 7.4.18

The commit that introduced the regression:
https://github.com/php/php-src/commit/206fd35a98375522a53818ec4ef6e0585b1055dd

Test script:
---------------
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");

array_walk($_SERVER, function($value, $key) {
        // NOOP
});
phpinfo(INFO_VARIABLES);

Expected result:
----------------
In the output, no match for the following string:

"Notice:  Array to string conversion"

Actual result:
--------------
PHP Notice:  Array to string conversion in /tmp/php-bug/bug.php on line 8
PHP Stack trace:
PHP   1. {main}() /tmp/php-bug/bug.php:0
PHP   2. phpinfo($what = 32) /tmp/php-bug/bug.php:8
phpinfo()

PHP Variables

Variable => Value
… [ TRUNCATED ] …
$_SERVER['argv'] => 
Notice: Array to string conversion in /tmp/php-bug/bug.php on line 8

Call Stack:
    0.0001     405000   1. {main}() /tmp/php-bug/bug.php:0
    0.0001     417176   2. phpinfo($what = 32) /tmp/php-bug/bug.php:8

Array
$_SERVER['argc'] => 1

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-19 09:46 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-05-19 09:46 UTC] cmb@php.net
Prior to fixing bug #80915, argv would have been omitted from the
ouput for the given script.
 [2021-05-19 10:10 UTC] cmb@php.net
-PHP Version: 8.0.6 +PHP Version: 7.4.18
 [2021-05-19 10:10 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
On GitHub:  https://github.com/php/php-src/pull/7014
Patch:      https://github.com/php/php-src/pull/7014.patch
 [2021-05-19 12:11 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/php-src/commit/36b9bdeeeca066909e2fd687dc5a2089b0112bb0
Log: Fix #81048: phpinfo(INFO_VARIABLES) &quot;Array to string conversion&quot;
 [2021-05-19 12:11 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 08:01:28 2024 UTC