Bug #77872 [NEW]: private/protected __serialize/__unserialize triggers a warning
| From: | nicolas dot grekas+php at gmail dot com | Date: | Tue, 09 Apr 2019 13:51:22 +0000 |
| Subject: | Bug #77872 [NEW]: private/protected __serialize/__unserialize triggers a warning | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220381@lists.php.net to get a copy of this message | ||
From: nicolas dot grekas+php at gmail dot com
Operating system:
PHP version: Next Minor Version
Package: *General Issues
Bug Type: Bug
Bug description:private/protected __serialize/__unserialize triggers a warning
Description:
------------
When the new __serialize/__unserialize method are made protected or
private, a warning is thrown.
Throwing an Error might be better.
Test script:
---------------
class foo
{
private function __serialize()
{
return [123];
}
public function __unserialize($a)
{
}
}
$f = new foo();
$s = serialize($f);
Expected result:
----------------
"Fatal error: Uncaught Error: Call to private method foo::__serialize()"
or similar
Actual result:
--------------
Warning: Invalid callback foo::__serialize, cannot access private method
foo::__serialize() in /var/www/html/test.php on line 22
--
Edit bug report at https://bugs.php.net/bug.php?id=77872&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77872&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77872&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77872&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77872&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77872&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77872&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77872&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77872&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77872&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77872&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77872&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77872&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77872&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77872&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77872&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77872&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77872&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77872&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77872&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77872&r=mysqlcfg