laminas / laminas-developer-tools

Module for developer and debug tools for use with laminas-mvc applications.
BSD 3-Clause "New" or "Revised" License
23 stars 13 forks source link

Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' #14

Open weierophinney opened 4 years ago

weierophinney commented 4 years ago

in the application config ,i have a route its type is 'Zend\Mvc\Router\Http\Chain', this type need a parameter 'route_plugins', so i new it in the application config. but in the \Zend\Mvc\Router\RoutePluginManager, the initializer propery store some closures. so when the application config is serialized, the error happend.

i think we need a method named makeObjectProperySerializable in the class Collector\ConfigCollector


Originally posted by @h3110w0r1d at https://github.com/zendframework/zend-developer-tools/issues/153

weierophinney commented 4 years ago

@h3110w0r1d do you have a stack trace for this? But yeah, we may need some clever way of replacing those unserializable instances.


Originally posted by @Ocramius at https://github.com/zendframework/zend-developer-tools/issues/153#issuecomment-44396841

weierophinney commented 4 years ago

Stack trace:

 #0 /home/ethantsien/project/www/h3110w0r1d.com/vendor/zendframework/zend-developer-tools/src/ZendDeveloperTools/Collector/ConfigCollector.php(94): serialize(Array) 

#1 [internal function]: ZendDeveloperTools\Collector\ConfigCollector->serialize() 

#2 /home/ethantsien/project/www/h3110w0r1d.com/vendor/zendframework/zend-developer-tools/src/ZendDeveloperTools/Profiler.php(213): serialize(Object(ZendDeveloperTools\Collector\ConfigCollector)) 

#3 /home/ethantsien/project/www/h3110w0r1d.com/vendor/zendframework/zend-developer-tools/src/ZendDeveloperTools/Listener/ProfilerListener.php(107): ZendDeveloperTools\Profiler->collect(Object(Zend\Mvc\MvcEvent)) 

#4 [internal function]: ZendDeveloperTools\Listener\ProfilerListener->onFinish(Object(Zend\Mvc\MvcEvent)) #5 /home/ethantsien in /home/ethantsien/project/www/h3110w0r1d.com/vendor/zendframework/zend-developer-tools/src/ZendDeveloperTools/Collector/ConfigCollector.php on line 94

i am sure that the line ''route_plugins' => new RoutePluginManager(),' in the config below cause this error

return array(
    'router' => array(
        'routes' => array(
            'passport' => array(
                'type' => 'chain',
                'options' => array(
                    'routes' => array(
                        'hostname' => array(
                            'type' => 'Zend\Mvc\Router\Http\Hostname',
                            'options' => array(
                                'route' => PASSPORT_HOSTNAME,    
                                'defaults' => array(
                                    '__NAMESPACE__' => 'Passport\Controller',
                                    'controller' => 'Index',
                                    'action' => 'index',    
                                ),
                            ),    
                        ),
                        'scheme' => array(
                            'type' => 'Zend\Mvc\Router\Http\Scheme',
                            'options' => array(
                                'scheme' => 'http',
                            ),    
                        ),
                    ),
                    'route_plugins' => new RoutePluginManager(),
                ),

                'may_terminate' => true,

                'child_routes' => array(
                    'home' => array(
                        'type' => 'literal',
                        'options' => array(
                            'route' => '/',
                        ),
                    ),
                    'register' => array(
                        'type' => 'literal',
                        'options' => array(
                            'route' => '/register',
                            'defaults' => array(
                                'action' => 'register',    
                            ), 
                        ),    
                    ),
                    'login' => array(
                        'type' => 'literal',
                        'options' => array(
                            'route' => '/login',
                            'defaults' => array(
                                'action' => 'login',    
                            ),
                        ),    
                    ),
                    'logout' => array(
                        'type' => 'literal',
                        'options' => array(
                            'route' => '/logout',
                            'defaults' => array(
                                'action' => 'logout',    
                            ), 
                        ),    
                    ),
                ),
            ),
        ),    
    ),
);

Originally posted by @h3110w0r1d at https://github.com/zendframework/zend-developer-tools/issues/153#issuecomment-44397495

weierophinney commented 4 years ago

@h3110w0r1d yeah, I have something in RoaveDeveloperTools which may be backported here, see https://github.com/Roave/RoaveDeveloperTools/blob/424285eb861c9df7891ce7c6e66a21756eecd81c/src/Roave/DeveloperTools/Stub/SerializableValueStub.php#L44


Originally posted by @Ocramius at https://github.com/zendframework/zend-developer-tools/issues/153#issuecomment-44398163

weierophinney commented 4 years ago

thanks 2014年5月28日 下午8:11于 "Marco Pivetta" notifications@github.com写道:

@h3110w0r1d https://github.com/h3110w0r1d yeah, I have something in RoaveDeveloperTools which may be backported here, see https://github.com/Roave/RoaveDeveloperTools/blob/424285eb861c9df7891ce7c6e66a21756eecd81c/src/Roave/DeveloperTools/Stub/SerializableValueStub.php#L44

— Reply to this email directly or view it on GitHubhttps://github.com/zendframework/ZendDeveloperTools/issues/153#issuecomment-44398163 .


Originally posted by @h3110w0r1d at https://github.com/zendframework/zend-developer-tools/issues/153#issuecomment-44399058

weierophinney commented 4 years ago

Still an issue.


Originally posted by @Ocramius at https://github.com/zendframework/zend-developer-tools/issues/153#issuecomment-44744591

weierophinney commented 4 years ago

a very annoying one


Originally posted by @Perfect-Web at https://github.com/zendframework/zend-developer-tools/issues/153#issuecomment-80971724