Bug #72884 [Csd]: SplObject isCloneable() returns true but errs on clone

From: Date: Mon, 09 Sep 2019 17:14:34 +0000
Subject: Bug #72884 [Csd]: SplObject isCloneable() returns true but errs on clone
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222669@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 Updated by: jhdxr@php.net Reported by: php at abiusx dot com Summary: SplObject isCloneable() returns true but errs on clone Status: Closed Type: Bug Package: SPL related Operating System: OS X 10.11 PHP Version: 7.0.9 -Assigned To: +Assigned To: jhdxr Block user comment: N Private report: N New Comment: The fix for this bug has been committed. If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2019-09-09 15:30:33] nikic@php.net Automatic comment on behalf of me@jhdxr.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=1ac6b0251b6585490dfb549eb70b8c618cf90913 Log: Fix bug #72884 isCloneable() on SplFileObject should return false ------------------------------------------------------------------------ [2019-09-08 09:48:39] jhdxr@php.net 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#222669) next »