Bug #72884 [PATCH]: SplObject isCloneable() returns true but errs on clone
| From: | jhdxr@php.net | Date: | Sun, 08 Sep 2019 09:48:39 +0000 |
| Subject: | Bug #72884 [PATCH]: SplObject isCloneable() returns true but errs on clone | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222627@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72884&edit=1
ID: 72884
Patch added by: jhdxr@php.net
Reported by: php at abiusx dot com
Summary: SplObject isCloneable() returns true but errs on
clone
Status: Verified
Type: Bug
Package: SPL related
Operating System: OS X 10.11
PHP Version: 7.0.9
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: fix bug #72884 isCloneable() on SplFileObject should return false
On GitHub: https://github.com/php/php-src/pull/4688
Patch: https://github.com/php/php-src/pull/4688.patch
Previous Comments:
------------------------------------------------------------------------
[2018-08-15 17:49:41] cmb@php.net
The problem is that SplFileObject reuses the object handlers of
SplFileInfo, which defines a clone_obj handler[1], which signals
to reflection that it is cloneable, but throws an error there[2].
[1] <https://github.com/php/php-src/blob/php-7.3.0beta1/ext/spl/spl_directory.c#L3097>
[2] <https://github.com/php/php-src/blob/php-7.3.0beta1/ext/spl/spl_directory.c#L374>
------------------------------------------------------------------------
[2016-08-19 03:14:55] laruence@php.net
hmm, the codes lead to segfault in 7.1
------------------------------------------------------------------------
[2016-08-18 16:34:25] php at abiusx dot com
Description:
------------
An SplFileObject is clonable according to reflection, but errs on attempting to clone.
Related bug report: 53967
Test script:
---------------
$x=new SplFileObject("tests.php");
$r=new ReflectionObject($x);
var_dump($r->isCloneable());
$y=clone $x; //fatal error
Expected result:
----------------
At worst, such things should issue a warning. This clone might happen as part of more general clone
that involves many objects and arrays, and with a fatal error there is no way to recover from this,
but it is not a big deal and should be recoverable.
Changing it to E_WARNING is a possible scenario, or throwing appropriate exceptions on PHP 7.
Also, note in the documentation that reflection stats are not accurate regarding core classes and
functions.
Actual result:
--------------
make cloneable, return false, or E_WARNING
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72884&edit=1