Bug->Req #77872 [Opn]: private/protected __serialize/__unserialize should throw Error

From: Date: Fri, 06 Aug 2021 19:10:57 +0000
Subject: Bug->Req #77872 [Opn]: private/protected __serialize/__unserialize should throw Error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235655@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77872&edit=1 ID: 77872 Updated by: cmb@php.net Reported by: nicolas dot grekas+php at gmail dot com -Summary: private/protected __serialize/__unserialize triggers a warning +Summary: private/protected __serialize/__unserialize should throw Error Status: Open -Type: Bug +Type: Feature/Change Request Package: *General Issues PHP Version: Next Minor Version Block user comment: N Private report: N New Comment: > Changing that for PHP8 would be great then, yes! Seems to have been forgotten. Not sure what to do now – postpone to PHP 9? How to make sure that we don't forget it? Previous Comments: ------------------------------------------------------------------------ [2019-04-09 15:39:45] nicolas dot grekas+php at gmail dot com Changing that for PHP8 would be great then, yes! ------------------------------------------------------------------------ [2019-04-09 15:31:10] nikic@php.net This is a standard warning generated by the internal call mechanism, not by the serialization handling. If we change something here it should probably only be in PHP 8 and for all users of the mechanism. ------------------------------------------------------------------------ [2019-04-09 13:51:22] nicolas dot grekas+php at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=77872&edit=1

« previous php.bugs (#235655) next »