jonaswouters / XhprofBundle

XHProf bundle for Symfony 2
210 stars 49 forks source link

Prevent "Undefined index: xhprof" in Symfony 2.6 #66

Closed Metabor closed 9 years ago

Metabor commented 9 years ago

When using request_query_argument but not setting the get parameter in the URL there was a "Undefined index: xhprof" error

stephpy commented 9 years ago

You are not profiling data ? Not sure to understand.

$this->data is hydrated here https://github.com/Metabor/XhprofBundle/blob/patch-1/DataCollector/XhprofCollector.php#L125-L129

Metabor commented 9 years ago

The link is not working. I will explain the problem, that is solved with this pull request. We used the Bundle for a long time with request_query_argument. After migrating to Symfony 2.6 we got an error when NOT setting the get parameter, because of the not existing "index" key in $data. It seems that the toolbar in Symfony 2.6 is generated in an other way than before. This fix solves the problem that "index" key is not set, when the request don't activate the profiler and also works when it is activated (because then it is overwritten).

stephpy commented 9 years ago

Sorry, bad copy/paste for link.

IMO there is something else to do with Symfony 2.6. At least you should define each keys of $this->data https://github.com/Metabor/XhprofBundle/blob/patch-1/DataCollector/XhprofCollector.php#L125-L129

It seems in Symfony 2.6, profiler still try to use method of collectors while it should not. So may be the listener is executed while it should not be and it's a bigger problem.

Metabor commented 9 years ago

They added this ajax call thing to the toolbar. Maybe this has side effects on your Bundle.

Metabor commented 9 years ago

Maybe take my pull request as a quick fix and resolve the real problem later. ;)

stephpy commented 9 years ago

Ok. Thanks.