note 96577 added to function.wincache-ucache-set
| From: | don dot raman at microsoft dot com | Date: | Fri, 05 Mar 2010 20:08:15 +0000 |
| Subject: | note 96577 added to function.wincache-ucache-set | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166717@lists.php.net to get a copy of this message | ||
As of writing this note (PHP 5.3.1) serialization of closure is not allowed.
This means a code like the one below:
<?php
//Closure
$bar3 = function($a) {
return $a * 2;
};
wincache_ucache_set('foo3', $bar3);
var_dump(wincache_ucache_get('foo3'));
echo "<br>";
?>
Will throw exception:
[11-Feb-2010 09:25:33] PHP Fatal error: Uncaught exception 'Exception' with message
'Serialization of 'Closure' is not allowed' in
C:\inetpub\wwwroot\phptest\tests\ucache\wincache15.php:6
Stack trace:
#0 C:\inetpub\wwwroot\phptest\tests\ucache\wincache15.php(6): wincache_ucache_set('foo3',
Object(Closure))
#1 {main}
thrown in C:\inetpub\wwwroot\phptest\tests\ucache\wincache15.php on line 6
However one catch this exception like:
<?php
//Closure
$bar3 = function($a) {
return $a * 2;
};
try
{
wincache_ucache_set('foo3', $bar3);
}
catch (Exception $e)
{
var_dump($e->getMessage());
}
var_dump(wincache_ucache_get('foo3'));
echo "<br>";
?>
This will generate output as shown beloe:
string(41) "Serialization of 'Closure' is not allowed" NULL
----
Server IP: 69.147.83.197
Probable Submitter: 131.107.0.73
----
Manual Page -- http://www.php.net/manual/en/function.wincache-ucache-set.php
Edit -- https://master.php.net/note/edit/96577
Del: integrated -- https://master.php.net/note/delete/96577/integrated
Del: useless -- https://master.php.net/note/delete/96577/useless
Del: bad code -- https://master.php.net/note/delete/96577/bad+code
Del: spam -- https://master.php.net/note/delete/96577/spam
Del: non-english -- https://master.php.net/note/delete/96577/non-english
Del: in docs -- https://master.php.net/note/delete/96577/in+docs
Del: other reasons-- https://master.php.net/note/delete/96577
Reject -- https://master.php.net/note/reject/96577
Search -- https://master.php.net/manage/user-notes.php