composer update
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpKernel\DataCollector;
|
||||
|
||||
use Symfony\Component\VarDumper\Caster\CutStub;
|
||||
use Symfony\Component\VarDumper\Caster\ReflectionCaster;
|
||||
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
@@ -25,7 +26,7 @@ use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@symfony.com>
|
||||
*/
|
||||
abstract class DataCollector implements DataCollectorInterface, \Serializable
|
||||
abstract class DataCollector implements DataCollectorInterface
|
||||
{
|
||||
protected $data = [];
|
||||
|
||||
@@ -34,16 +35,26 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
|
||||
*/
|
||||
private $cloner;
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.3, store all the serialized state in the data property instead
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
@trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3, store all the serialized state in the data property instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
|
||||
$isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object'];
|
||||
|
||||
return $isCalledFromOverridingMethod ? $this->data : serialize($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.3, store all the serialized state in the data property instead
|
||||
*/
|
||||
public function unserialize($data)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3, store all the serialized state in the data property instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->data = \is_array($data) ? $data : unserialize($data);
|
||||
}
|
||||
|
||||
@@ -79,7 +90,7 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
|
||||
*/
|
||||
protected function getCasters()
|
||||
{
|
||||
return [
|
||||
$casters = [
|
||||
'*' => function ($v, array $a, Stub $s, $isNested) {
|
||||
if (!$v instanceof Stub) {
|
||||
foreach ($a as $k => $v) {
|
||||
@@ -92,5 +103,29 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
|
||||
return $a;
|
||||
},
|
||||
];
|
||||
|
||||
if (method_exists(ReflectionCaster::class, 'unsetClosureFileInfo')) {
|
||||
$casters += ReflectionCaster::UNSET_CLOSURE_FILE_INFO;
|
||||
}
|
||||
|
||||
return $casters;
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
|
||||
@trigger_error(sprintf('Implementing the "%s::serialize()" method is deprecated since Symfony 4.3, store all the serialized state in the "data" property instead.', $c), E_USER_DEPRECATED);
|
||||
$this->data = $this->serialize();
|
||||
}
|
||||
|
||||
return ['data'];
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'unserialize'))->getDeclaringClass()->name) {
|
||||
@trigger_error(sprintf('Implementing the "%s::unserialize()" method is deprecated since Symfony 4.3, store all the serialized state in the "data" property instead.', $c), E_USER_DEPRECATED);
|
||||
$this->unserialize($this->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ use Symfony\Component\VarDumper\Server\Connection;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final since Symfony 4.3
|
||||
*/
|
||||
class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
{
|
||||
@@ -85,6 +87,9 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$this->isCollected = false;
|
||||
}
|
||||
|
||||
if (!$this->dataCount) {
|
||||
$this->data = [];
|
||||
}
|
||||
$this->data[] = compact('data', 'name', 'file', 'line', 'fileExcerpt');
|
||||
++$this->dataCount;
|
||||
|
||||
@@ -95,6 +100,10 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
if (!$this->dataCount) {
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
// Sub-requests and programmatic calls stay in the collected profile.
|
||||
if ($this->dumper || ($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) {
|
||||
return;
|
||||
@@ -113,6 +122,9 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
|
||||
} else {
|
||||
$dumper = new CliDumper('php://output', $this->charset);
|
||||
if (method_exists($dumper, 'setDisplayOptions')) {
|
||||
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->data as $dump) {
|
||||
@@ -133,28 +145,38 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$this->clonesIndex = 0;
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
if (!$this->dataCount) {
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
if ($this->clonesCount !== $this->clonesIndex) {
|
||||
return 'a:0:{}';
|
||||
return [];
|
||||
}
|
||||
|
||||
$this->data[] = $this->fileLinkFormat;
|
||||
$this->data[] = $this->charset;
|
||||
$ser = serialize($this->data);
|
||||
$this->data = [];
|
||||
$this->dataCount = 0;
|
||||
$this->isCollected = true;
|
||||
|
||||
return $ser;
|
||||
return parent::__sleep();
|
||||
}
|
||||
|
||||
public function unserialize($data)
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->data = unserialize($data);
|
||||
parent::__wakeup();
|
||||
|
||||
$charset = array_pop($this->data);
|
||||
$fileLinkFormat = array_pop($this->data);
|
||||
$this->dataCount = \count($this->data);
|
||||
|
||||
self::__construct($this->stopwatch, $fileLinkFormat, $charset);
|
||||
}
|
||||
|
||||
@@ -175,6 +197,10 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
$dumps = [];
|
||||
|
||||
if (!$this->dataCount) {
|
||||
return $this->data = [];
|
||||
}
|
||||
|
||||
foreach ($this->data as $dump) {
|
||||
$dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth));
|
||||
$dump['data'] = stream_get_contents($data, -1, 0);
|
||||
@@ -193,7 +219,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (0 === $this->clonesCount-- && !$this->isCollected && $this->data) {
|
||||
if (0 === $this->clonesCount-- && !$this->isCollected && $this->dataCount) {
|
||||
$this->clonesCount = 0;
|
||||
$this->isCollected = true;
|
||||
|
||||
@@ -215,6 +241,9 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
|
||||
} else {
|
||||
$dumper = new CliDumper('php://output', $this->charset);
|
||||
if (method_exists($dumper, 'setDisplayOptions')) {
|
||||
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->data as $i => $dump) {
|
||||
|
||||
@@ -13,9 +13,10 @@ namespace Symfony\Component\HttpKernel\DataCollector;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
/**
|
||||
@@ -26,10 +27,13 @@ use Symfony\Contracts\Service\ResetInterface;
|
||||
class EventDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
protected $dispatcher;
|
||||
private $requestStack;
|
||||
private $currentRequest;
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(EventDispatcherInterface $dispatcher = null, RequestStack $requestStack = null)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,6 +41,7 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
|
||||
$this->data = [
|
||||
'called_listeners' => [],
|
||||
'not_called_listeners' => [],
|
||||
@@ -56,12 +61,12 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
public function lateCollect()
|
||||
{
|
||||
if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
|
||||
$this->setCalledListeners($this->dispatcher->getCalledListeners());
|
||||
$this->setNotCalledListeners($this->dispatcher->getNotCalledListeners());
|
||||
$this->setCalledListeners($this->dispatcher->getCalledListeners($this->currentRequest));
|
||||
$this->setNotCalledListeners($this->dispatcher->getNotCalledListeners($this->currentRequest));
|
||||
}
|
||||
|
||||
if ($this->dispatcher instanceof TraceableEventDispatcher) {
|
||||
$this->setOrphanedEvents($this->dispatcher->getOrphanedEvents());
|
||||
$this->setOrphanedEvents($this->dispatcher->getOrphanedEvents($this->currentRequest));
|
||||
}
|
||||
|
||||
$this->data = $this->cloneVar($this->data);
|
||||
|
||||
@@ -66,7 +66,9 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
if (null !== $this->logger) {
|
||||
$containerDeprecationLogs = $this->getContainerDeprecationLogs();
|
||||
$this->data = $this->computeErrorsCount($containerDeprecationLogs);
|
||||
$this->data['compiler_logs'] = $this->getContainerCompilerLogs();
|
||||
// get compiler logs later (only when they are needed) to improve performance
|
||||
$this->data['compiler_logs'] = [];
|
||||
$this->data['compiler_logs_filepath'] = $this->containerPathPrefix.'Compiler.log';
|
||||
$this->data['logs'] = $this->sanitizeLogs(array_merge($this->logger->getLogs($this->currentRequest), $containerDeprecationLogs));
|
||||
$this->data = $this->cloneVar($this->data);
|
||||
}
|
||||
@@ -110,7 +112,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
public function getCompilerLogs()
|
||||
{
|
||||
return isset($this->data['compiler_logs']) ? $this->data['compiler_logs'] : [];
|
||||
return $this->cloneVar($this->getContainerCompilerLogs($this->data['compiler_logs_filepath'] ?? null));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,14 +149,14 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $logs;
|
||||
}
|
||||
|
||||
private function getContainerCompilerLogs()
|
||||
private function getContainerCompilerLogs(?string $compilerLogsFilepath = null): array
|
||||
{
|
||||
if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Compiler.log')) {
|
||||
if (!file_exists($compilerLogsFilepath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$logs = [];
|
||||
foreach (file($file, FILE_IGNORE_NEW_LINES) as $log) {
|
||||
foreach (file($compilerLogsFilepath, FILE_IGNORE_NEW_LINES) as $log) {
|
||||
$log = explode(': ', $log, 2);
|
||||
if (!isset($log[1]) || !preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $log[0])) {
|
||||
$log = ['Unknown Compiler Pass', implode(': ', $log)];
|
||||
|
||||
@@ -252,6 +252,18 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
return $this->data['content'];
|
||||
}
|
||||
|
||||
public function isJsonRequest()
|
||||
{
|
||||
return 1 === preg_match('{^application/(?:\w+\++)*json$}i', $this->data['request_headers']['content-type']);
|
||||
}
|
||||
|
||||
public function getPrettyJson()
|
||||
{
|
||||
$decoded = json_decode($this->getContent());
|
||||
|
||||
return JSON_ERROR_NONE === json_last_error() ? json_encode($decoded, JSON_PRETTY_PRINT) : null;
|
||||
}
|
||||
|
||||
public function getContentType()
|
||||
{
|
||||
return $this->data['content_type'];
|
||||
@@ -338,11 +350,17 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
return isset($this->data['forward_token']) ? $this->data['forward_token'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.3
|
||||
*/
|
||||
public function onKernelController(FilterControllerEvent $event)
|
||||
{
|
||||
$this->controllers[$event->getRequest()] = $event->getController();
|
||||
}
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.3
|
||||
*/
|
||||
public function onKernelResponse(FilterResponseEvent $event)
|
||||
{
|
||||
if (!$event->isMasterRequest()) {
|
||||
|
||||
@@ -17,8 +17,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
||||
|
||||
/**
|
||||
* RouterDataCollector.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class RouterDataCollector extends DataCollector
|
||||
@@ -68,6 +66,8 @@ class RouterDataCollector extends DataCollector
|
||||
|
||||
/**
|
||||
* Remembers the controller associated to each request.
|
||||
*
|
||||
* @final since Symfony 4.3
|
||||
*/
|
||||
public function onKernelController(FilterControllerEvent $event)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user