Bug #74442 [Opn]: Opcached version produces a nested array

From: Date: Fri, 14 Apr 2017 16:59:42 +0000
Subject: Bug #74442 [Opn]: Opcached version produces a nested array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208557@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: rasmus@php.net Reported by: rasmus@php.net Summary: Opcached version produces a nested array Status: Open Type: Bug Package: opcache Operating System: Linux PHP Version: 7.1.5RC1 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#208557) next »