Commit a2a1c6af authored by alexpott's avatar alexpott

Issue #2454393 by hussainweb: Upgrade to Symfony 2.6.5

parent d2304f84
This diff is collapsed.
This diff is collapsed.
...@@ -19,5 +19,5 @@ provided by the HttpKernel component. ...@@ -19,5 +19,5 @@ provided by the HttpKernel component.
You can run the unit tests with the following command: You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/BrowserKit/ $ cd path/to/Symfony/Component/BrowserKit/
$ composer.phar install $ composer install
$ phpunit $ phpunit
...@@ -123,8 +123,9 @@ public function getHeaders() ...@@ -123,8 +123,9 @@ public function getHeaders()
*/ */
public function getHeader($header, $first = true) public function getHeader($header, $first = true)
{ {
$normalizedHeader = str_replace('-', '_', strtolower($header));
foreach ($this->headers as $key => $value) { foreach ($this->headers as $key => $value) {
if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header))) { if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
if ($first) { if ($first) {
return is_array($value) ? (count($value) ? $value[0] : '') : $value; return is_array($value) ? (count($value) ? $value[0] : '') : $value;
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"symfony/dom-crawler": "~2.0,>=2.0.5" "symfony/dom-crawler": "~2.0,>=2.0.5"
}, },
"require-dev": { "require-dev": {
"symfony/phpunit-bridge": "~2.7",
"symfony/process": "~2.0,>=2.0.5", "symfony/process": "~2.0,>=2.0.5",
"symfony/css-selector": "~2.0,>=2.0.5" "symfony/css-selector": "~2.0,>=2.0.5"
}, },
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
> >
<php> <php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) --> <ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-16385"/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Symfony BrowserKit Component Test Suite"> <testsuite name="Symfony BrowserKit Component Test Suite">
......
...@@ -81,5 +81,5 @@ Resources ...@@ -81,5 +81,5 @@ Resources
You can run the unit tests with the following command: You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/ClassLoader/ $ cd path/to/Symfony/Component/ClassLoader/
$ composer.phar install $ composer install
$ phpunit $ phpunit
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
use Symfony\Component\ClassLoader\ApcUniversalClassLoader; use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
/**
* @group legacy
*/
class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{ {
protected function setUp() protected function setUp()
......
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
use Symfony\Component\ClassLoader\UniversalClassLoader; use Symfony\Component\ClassLoader\UniversalClassLoader;
/**
* @group legacy
*/
class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{ {
public function setUp() protected function setUp()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"php": ">=5.3.3" "php": ">=5.3.3"
}, },
"require-dev": { "require-dev": {
"symfony/phpunit-bridge": "~2.7",
"symfony/finder": "~2.0,>=2.0.5" "symfony/finder": "~2.0,>=2.0.5"
}, },
"autoload": { "autoload": {
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
> >
<php> <php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) --> <ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-16385"/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Symfony ClassLoader Component Test Suite"> <testsuite name="Symfony ClassLoader Component Test Suite">
......
...@@ -43,5 +43,5 @@ which is distributed under the BSD license. ...@@ -43,5 +43,5 @@ which is distributed under the BSD license.
You can run the unit tests with the following command: You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/CssSelector/ $ cd path/to/Symfony/Component/CssSelector/
$ composer.phar install $ composer install
$ phpunit $ phpunit
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.3"
}, },
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"autoload": { "autoload": {
"psr-0": { "Symfony\\Component\\CssSelector\\": "" } "psr-0": { "Symfony\\Component\\CssSelector\\": "" }
}, },
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
> >
<php> <php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) --> <ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-16385"/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Symfony CssSelector Component Test Suite"> <testsuite name="Symfony CssSelector Component Test Suite">
......
...@@ -30,27 +30,37 @@ ...@@ -30,27 +30,37 @@
class ExceptionHandler class ExceptionHandler
{ {
private $debug; private $debug;
private $charset;
private $handler; private $handler;
private $caughtBuffer; private $caughtBuffer;
private $caughtLength; private $caughtLength;
private $fileLinkFormat; private $fileLinkFormat;
public function __construct($debug = true, $fileLinkFormat = null) public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
{ {
if (false !== strpos($charset, '%') xor false === strpos($fileLinkFormat, '%')) {
// Swap $charset and $fileLinkFormat for BC reasons
$pivot = $fileLinkFormat;
$fileLinkFormat = $charset;
$charset = $pivot;
}
$this->debug = $debug; $this->debug = $debug;
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
} }
/** /**
* Registers the exception handler. * Registers the exception handler.
* *
* @param bool $debug * @param bool $debug Enable/disable debug mode, where the stack trace is displayed
* @param string|null $charset The charset used by exception messages
* @param string|null $fileLinkFormat The IDE link template
* *
* @return ExceptionHandler The registered exception handler * @return ExceptionHandler The registered exception handler
*/ */
public static function register($debug = true, $fileLinkFormat = null) public static function register($debug = true, $charset = null, $fileLinkFormat = null)
{ {
$handler = new static($debug, $fileLinkFormat); $handler = new static($debug, $charset, $fileLinkFormat);
$prev = set_exception_handler(array($handler, 'handle')); $prev = set_exception_handler(array($handler, 'handle'));
if (is_array($prev) && $prev[0] instanceof ErrorHandler) { if (is_array($prev) && $prev[0] instanceof ErrorHandler) {
...@@ -177,6 +187,7 @@ public function sendPhpResponse($exception) ...@@ -177,6 +187,7 @@ public function sendPhpResponse($exception)
foreach ($exception->getHeaders() as $name => $value) { foreach ($exception->getHeaders() as $name => $value) {
header($name.': '.$value, false); header($name.': '.$value, false);
} }
header('Content-Type: text/html; charset='.$this->charset);
} }
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception)); echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
...@@ -195,7 +206,7 @@ public function createResponse($exception) ...@@ -195,7 +206,7 @@ public function createResponse($exception)
$exception = FlattenException::create($exception); $exception = FlattenException::create($exception);
} }
return new Response($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders()); return Response::create($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
} }
/** /**
...@@ -223,7 +234,7 @@ public function getContent(FlattenException $exception) ...@@ -223,7 +234,7 @@ public function getContent(FlattenException $exception)
foreach ($exception->toArray() as $position => $e) { foreach ($exception->toArray() as $position => $e) {
$ind = $count - $position + 1; $ind = $count - $position + 1;
$class = $this->formatClass($e['class']); $class = $this->formatClass($e['class']);
$message = nl2br(self::utf8Htmlize($e['message'])); $message = nl2br($this->escapeHtml($e['message']));
$content .= sprintf(<<<EOF $content .= sprintf(<<<EOF
<h2 class="block_exception clear_fix"> <h2 class="block_exception clear_fix">
<span class="exception_counter">%d/%d</span> <span class="exception_counter">%d/%d</span>
...@@ -251,7 +262,7 @@ public function getContent(FlattenException $exception) ...@@ -251,7 +262,7 @@ public function getContent(FlattenException $exception)
} catch (\Exception $e) { } catch (\Exception $e) {
// something nasty happened and we cannot throw an exception anymore // something nasty happened and we cannot throw an exception anymore
if ($this->debug) { if ($this->debug) {
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()); $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $this->escapeHtml($e->getMessage()));
} else { } else {
$title = 'Whoops, looks like something went wrong.'; $title = 'Whoops, looks like something went wrong.';
} }
...@@ -337,7 +348,7 @@ private function decorate($content, $css) ...@@ -337,7 +348,7 @@ private function decorate($content, $css)
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8" /> <meta charset="{$this->charset}" />
<meta name="robots" content="noindex,nofollow" /> <meta name="robots" content="noindex,nofollow" />
<style> <style>
/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */ /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
...@@ -365,7 +376,7 @@ private function formatClass($class) ...@@ -365,7 +376,7 @@ private function formatClass($class)
private function formatPath($path, $line) private function formatPath($path, $line)
{ {
$path = self::utf8Htmlize($path); $path = $this->escapeHtml($path);
$file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path; $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
if ($linkFormat = $this->fileLinkFormat) { if ($linkFormat = $this->fileLinkFormat) {
...@@ -393,7 +404,7 @@ private function formatArgs(array $args) ...@@ -393,7 +404,7 @@ private function formatArgs(array $args)
} elseif ('array' === $item[0]) { } elseif ('array' === $item[0]) {
$formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); $formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) { } elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", self::utf8Htmlize($item[1])); $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
} elseif ('null' === $item[0]) { } elseif ('null' === $item[0]) {
$formattedValue = '<em>null</em>'; $formattedValue = '<em>null</em>';
} elseif ('boolean' === $item[0]) { } elseif ('boolean' === $item[0]) {
...@@ -401,7 +412,7 @@ private function formatArgs(array $args) ...@@ -401,7 +412,7 @@ private function formatArgs(array $args)
} elseif ('resource' === $item[0]) { } elseif ('resource' === $item[0]) {
$formattedValue = '<em>resource</em>'; $formattedValue = '<em>resource</em>';
} else { } else {
$formattedValue = str_replace("\n", '', var_export(self::utf8Htmlize((string) $item[1]), true)); $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
} }
$result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
...@@ -429,6 +440,14 @@ protected static function utf8Htmlize($str) ...@@ -429,6 +440,14 @@ protected static function utf8Htmlize($str)
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8'); return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
} }
/**
* HTML-encodes a string
*/
private function escapeHtml($str)
{
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
}
/** /**
* @internal * @internal
*/ */
......
...@@ -39,5 +39,5 @@ Resources ...@@ -39,5 +39,5 @@ Resources
You can run the unit tests with the following command: You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Debug/ $ cd path/to/Symfony/Component/Debug/
$ composer.phar install --dev $ composer install
$ phpunit $ phpunit
...@@ -359,6 +359,9 @@ public function testHandleFatalError() ...@@ -359,6 +359,9 @@ public function testHandleFatalError()
} }
} }
/**
* @group legacy
*/
public function testLegacyInterface() public function testLegacyInterface()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
......
...@@ -36,6 +36,7 @@ public function testHandleClassNotFound($error, $translatedMessage) ...@@ -36,6 +36,7 @@ public function testHandleClassNotFound($error, $translatedMessage)
/** /**
* @dataProvider provideLegacyClassNotFoundData * @dataProvider provideLegacyClassNotFoundData
* @group legacy
*/ */
public function testLegacyHandleClassNotFound($error, $translatedMessage, $autoloader) public function testLegacyHandleClassNotFound($error, $translatedMessage, $autoloader)
{ {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
}, },
"require-dev": { "require-dev": {
"symfony/phpunit-bridge": "~2.7",
"symfony/class-loader": "~2.2", "symfony/class-loader": "~2.2",
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2", "symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2",
"symfony/http-foundation": "~2.1" "symfony/http-foundation": "~2.1"
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
> >
<php> <php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) --> <ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-16385"/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Symfony Debug Component Test Suite"> <testsuite name="Symfony Debug Component Test Suite">
......
...@@ -65,9 +65,6 @@ public function process(ContainerBuilder $container) ...@@ -65,9 +65,6 @@ public function process(ContainerBuilder $container)
$configurator = $this->inlineArguments($container, array($definition->getConfigurator())); $configurator = $this->inlineArguments($container, array($definition->getConfigurator()));
$definition->setConfigurator($configurator[0]); $definition->setConfigurator($configurator[0]);
$factory = $this->inlineArguments($container, array($definition->getFactory()));
$definition->setFactory($factory[0]);
} }
} }
......
...@@ -37,6 +37,14 @@ public function process(ContainerBuilder $container) ...@@ -37,6 +37,14 @@ public function process(ContainerBuilder $container)
$definition->setClass($parameterBag->resolveValue($definition->getClass())); $definition->setClass($parameterBag->resolveValue($definition->getClass()));
$definition->setFile($parameterBag->resolveValue($definition->getFile())); $definition->setFile($parameterBag->resolveValue($definition->getFile()));
$definition->setArguments($parameterBag->resolveValue($definition->getArguments())); $definition->setArguments($parameterBag->resolveValue($definition->getArguments()));
$definition->setFactoryClass($parameterBag->resolveValue($definition->getFactoryClass()));
$factory = $definition->getFactory();
if (is_array($factory) && isset($factory[0])) {
$factory[0] = $parameterBag->resolveValue($factory[0]);
$definition->setFactory($factory);
}
$calls = array(); $calls = array();
foreach ($definition->getMethodCalls() as $name => $arguments) { foreach ($definition->getMethodCalls() as $name => $arguments) {
......
...@@ -1004,9 +1004,7 @@ public function createService(Definition $definition, $id, $tryProxy = true) ...@@ -1004,9 +1004,7 @@ public function createService(Definition $definition, $id, $tryProxy = true)
public function resolveServices($value) public function resolveServices($value)
{ {
if (is_array($value)) { if (is_array($value)) {
foreach ($value as &$v) { $value = array_map(array($this, 'resolveServices'), $value);
$v = $this->resolveServices($v);
}
} elseif ($value instanceof Reference) { } elseif ($value instanceof Reference) {
$value = $this->get((string) $value, $value->getInvalidBehavior()); $value = $this->get((string