Avoid infinite loops when profiler data is malformed
This commit is contained in:
parent
e1ffb3341d
commit
e5ef9fb74a
|
@ -144,11 +144,19 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$profileToken = $profile->getToken();
|
||||||
|
// when there are errors in sub-requests, the parent and/or children tokens
|
||||||
|
// may equal the profile token, resulting in infinite loops
|
||||||
|
$parentToken = $profile->getParentToken() !== $profileToken ? $profile->getParentToken() : null;
|
||||||
|
$childrenToken = array_filter(array_map(function ($p) use ($profileToken) {
|
||||||
|
return $profileToken !== $p->getToken() ? $p->getToken() : null;
|
||||||
|
}, $profile->getChildren()));
|
||||||
|
|
||||||
// Store profile
|
// Store profile
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => $profile->getToken(),
|
'token' => $profileToken,
|
||||||
'parent' => $profile->getParentToken(),
|
'parent' => $parentToken,
|
||||||
'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()),
|
'children' => $childrenToken,
|
||||||
'data' => $profile->getCollectors(),
|
'data' => $profile->getCollectors(),
|
||||||
'ip' => $profile->getIp(),
|
'ip' => $profile->getIp(),
|
||||||
'method' => $profile->getMethod(),
|
'method' => $profile->getMethod(),
|
||||||
|
|
Reference in New Issue