|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-02-23 01:46 UTC] eric at wepay dot com
Description: ------------ Storing a closure in APC silently fails (or stores null), and retrieving it later ends up returning null which causes fun problems like "Function name must be a string in ..." Use case: It's common to store app configuration in APC, and some configuration includes closures. If you have a closure in your config array and attempt to store it in APC, there are no warnings or errors; yet when fetching this value from APC it returns null. Probably related to https://bugs.php.net/bug.php?id=63021 (I don't know if APC uses serialize or var_export, but it's the same general problem) Test script: --------------- $fn = function() { return 1; } ; $ret = apc_store('test', $fn); var_dump($ret); // NULL $fetched = apc_fetch('test'); var_dump($fetched); // NULL Expected result: ---------------- either a) apc_store('key', $value_containing_closure) will throw an exception or issue some sort of warning (PHP notice?) More accurately, var_export/serialize on a closure should probably handle this or b) it works (closures can be serialized/exported) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 19:00:02 2025 UTC |
I am not sure I got your point. but apc do trigger an exception: Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /tmp/1.php:4 Stack trace: #0 /tmp/1.php(4): apc_store('test', Object(Closure)) #1 {main} thrown in /tmp/1.php on line 4