diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index e25b5a6dd8b2..369ed26f125c 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -414,7 +414,7 @@ public function handleError($type, $message, $file, $line) $errorAsException = self::$silencedErrorCache[$message]; ++$errorAsException->count; } else { - $lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), $type, $file, $line, false) : array(); + $lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3), $type, $file, $line, false) : array(); $errorAsException = new SilencedErrorContext($type, $file, $line, $lightTrace); } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index f45f99718d31..92fd0da71e64 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -120,6 +120,7 @@ private function getContainerDeprecationLogs() $log['priorityName'] = 'DEBUG'; $log['channel'] = '-'; $log['scream'] = false; + unset($log['type'], $log['file'], $log['line'], $log['trace'], $log['trace'], $log['count']); $logs[] = $log; } @@ -251,7 +252,7 @@ private function computeErrorsCount(array $containerDeprecationLogs) } foreach ($containerDeprecationLogs as $deprecationLog) { - $count['deprecation_count'] += $deprecationLog['count']; + $count['deprecation_count'] += $deprecationLog['context']['exception']->count; } ksort($count['priorities']); diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 1a0f2434dc60..d6ea3e6f04c5 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -551,7 +551,7 @@ protected function initializeContainer() return; } - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); // Clean the trace by removing first frames added by the error handler itself. for ($i = 0; isset($backtrace[$i]); ++$i) { if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php index 9a306e533e00..e642e3c33715 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php @@ -50,7 +50,7 @@ public function testDump() ); $this->assertEquals($xDump, $dump); - $this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";O:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize()); + $this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize()); $this->assertSame(0, $collector->getDumpsCount()); $this->assertSame('a:2:{i:0;b:0;i:1;s:5:"UTF-8";}', $collector->serialize()); } diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index 5a6997cf251c..655fae0ca6fe 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -16,7 +16,7 @@ /** * @author Nicolas Grekas */ -class Data implements \ArrayAccess, \Countable, \IteratorAggregate +class Data implements \ArrayAccess, \Countable, \IteratorAggregate, \Serializable { private $data; private $position = 0; @@ -278,6 +278,57 @@ public function dump(DumperInterface $dumper) $this->dumpItem($dumper, new Cursor(), $refs, $this->data[$this->position][$this->key]); } + /** + * @internal + */ + public function serialize() + { + $data = $this->data; + + foreach ($data as $i => $values) { + foreach ($values as $k => $v) { + if ($v instanceof Stub) { + if (Stub::TYPE_ARRAY === $v->type) { + $v = self::mapStubConsts($v, false); + $data[$i][$k] = array($v->class, $v->position, $v->cut); + } else { + $v = self::mapStubConsts($v, false); + $data[$i][$k] = array($v->class, $v->position, $v->cut, $v->type, $v->value, $v->handle, $v->refCount, $v->attr); + } + } + } + } + + return serialize(array($data, $this->position, $this->key, $this->maxDepth, $this->maxItemsPerDepth, $this->useRefHandles)); + } + + /** + * @internal + */ + public function unserialize($serialized) + { + list($data, $this->position, $this->key, $this->maxDepth, $this->maxItemsPerDepth, $this->useRefHandles) = unserialize($serialized); + + foreach ($data as $i => $values) { + foreach ($values as $k => $v) { + if ($v && is_array($v)) { + $s = new Stub(); + if (3 === count($v)) { + $s->type = Stub::TYPE_ARRAY; + $s = self::mapStubConsts($s, false); + list($s->class, $s->position, $s->cut) = $v; + $s->value = $s->cut + count($data[$s->position]); + } else { + list($s->class, $s->position, $s->cut, $s->type, $s->value, $s->handle, $s->refCount, $s->attr) = $v; + } + $data[$i][$k] = self::mapStubConsts($s, true); + } + } + } + + $this->data = $data; + } + /** * Depth-first dumping of items. * @@ -406,4 +457,23 @@ private function dumpChildren($dumper, $parentCursor, &$refs, $children, $hashCu return $hashCut; } + + private static function mapStubConsts(Stub $stub, $resolve) + { + static $stubConstIndexes, $stubConstValues; + + if (null === $stubConstIndexes) { + $r = new \ReflectionClass(Stub::class); + $stubConstIndexes = array_flip(array_values($r->getConstants())); + $stubConstValues = array_flip($stubConstIndexes); + } + + $map = $resolve ? $stubConstValues : $stubConstIndexes; + + $stub = clone $stub; + $stub->type = $map[$stub->type]; + $stub->class = isset($map[$stub->class]) ? $map[$stub->class] : $stub->class; + + return $stub; + } }