Bug #76300 [NEW]: Serialize/Unserialize of extended protected member broken

From: Date: Thu, 03 May 2018 18:57:22 +0000
Subject: Bug #76300 [NEW]: Serialize/Unserialize of extended protected member broken
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215039@lists.php.net to get a copy of this message
From: rishad at kaluma dot com Operating system: Ubuntu 16.04 PHP version: 7.2.5 Package: Class/Object related Bug Type: Bug Bug description:Serialize/Unserialize of extended protected member broken Description: ------------ $php -v ``` PHP 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Apr 5 2018 08:53:57) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.4-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans ``` I have a base class and derived class with same member name. In the base class if member is protected it breaks the serialize/unserialize. However, if the member is private functionality works as expected. This works on: PHP 7.1.11-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Oct 27 2017 13:49:56) ( NTS ) Test script: --------------- <?php class Base { private $id; public function __construct($id) { $this->id = $id; } } class Derived extends Base { protected $id; public function __construct($id) { parent::__construct($id + 20); $this->id = $id; } } $a = new Derived(44); $s = serialize($a); $u = unserialize($s); print_r($u); Expected result: ---------------- Derived Object ( [id:protected] => 44 [id:Base:private] => 64 ) Actual result: -------------- Derived Object ( [id:protected] => 64 [id:Base:private] => ) -- Edit bug report at https://bugs.php.net/bug.php?id=76300&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76300&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76300&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76300&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76300&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76300&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76300&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76300&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76300&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76300&r=support Expected behavior: https://bugs.php.net/fix.php?id=76300&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76300&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76300&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76300&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76300&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76300&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76300&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76300&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76300&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76300&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76300&r=mysqlcfg

« previous php.bugs (#215039) next »