Laravel version update
Laravel version update
This commit is contained in:
@@ -49,7 +49,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null)
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null)
|
||||
{
|
||||
$file = $this->getIndexFilename();
|
||||
|
||||
@@ -61,14 +61,12 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
fseek($file, 0, SEEK_END);
|
||||
|
||||
$result = array();
|
||||
while (count($result) < $limit && $line = $this->readLineFromFile($file)) {
|
||||
while (\count($result) < $limit && $line = $this->readLineFromFile($file)) {
|
||||
$values = str_getcsv($line);
|
||||
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = $values;
|
||||
$csvStatusCode = isset($values[6]) ? $values[6] : null;
|
||||
|
||||
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode) = $values;
|
||||
$csvTime = (int) $csvTime;
|
||||
|
||||
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) {
|
||||
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method) || $statusCode && false === strpos($csvStatusCode, $statusCode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -138,22 +136,31 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
$profileIndexed = is_file($file);
|
||||
if (!$profileIndexed) {
|
||||
// Create directory
|
||||
$dir = dirname($file);
|
||||
$dir = \dirname($file);
|
||||
if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
|
||||
throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir));
|
||||
}
|
||||
}
|
||||
|
||||
$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
|
||||
$data = array(
|
||||
'token' => $profile->getToken(),
|
||||
'parent' => $profile->getParentToken(),
|
||||
'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()),
|
||||
'token' => $profileToken,
|
||||
'parent' => $parentToken,
|
||||
'children' => $childrenToken,
|
||||
'data' => $profile->getCollectors(),
|
||||
'ip' => $profile->getIp(),
|
||||
'method' => $profile->getMethod(),
|
||||
'url' => $profile->getUrl(),
|
||||
'time' => $profile->getTime(),
|
||||
'status_code' => $profile->getStatusCode(),
|
||||
);
|
||||
|
||||
if (false === file_put_contents($file, serialize($data))) {
|
||||
@@ -261,6 +268,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
$profile->setMethod($data['method']);
|
||||
$profile->setUrl($data['url']);
|
||||
$profile->setTime($data['time']);
|
||||
$profile->setStatusCode($data['status_code']);
|
||||
$profile->setCollectors($data['data']);
|
||||
|
||||
if (!$parent && $data['parent']) {
|
||||
|
21
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
21
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
@@ -44,8 +44,6 @@ class Profile
|
||||
private $children = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $token The token
|
||||
*/
|
||||
public function __construct($token)
|
||||
@@ -75,8 +73,6 @@ class Profile
|
||||
|
||||
/**
|
||||
* Sets the parent token.
|
||||
*
|
||||
* @param Profile $parent The parent Profile
|
||||
*/
|
||||
public function setParent(Profile $parent)
|
||||
{
|
||||
@@ -86,7 +82,7 @@ class Profile
|
||||
/**
|
||||
* Returns the parent profile.
|
||||
*
|
||||
* @return Profile The parent profile
|
||||
* @return self
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
@@ -156,7 +152,7 @@ class Profile
|
||||
/**
|
||||
* Returns the time.
|
||||
*
|
||||
* @return string The time
|
||||
* @return int The time
|
||||
*/
|
||||
public function getTime()
|
||||
{
|
||||
@@ -167,6 +163,9 @@ class Profile
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $time The time
|
||||
*/
|
||||
public function setTime($time)
|
||||
{
|
||||
$this->time = $time;
|
||||
@@ -191,7 +190,7 @@ class Profile
|
||||
/**
|
||||
* Finds children profilers.
|
||||
*
|
||||
* @return Profile[] An array of Profile
|
||||
* @return self[]
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
@@ -201,7 +200,7 @@ class Profile
|
||||
/**
|
||||
* Sets children profiler.
|
||||
*
|
||||
* @param Profile[] $children An array of Profile
|
||||
* @param Profile[] $children
|
||||
*/
|
||||
public function setChildren(array $children)
|
||||
{
|
||||
@@ -213,8 +212,6 @@ class Profile
|
||||
|
||||
/**
|
||||
* Adds the child token.
|
||||
*
|
||||
* @param Profile $child The child Profile
|
||||
*/
|
||||
public function addChild(Profile $child)
|
||||
{
|
||||
@@ -265,8 +262,6 @@ class Profile
|
||||
|
||||
/**
|
||||
* Adds a Collector.
|
||||
*
|
||||
* @param DataCollectorInterface $collector A DataCollectorInterface instance
|
||||
*/
|
||||
public function addCollector(DataCollectorInterface $collector)
|
||||
{
|
||||
@@ -287,6 +282,6 @@ class Profile
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time');
|
||||
return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode');
|
||||
}
|
||||
}
|
||||
|
68
vendor/symfony/http-kernel/Profiler/Profiler.php
vendored
68
vendor/symfony/http-kernel/Profiler/Profiler.php
vendored
@@ -11,12 +11,12 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Profiler;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
|
||||
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Profiler.
|
||||
@@ -25,9 +25,6 @@ use Psr\Log\LoggerInterface;
|
||||
*/
|
||||
class Profiler
|
||||
{
|
||||
/**
|
||||
* @var ProfilerStorageInterface
|
||||
*/
|
||||
private $storage;
|
||||
|
||||
/**
|
||||
@@ -35,26 +32,18 @@ class Profiler
|
||||
*/
|
||||
private $collectors = array();
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $initiallyEnabled = true;
|
||||
private $enabled = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ProfilerStorageInterface $storage A ProfilerStorageInterface instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
* @param bool $enable The initial enabled state
|
||||
*/
|
||||
public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null)
|
||||
public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, $enable = true)
|
||||
{
|
||||
$this->storage = $storage;
|
||||
$this->logger = $logger;
|
||||
$this->initiallyEnabled = $this->enabled = (bool) $enable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,9 +65,7 @@ class Profiler
|
||||
/**
|
||||
* Loads the Profile for the given Response.
|
||||
*
|
||||
* @param Response $response A Response instance
|
||||
*
|
||||
* @return Profile A Profile instance
|
||||
* @return Profile|false A Profile instance
|
||||
*/
|
||||
public function loadProfileFromResponse(Response $response)
|
||||
{
|
||||
@@ -104,8 +91,6 @@ class Profiler
|
||||
/**
|
||||
* Saves a Profile.
|
||||
*
|
||||
* @param Profile $profile A Profile instance
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveProfile(Profile $profile)
|
||||
@@ -118,7 +103,7 @@ class Profiler
|
||||
}
|
||||
|
||||
if (!($ret = $this->storage->write($profile)) && null !== $this->logger) {
|
||||
$this->logger->warning('Unable to store the profiler information.', array('configured_storage' => get_class($this->storage)));
|
||||
$this->logger->warning('Unable to store the profiler information.', array('configured_storage' => \get_class($this->storage)));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -135,29 +120,26 @@ class Profiler
|
||||
/**
|
||||
* Finds profiler tokens for the given criteria.
|
||||
*
|
||||
* @param string $ip The IP
|
||||
* @param string $url The URL
|
||||
* @param string $limit The maximum number of tokens to return
|
||||
* @param string $method The request method
|
||||
* @param string $start The start date to search from
|
||||
* @param string $end The end date to search to
|
||||
* @param string $ip The IP
|
||||
* @param string $url The URL
|
||||
* @param string $limit The maximum number of tokens to return
|
||||
* @param string $method The request method
|
||||
* @param string $start The start date to search from
|
||||
* @param string $end The end date to search to
|
||||
* @param string $statusCode The request status code
|
||||
*
|
||||
* @return array An array of tokens
|
||||
*
|
||||
* @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start, $end)
|
||||
public function find($ip, $url, $limit, $method, $start, $end, $statusCode = null)
|
||||
{
|
||||
return $this->storage->find($ip, $url, $limit, $method, $this->getTimestamp($start), $this->getTimestamp($end));
|
||||
return $this->storage->find($ip, $url, $limit, $method, $this->getTimestamp($start), $this->getTimestamp($end), $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects data for the given Response.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param Response $response A Response instance
|
||||
* @param \Exception $exception An exception instance if the request threw one
|
||||
*
|
||||
* @return Profile|null A Profile instance or null if the profiler is disabled
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
@@ -189,6 +171,18 @@ class Profiler
|
||||
return $profile;
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
foreach ($this->collectors as $collector) {
|
||||
if (!method_exists($collector, 'reset')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$collector->reset();
|
||||
}
|
||||
$this->enabled = $this->initiallyEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Collectors associated with this profiler.
|
||||
*
|
||||
@@ -214,11 +208,13 @@ class Profiler
|
||||
|
||||
/**
|
||||
* Adds a Collector.
|
||||
*
|
||||
* @param DataCollectorInterface $collector A DataCollectorInterface instance
|
||||
*/
|
||||
public function add(DataCollectorInterface $collector)
|
||||
{
|
||||
if (!method_exists($collector, 'reset')) {
|
||||
@trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', DataCollectorInterface::class, \get_class($collector)), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->collectors[$collector->getName()] = $collector;
|
||||
}
|
||||
|
||||
|
@@ -46,8 +46,6 @@ interface ProfilerStorageInterface
|
||||
/**
|
||||
* Saves a Profile.
|
||||
*
|
||||
* @param Profile $profile A Profile instance
|
||||
*
|
||||
* @return bool Write operation successful
|
||||
*/
|
||||
public function write(Profile $profile);
|
||||
|
Reference in New Issue
Block a user