Bug #69996 [NEW]: Changing the property of a cloned object affects the original
| From: | berdir@php.net | Date: | Sun, 05 Jul 2015 11:33:10 +0000 |
| Subject: | Bug #69996 [NEW]: Changing the property of a cloned object affects the original | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-194140@lists.php.net to get a copy of this message | ||
From: berdir
Operating system: Ubuntu
PHP version: 7.0Git-2015-07-05 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Changing the property of a cloned object affects the original
Description:
------------
... under not yet identified descriptions.
This is part of our efforts to get Drupal 8 green on PHP 7, see
https://www.drupal.org/node/2454439.
At some point a very strange bug was introduced in PHP 7, this is a
relatively new bug. Many tests have fails, I haven't checked yet if it's
the same bug for all of them.
You can reproduce by running MemoryBackendUnitTest.
https://bugs.php.net/bug.php?id=69371 for
example has instructions on
how to run a test.
The problematic code is in MemoryBackend::prepareItem():
$prepared = clone $cache;
$prepared->data = unserialize($prepared->data);
This is called repeatedly and on the second call, $cache->data is
already unserialized which results in a notice. So it looks like the
clone doesn't fully work. $cache is a stdClass object.
I tried to extract it into a standalone script but that doesn't fail.
When debugging, I noticed that both cloned object have the same hash
(spl_object_hash()) and that both $prepared->data and $cache->data are
already unserialized.
Expected result:
----------------
No error
Actual result:
--------------
unserialize(): Error at offset 0 of 6 bytes
unserialize('foobar')
Drupal\Core\Cache\MemoryBackend->prepareItem(Object, 1)
Drupal\Core\Cache\MemoryBackend->get('test3', 1)
Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase->testSetGet()
Drupal\simpletest\TestBase->run()
_simpletest_batch_operation(Array, '7', Array)
_batch_process()
_batch_do()
_batch_page(Object)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1,
1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
--
Edit bug report at https://bugs.php.net/bug.php?id=69996&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69996&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69996&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69996&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69996&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69996&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69996&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69996&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69996&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69996&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69996&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69996&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69996&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69996&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69996&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69996&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69996&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69996&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69996&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69996&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69996&r=mysqlcfg