|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-05-03 19:41 UTC] cedricleong at gmail dot com
[2018-05-03 19:48 UTC] nikic@php.net
-Status: Open
+Status: Verified
[2018-05-03 19:48 UTC] nikic@php.net
[2018-05-03 20:31 UTC] pmmaga@php.net
[2018-06-17 22:53 UTC] stas@php.net
[2018-06-17 22:53 UTC] stas@php.net
-Status: Verified
+Status: Closed
[2018-06-17 22:54 UTC] stas@php.net
[2018-06-17 23:44 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 21:00:02 2025 UTC |
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] => )