Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+35 -37
View File
@@ -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,36 +25,25 @@ use Psr\Log\LoggerInterface;
*/
class Profiler
{
/**
* @var ProfilerStorageInterface
*/
private $storage;
/**
* @var DataCollectorInterface[]
*/
private $collectors = array();
private $collectors = [];
/**
* @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,14 +65,12 @@ class Profiler
/**
* Loads the Profile for the given Response.
*
* @param Response $response A Response instance
*
* @return Profile|false A Profile instance
* @return Profile|null A Profile instance
*/
public function loadProfileFromResponse(Response $response)
{
if (!$token = $response->headers->get('X-Debug-Token')) {
return false;
return null;
}
return $this->loadProfile($token);
@@ -94,7 +81,7 @@ class Profiler
*
* @param string $token A token
*
* @return Profile A Profile instance
* @return Profile|null A Profile instance
*/
public function loadProfile($token)
{
@@ -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.', ['configured_storage' => \get_class($this->storage)]);
}
return $ret;
@@ -145,7 +130,7 @@ class Profiler
*
* @return array An array of tokens
*
* @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats
* @see https://php.net/datetime.formats for the supported date/time formats
*/
public function find($ip, $url, $limit, $method, $start, $end, $statusCode = null)
{
@@ -155,16 +140,12 @@ class Profiler
/**
* 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)
{
if (false === $this->enabled) {
return;
return null;
}
$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
@@ -190,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.
*
@@ -205,9 +198,9 @@ class Profiler
*
* @param DataCollectorInterface[] $collectors An array of collectors
*/
public function set(array $collectors = array())
public function set(array $collectors = [])
{
$this->collectors = array();
$this->collectors = [];
foreach ($collectors as $collector) {
$this->add($collector);
}
@@ -215,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;
}
@@ -253,16 +248,19 @@ class Profiler
return $this->collectors[$name];
}
/**
* @return int|null
*/
private function getTimestamp($value)
{
if (null === $value || '' == $value) {
return;
return null;
}
try {
$value = new \DateTime(is_numeric($value) ? '@'.$value : $value);
} catch (\Exception $e) {
return;
return null;
}
return $value->getTimestamp();