8p / EightPointsGuzzleBundle

⛽️ Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony
MIT License
440 stars 71 forks source link

Guzzle is trying to serialize a PDO object, fails with a PDO Exception #8

Closed respinoza closed 9 years ago

respinoza commented 9 years ago

It seems that the new way the logging work is breaking as Guzzle is trying to serialize a PDO object. As you already know, they cannot be serialized so a PDO Exception is thrown.

I can confirm it works fine in b4fd12fb232ae57bb41f68c84e045d17823e7ef1

What information do you need to debug this?

Thank you

florianpreusner commented 9 years ago

Hi,

thanks for your information.

Best regards Florian

nurikabe commented 9 years ago

Seeing the same thing here: Seems to be crashing when rendering a controller:

{{ render(controller('Bundle:Controller:action')) }}

from within Twig.

I haven't dug much deeper than this but I'm going to guess that GuzzleBundle needs to be aware of a master request versus a sub-request when serializing.

We've been using dev-master until now.

p-bizouard commented 9 years ago

Same here. I just installed the bundle (dev-master), and when I enable it, I got this :

Exception in DataCollector.php line 35:
Serialization of 'Closure' is not allowed
in DataCollector.php line 35
at SplObjectStorage->serialize()
at serialize(array('logs' => array('http://****/app_dev.php/admin/login' => object(LogGroup)), 'callCount' => '0')) in DataCollector.php line 35
at DataCollector->serialize()
at serialize(array('token' => 'd6c559', 'parent' => null, 'children' => array(), 'data' => array('form' => object(FormDataCollector), 'config' => object(ConfigDataCollector), 'request' => object(RequestDataCollector), 'ajax' => object(AjaxDataCollector), 'exception' => object(ExceptionDataCollector), 'events' => object(EventDataCollector), 'logger' => object(LoggerDataCollector), 'time' => object(TimeDataCollector), 'memory' => object(MemoryDataCollector), 'router' => object(RouterDataCollector), 'security' => object(SecurityDataCollector), 'swiftmailer' => object(MessageDataCollector), 'db' => object(DoctrineDataCollector), 'guzzle' => object(HttpDataCollector), 'ladybug' => object(LadybugDataCollector)), 'ip' => '195.132.182.57', 'method' => 'GET', 'url' => 'http://******/app_dev.php/admin/login', 'time' => '1432054784')) in FileProfilerStorage.php line 153
at FileProfilerStorage->write(object(Profile)) in Profiler.php line 119
at Profiler->saveProfile(object(Profile)) in ProfilerListener.php line 139
at ProfilerListener->onKernelTerminate(object(PostResponseEvent), 'kernel.terminate', object(TraceableEventDispatcher))
at call_user_func(array(object(ProfilerListener), 'onKernelTerminate'), object(PostResponseEvent), 'kernel.terminate', object(TraceableEventDispatcher)) in WrappedListener.php line 61
at WrappedListener->__invoke(object(PostResponseEvent), 'kernel.terminate', object(ContainerAwareEventDispatcher))
at call_user_func(object(WrappedListener), object(PostResponseEvent), 'kernel.terminate', object(ContainerAwareEventDispatcher)) in classes.php line 1790
at EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener)), 'kernel.terminate', object(PostResponseEvent)) in classes.php line 1723
at EventDispatcher->dispatch('kernel.terminate', object(PostResponseEvent)) in classes.php line 1884
at ContainerAwareEventDispatcher->dispatch('kernel.terminate', object(PostResponseEvent)) in TraceableEventDispatcher.php line 112
at TraceableEventDispatcher->dispatch('kernel.terminate', object(PostResponseEvent)) in bootstrap.php.cache line 2995
at HttpKernel->terminate(object(Request), object(Response)) in bootstrap.php.cache line 2357
at Kernel->terminate(object(Request), object(Response)) in app_dev.php line 31

My page is fully loaded, I see the template results, but at the end of the page an exception is thrown. When I disable the bundle, everything works fine.

Cache cleared, not any Guzzle function called, cookies cleared

florianpreusner commented 9 years ago

I have tried to reproduce this bug but I'm not able to get this exception. I tested using rendering a controller inside a twig template. I got a Guzzle request inside this controller, also one in the main controller. I'm getting no error. All classes inside this bundle are not using closures.

Using PHP 5.5.10 and Symfony 2.6.7.

Can someone try to deactivate using "Request" in collect function in HttpDataCollector? Or providing some snippets of code that I'm able to reproduce.

respinoza commented 9 years ago

Florian,

If I pull the latest commit and disabled the Request by commenting out the line 65 in HttpDataCollector $logGroup->setRequest($request);

No PDO Exception was thrown. Now, I don't have a snippet but the problem arises when a Request attribute is an entity.

Specifically, I am seeing this problem in a sub-request (fragment) as my controller action is expecting an object of type X, like:

SomeController::someAction(Request $request, MyObject $object)

florianpreusner commented 9 years ago

Now the collector is just storing a name of the request instead of the whole object. This should fix the issue. Please verify so I can create a new tag/version. Thanks!

respinoza commented 9 years ago

Thank you for the quick fix. I pulled your changes and started running the tests from my application. I will let you know in an hour if everything worked as expected.

respinoza commented 9 years ago

Everything seems to be working.

Thank you again for the quick fix.

florianpreusner commented 9 years ago

You are welcome. Thanks also.

p-bizouard commented 9 years ago

Everything works fine here too. Thank you