merged branch dominikzogg/timecollectorfix (PR #8581)

This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #8581).

Discussion
----------

TimeCollector, Notice, if no events

https://github.com/symfony/symfony/issues/8574

Commits
-------

e9da1c0 return 0 if there is no valid data
This commit is contained in:
Fabien Potencier 2013-07-25 19:15:10 +02:00
commit 63ef3c1901
1 changed files with 8 additions and 0 deletions

View File

@ -72,6 +72,10 @@ class TimeDataCollector extends DataCollector
*/
public function getDuration()
{
if (!isset($this->data['events']['__section__'])) {
return 0;
}
$lastEvent = $this->data['events']['__section__'];
return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime();
@ -86,6 +90,10 @@ class TimeDataCollector extends DataCollector
*/
public function getInitTime()
{
if (!isset($this->data['events']['__section__'])) {
return 0;
}
return $this->data['events']['__section__']->getOrigin() - $this->getStartTime();
}