Bug #74442 [Opn->Csd]: Opcached version produces a nested array
| From: | nikic@php.net | Date: | Fri, 14 Apr 2017 20:21:09 +0000 |
| Subject: | Bug #74442 [Opn->Csd]: Opcached version produces a nested array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208570@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74442&edit=1
ID: 74442
Updated by: nikic@php.net
Reported by: rasmus@php.net
Summary: Opcached version produces a nested array
-Status: Open
+Status: Closed
Type: Bug
Package: opcache
Operating System: Linux
PHP Version: 7.1.5RC1
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2f22dffd1a4535520959943e2e9aec8b2b9b647f
Log: Fixed bug #74442
Previous Comments:
------------------------------------------------------------------------
[2017-04-14 16:59:42] rasmus@php.net
Note that in the constructor if you do
if(is_null($params)) $params = [];
instead of trying to cast null to an array the problem goes away.
------------------------------------------------------------------------
[2017-04-14 16:24:21] rasmus@php.net
Description:
------------
Without opcache this script prints 4. With opcache, on the first request to this script you get 4 as
well. On the 2nd request when you hit the opcached version you get a nested array. Reproducable from
cli with:
opcache.enable_cli=1
opcache.file_cache=/var/tmp
opcache.file_cache_only=1
It is fine in 7.0, so it is something we broke in 7.1
Test script:
---------------
<?php
class Schema_Base {
public function addField($typeclass, array $params = null) {
$field = new $typeclass($params);
return $field;
}
}
class Field_Base {
public function __construct(array $params = null) {
if (! is_array($params)) {
$params = (array) $params;
}
call_user_func_array(array($this, 'acceptParams'), $params);
}
}
class Field_Integer extends Field_Base {
protected function acceptParams($bytes = 4) {
echo print_r($bytes, true);
}
}
try {
$schema = new Schema_Base;
$schema->addField('Field_Integer');
} catch (Throwable $ex) {
echo "CAUGHT EXCEPTION";
echo (string)$ex;
}
Expected result:
----------------
4
Actual result:
--------------
Array
(
[0] => Array
*RECURSION*
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74442&edit=1