I have a custom Exception handler in my code (which used to work properly), until suddenly I saw this error yesterday:
PHP Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /raid0/nginx/www/voiceportal/lib/logutils.php:34 Stack trace:
#0 /raid0/nginx/www/voiceportal/lib/logutils.php(34): serialize(Array)
#1 [internal function]: custom_exception_handler(Object(AMQPConnectionException))
#2 {main}
I read that it can be caused if an anonymous function is tried to be serialized, but this is what threw the error for me:
//logutils.php
function custom_exception_handler($exception) {
$trace_id = uniqid();
$trace = serialize(array('trace_id' => $trace_id, 'trace' => $exception->getTrace()));
...
}
Not sure if it was caused by trying to serialize getTrace(), but if I remember correctly, it used to work earlier.
The original exception was (as seen in the trace) AMQPConnectionException
.
I am trying to understand what caused the 'Serialization of Closure not allowed'
exception.
Thanks!