From 8d6e3376028cad2940a58a229fe9e9c2a4c3e6a8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 30 Aug 2015 14:16:23 +0200 Subject: [PATCH 1/3] [HttpKernel] Group deprecation notices --- .../views/Collector/logger.html.twig | 4 ++ .../DataCollector/LoggerDataCollector.php | 41 ++++++++++++++++--- .../DataCollector/LoggerDataCollectorTest.php | 14 ++++++- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig index 291a4eac110c..261163090bca 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig @@ -116,6 +116,10 @@ {% set stack = log.context.stack|default([]) %} {% set id = 'sf-call-stack-' ~ log_index %} + {% if log.context.errorCount is defined %} + ({{ log.context.errorCount }}x) + {% endif %} + {% if stack %} diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index 0d1decda3a01..12584345a248 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -97,15 +97,46 @@ public function getName() private function sanitizeLogs($logs) { - foreach ($logs as $i => $log) { + $errorContextById = array(); + $sanitizedLogs = array(); + + foreach ($logs as $log) { $context = $this->sanitizeContext($log['context']); - if (isset($context['type'], $context['level']) && !($context['type'] & $context['level'])) { - $context['scream'] = true; + + if (isset($context['type'], $context['file'], $context['line'], $context['level'])) { + $errorId = md5("{$context['type']}/{$context['line']}/{$context['file']}\x00{$log['message']}", true); + $silenced = !($context['type'] & $context['level']); + + if (isset($errorContextById[$errorId])) { + if (isset($errorContextById[$errorId]['errorCount'])) { + ++$errorContextById[$errorId]['errorCount']; + } else { + $errorContextById[$errorId]['errorCount'] = 2; + } + + if (!$silenced && isset($errorContextById[$errorId]['scream'])) { + unset($errorContextById[$errorId]['scream']); + $errorContextById[$errorId]['level'] = $context['level']; + } + + continue; + } + + $errorContextById[$errorId] = &$context; + if ($silenced) { + $context['scream'] = true; + } + + $log['context'] = &$context; + unset($context); + } else { + $log['context'] = $context; } - $logs[$i]['context'] = $context; + + $sanitizedLogs[] = $log; } - return $logs; + return $sanitizedLogs; } private function sanitizeContext($context) diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 4303ab134342..dd1608ce7f3a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -75,8 +75,18 @@ public function getCollectTestData() ), array( 1, - array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')), + array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')), + array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')), + 0, + 1, + ), + array( + 1, + array( + array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'), + array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'), + ), + array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123, 'errorCount' => 2), 'priority' => 100, 'priorityName' => 'DEBUG')), 0, 1, ), From 0f2256e85a792409ce0071bcf16286bef1092243 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 31 Aug 2015 16:18:45 +0200 Subject: [PATCH 2/3] [appveyor] PHP 5.3.11 for Symfony 2.7 --- appveyor.yml | 4 ++-- src/Symfony/Component/Console/Descriptor/JsonDescriptor.php | 4 ++-- .../Component/Console/Descriptor/MarkdownDescriptor.php | 4 ++-- src/Symfony/Component/Console/Descriptor/TextDescriptor.php | 4 ++-- .../Tests/Normalizer/GetSetMethodNormalizerTest.php | 3 +++ .../Serializer/Tests/Normalizer/ObjectNormalizerTest.php | 3 +++ 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2eefdb1ce89e..2e4d1cce4021 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,8 +22,8 @@ init: install: - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) - cd c:\php - - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.3.3-nts-Win32-VC9-x86.zip - - IF %PHP%==1 7z x php-5.3.3-nts-Win32-VC9-x86.zip -y > 7z.log + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.3.11-nts-Win32-VC9-x86.zip + - IF %PHP%==1 7z x php-5.3.11-nts-Win32-VC9-x86.zip -y > 7z.log - IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/ICU-51.2-dlls.zip - IF %PHP%==1 7z x ICU-51.2-dlls.zip -y > 7z.log - IF %PHP%==1 cd ext diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index 8649d3ac456f..87e38fdb8907 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -102,7 +102,7 @@ private function getInputArgumentData(InputArgument $argument) 'name' => $argument->getName(), 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), - 'description' => preg_replace('/\s*\R\s*/', ' ', $argument->getDescription()), + 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()), 'default' => $argument->getDefault(), ); } @@ -120,7 +120,7 @@ private function getInputOptionData(InputOption $option) 'accept_value' => $option->acceptValue(), 'is_value_required' => $option->isValueRequired(), 'is_multiple' => $option->isArray(), - 'description' => preg_replace('/\s*\R\s*/', ' ', $option->getDescription()), + 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), 'default' => $option->getDefault(), ); } diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php index 10f05168d47d..d3d76a420102 100644 --- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -36,7 +36,7 @@ protected function describeInputArgument(InputArgument $argument, array $options .'* Name: '.($argument->getName() ?: '')."\n" .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n" - .'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $argument->getDescription() ?: '')."\n" + .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '')."\n" .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`' ); } @@ -53,7 +53,7 @@ protected function describeInputOption(InputOption $option, array $options = arr .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n" .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n" .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n" - .'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $option->getDescription() ?: '')."\n" + .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '')."\n" .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`' ); } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 212796a3edcc..57e09e4d81c3 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -44,7 +44,7 @@ protected function describeInputArgument(InputArgument $argument, array $options $argument->getName(), str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces - preg_replace('/\s*\R\s*/', PHP_EOL.str_repeat(' ', $totalWidth + 17), $argument->getDescription()), + preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $argument->getDescription()), $default ), $options); } @@ -81,7 +81,7 @@ protected function describeInputOption(InputOption $option, array $options = arr $synopsis, str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces - preg_replace('/\s*\R\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()), + preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()), $default, $option->isArray() ? ' (multiple values allowed)' : '' ), $options); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 24036292cace..53369629e6fe 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -209,6 +209,9 @@ public function testConstructorDenormalizeWithMissingOptionalArgument() public function testConstructorDenormalizeWithOptionalDefaultArgument() { + if (PHP_VERSION_ID <= 50316) { + $this->markTestSkipped('See https://bugs.php.net/62715'); + } $obj = $this->normalizer->denormalize( array('bar' => 'test'), __NAMESPACE__.'\GetConstructorArgsWithDefaultValueDummy', 'any'); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 7d9da645c4f4..3080c8df80e9 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -157,6 +157,9 @@ public function testConstructorDenormalizeWithMissingOptionalArgument() public function testConstructorDenormalizeWithOptionalDefaultArgument() { + if (PHP_VERSION_ID <= 50316) { + $this->markTestSkipped('See https://bugs.php.net/62715'); + } $obj = $this->normalizer->denormalize( array('bar' => 'test'), __NAMESPACE__.'\ObjectConstructorArgsWithDefaultValueDummy', 'any'); From cd167f49dd09a5eb39e2f2b888e7ee0008e8129a Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 31 Aug 2015 21:21:38 +0200 Subject: [PATCH 3/3] Mark deprecated Twig functions as deprecated with the Twig feature --- src/Symfony/Bridge/Twig/AppVariable.php | 2 +- src/Symfony/Bridge/Twig/Extension/AssetExtension.php | 2 +- src/Symfony/Bridge/Twig/Extension/FormExtension.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index bffa6a674d24..88d9835ce239 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -14,8 +14,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\SecurityContext; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php index f7b9c8750089..d90d13f6fd3d 100644 --- a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php @@ -42,7 +42,7 @@ public function getFunctions() return array( new \Twig_SimpleFunction('asset', array($this, 'getAssetUrl')), new \Twig_SimpleFunction('asset_version', array($this, 'getAssetVersion')), - new \Twig_SimpleFunction('assets_version', array($this, 'getAssetsVersion')), + new \Twig_SimpleFunction('assets_version', array($this, 'getAssetsVersion'), array('deprecated' => true, 'alternative' => 'asset_version')), ); } diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index 9c7339f70295..924d49d58186 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -61,7 +61,7 @@ public function getTokenParsers() public function getFunctions() { return array( - new \Twig_SimpleFunction('form_enctype', null, array('node_class' => 'Symfony\Bridge\Twig\Node\FormEnctypeNode', 'is_safe' => array('html'))), + new \Twig_SimpleFunction('form_enctype', null, array('node_class' => 'Symfony\Bridge\Twig\Node\FormEnctypeNode', 'is_safe' => array('html'), 'deprecated' => true, 'alternative' => 'form_start')), new \Twig_SimpleFunction('form_widget', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new \Twig_SimpleFunction('form_errors', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new \Twig_SimpleFunction('form_label', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),