Bug #79352 [NEW]: ArrayObject::serialize and ArrayObject::unserialize are no longer overrideable
| From: | tarasov dot igor at gmail dot com | Date: | Sat, 07 Mar 2020 09:43:45 +0000 |
| Subject: | Bug #79352 [NEW]: ArrayObject::serialize and ArrayObject::unserialize are no longer overrideable | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-225933@lists.php.net to get a copy of this message | ||
From: tarasov dot igor at gmail dot com
Operating system: Linux
PHP version: 7.4.3
Package: SPL related
Bug Type: Bug
Bug description:ArrayObject::serialize and ArrayObject::unserialize are no longer overrideable
Description:
------------
If you inherit from ArrayObject and then try to override serialize and
unserialize methods, you'll notice that starting with PHP 7.4 these are
not executed at all. There are no mentions in the documentation
describing this change. Sure, there are new __serialize and
__unserialize, but this backward-incompatible change and is not
described anywhere.
If you create a custom class implementing Serializable interface, you
can still override these methods in child classes, no problem there.
Not sure if this change affects only ArrayObject, I suspect there might
be other built-in classes that were changed the same way.
Test script:
---------------
class Foo extends \ArrayObject {
public function serialize() {
return 'test';
}
}
echo serialize(new Foo);
Expected result:
----------------
C:3:"Foo":4:{test}
Actual result:
--------------
O:3:"Foo":3:{i:0;i:0;i:1;a:0:{}i:2;a:0:{}}
So, Foo::serialize is never executed. And it's not like the results are
ignored, you can even change it's body to die statement and it won't
stop there.
--
Edit bug report at https://bugs.php.net/bug.php?id=79352&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79352&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79352&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79352&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79352&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79352&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79352&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79352&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79352&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79352&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79352&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79352&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79352&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79352&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79352&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79352&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79352&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79352&r=mysqlcfg