Req #69959 [NEW]: unserialize() needlessly requires boilerplate

From: Date: Mon, 29 Jun 2015 07:08:27 +0000
Subject: Req #69959 [NEW]: unserialize() needlessly requires boilerplate
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193977@lists.php.net to get a copy of this message
From: lucas at threeamdesign dot com dot au Operating system: PHP version: 7.0.0alpha2 Package: *General Issues Bug Type: Feature/Change Request Bug description:unserialize() needlessly requires boilerplate Description: ------------ I'm aware that the docs have this to say: --- Warning FALSE is returned both in the case of an error and if unserializing the serialized FALSE value. It is possible to catch this special case by comparing str with serialize(false) or by catching the issued E_NOTICE. --- Using the return value for failure and data is just lazy. This problem could be done away with, very easily if unserialize() were changed to accept a second parameter. This parameter would be a reference variable. If the function was called with the second parameter, the reference would be filled with either the unserialized data, or the success/failure boolean of the process. The return value of the function would then be the other. The latter form would be most backwards-compatible though seems more unintuitive. -- Edit bug report at https://bugs.php.net/bug.php?id=69959&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69959&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69959&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69959&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69959&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69959&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69959&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69959&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69959&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69959&r=support Expected behavior: https://bugs.php.net/fix.php?id=69959&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69959&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69959&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69959&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69959&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69959&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69959&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69959&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69959&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69959&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69959&r=mysqlcfg

« previous php.bugs (#193977) next »