diff --git a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index aa78dbaacc..c0f240a0ea 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php @@ -87,40 +87,32 @@ class ProfilerListener implements EventSubscriberInterface return; } + $request = $event->getRequest(); $exception = $this->exception; $this->exception = null; - if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) { + if (null !== $this->matcher && !$this->matcher->matches($request)) { return; } - if (!$profile = $this->profiler->collect($event->getRequest(), $event->getResponse(), $exception)) { + if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) { return; } // keep the profile as the child of its parent if (!$master) { array_pop($this->requests); - - $parent = $this->requests[count($this->requests) - 1]; - if (!isset($this->children[$parent])) { - $profiles = array($profile); - } else { - $profiles = $this->children[$parent]; - $profiles[] = $profile; - } - - $this->children[$parent] = $profiles; + $this->children[end($this->requests)][] = $profile; } // store the profile and its children - if (isset($this->children[$event->getRequest()])) { - foreach ($this->children[$event->getRequest()] as $child) { + if (isset($this->children[$request])) { + foreach ($this->children[$request] as $child) { $child->setParent($profile); $profile->addChild($child); $this->profiler->saveProfile($child); } - $this->children[$event->getRequest()] = array(); + $this->children[$request] = array(); } $this->profiler->saveProfile($profile); diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php index 966111c459..840529d9dc 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -157,7 +157,7 @@ class Profiler * @param Response $response A Response instance * @param \Exception $exception An exception instance if the request threw one * - * @return Profile|false A Profile instance or false if the profiler is disabled + * @return Profile|null A Profile instance or false if the profiler is disabled */ public function collect(Request $request, Response $response, \Exception $exception = null) {