Merge branch '2.7'
* 2.7: Changed visibility of setUp() and tearDown to protected Changed visibility of setUp() and tearDown to protected [2.7] Fix travis file [HttpFoundation] MongoDbSessionHandler::read() now checks for valid session age [Debug] reintroduce charset param to ExceptionHandler Changed visibility of setUp() and tearDown to protected [WebProfilerBundle] Set debug+charset on the ExceptionHandler fallback [Debug] deprecate ExceptionHandler::utf8Htmlize Added default button class used HTML5 meta charset tag and removed hardcoded ones Revert "bug #13715 Enforce UTF-8 charset for core controllers (WouterJ)" fixed XSS in the exception handler Php Inspections (EA Extended) - static code analysis includes: [2.3] Remove most refs uses [FrameworkBundle] Read config/validation/*.(xml|yml) files Test with local components instead of waiting for the subtree-splitter when possible Conflicts: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyTemplatingAssetHelperPassTest.php src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php src/Symfony/Component/ClassLoader/Tests/LegacyUniversalClassLoaderTest.php src/Symfony/Component/Console/Helper/ProgressHelper.php src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php src/Symfony/Component/Debug/ExceptionHandler.php src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php src/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php src/Symfony/Component/Templating/Tests/Helper/LegacyAssetsHelperTest.php
This commit is contained in:
commit
21450da1f0
|
@ -2,4 +2,6 @@ phpunit.xml
|
|||
composer.lock
|
||||
composer.phar
|
||||
autoload.php
|
||||
package*.tar
|
||||
packages.json
|
||||
/vendor/
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
branch=$1
|
||||
if [ -z "$branch" ]; then
|
||||
echo 'Usage: branch dir1 dir2 ... dirN'
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
components=$*
|
||||
if [ -z "$components" ]; then
|
||||
echo 'Usage: branch dir1 dir2 ... dirN'
|
||||
exit 1
|
||||
fi
|
||||
echo '{"packages": {' > packages.json
|
||||
components=$(
|
||||
for c in $components; do
|
||||
sed -i ':a;N;$!ba;s#^{\n\(\s*\)\("name"\)#{\n\1"repositories": \[{ "type": "composer", "url": "file://'$(pwd)'/" }\],\n\1\2#' $c/composer.json
|
||||
n=$(php -r '$n=json_decode(file_get_contents("'$c'/composer.json"));echo $n->name;')
|
||||
echo '"'$n'": {"'$branch'.x-dev": ' >> packages.json
|
||||
cat $c/composer.json >> packages.json
|
||||
echo '"version": "'$branch.x-dev'",\n "dist": {"type": "tar", "url": "file://'$(pwd)/$c'/package'$branch'.tar"}\n}},' >> packages.json
|
||||
echo $c
|
||||
done;
|
||||
)
|
||||
sed -i ':a;N;$!ba;s/\n}\n"/,\n "/g' packages.json
|
||||
sed -i ':a;N;$!ba;s/}},$/\n}}\n}}/' packages.json
|
||||
echo "$components" | parallel --gnu "cd {}; tar -cf package$branch.tar --exclude='package*.tar' *"
|
|
@ -37,11 +37,12 @@ before_install:
|
|||
- if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi;
|
||||
|
||||
install:
|
||||
- if [ "$deps" = "no" ]; then export SYMFONY_DEPRECATIONS_HELPER=strict; fi;
|
||||
- if [ "$deps" = "no" ]; then composer --prefer-source install; fi;
|
||||
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
|
||||
- if [ "$deps" != "no" ]; then sh .travis.sh $TRAVIS_BRANCH $components; fi;
|
||||
|
||||
script:
|
||||
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
|
||||
- if [ "$deps" = "no" ]; then export SYMFONY_DEPRECATIONS_HELPER=strict; fi;
|
||||
- if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
|
||||
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; phpunit --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
|
||||
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
|
||||
|
|
|
@ -117,8 +117,10 @@ class DoctrineDataCollector extends DataCollector
|
|||
private function sanitizeQuery($connectionName, $query)
|
||||
{
|
||||
$query['explainable'] = true;
|
||||
$query['params'] = (array) $query['params'];
|
||||
foreach ($query['params'] as $j => &$param) {
|
||||
if (!is_array($query['params'])) {
|
||||
$query['params'] = array($query['params']);
|
||||
}
|
||||
foreach ($query['params'] as $j => $param) {
|
||||
if (isset($query['types'][$j])) {
|
||||
// Transform the param according to the type
|
||||
$type = $query['types'][$j];
|
||||
|
@ -131,7 +133,7 @@ class DoctrineDataCollector extends DataCollector
|
|||
}
|
||||
}
|
||||
|
||||
list($param, $explainable) = $this->sanitizeParam($param);
|
||||
list($query['params'][$j], $explainable) = $this->sanitizeParam($param);
|
||||
if (!$explainable) {
|
||||
$query['explainable'] = false;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class RuntimeInstantiatorTest extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->instantiator = new RuntimeInstantiator();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->dumper = new ProxyDumper();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{%- endblock textarea_widget %}
|
||||
|
||||
{% block button_widget -%}
|
||||
{% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %}
|
||||
{% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %}
|
||||
{{- parent() -}}
|
||||
{%- endblock %}
|
||||
|
||||
|
|
|
@ -98,12 +98,12 @@ class LintCommandTest extends \PHPUnit_Framework_TestCase
|
|||
return $filename;
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->files = array();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if (file_exists($file)) {
|
||||
|
|
|
@ -84,7 +84,7 @@ class TwigExtractor implements ExtractorInterface
|
|||
$this->twig->parse($this->twig->tokenize($template));
|
||||
|
||||
foreach ($visitor->getMessages() as $message) {
|
||||
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ? $message[1] : $this->defaultDomain);
|
||||
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
|
||||
}
|
||||
|
||||
$visitor->disable();
|
||||
|
|
|
@ -792,6 +792,17 @@ class FrameworkExtension extends Extension
|
|||
$files[1][] = realpath($file);
|
||||
$container->addResource(new FileResource($file));
|
||||
}
|
||||
|
||||
if (is_dir($dir = $dirname.'/Resources/config/validation')) {
|
||||
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
|
||||
$files[0][] = $file->getRealpath();
|
||||
}
|
||||
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
|
||||
$files[1][] = $file->getRealpath();
|
||||
}
|
||||
|
||||
$container->addResource(new DirectoryResource($dir));
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
|
|
|
@ -29,7 +29,7 @@ class ControllerNameParserTest extends TestCase
|
|||
$this->loader->register();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
spl_autoload_unregister(array($this->loader, 'loadClass'));
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRenderer
|
|||
|
||||
class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class GlobalVariablesTest extends TestCase
|
|||
private $container;
|
||||
private $globals;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->container = new Container();
|
||||
$this->globals = new GlobalVariables($this->container);
|
||||
|
|
|
@ -26,7 +26,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
|||
$this->deleteTmpDir();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->deleteTmpDir();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta charset="{{ _charset }}" />
|
||||
<title>{% block title %}Welcome!{% endblock %}</title>
|
||||
{% block stylesheets %}{% endblock %}
|
||||
</head>
|
||||
|
|
|
@ -62,7 +62,7 @@ class ExceptionController
|
|||
|
||||
$code = $exception->getStatusCode();
|
||||
|
||||
return Response::create($this->twig->render(
|
||||
return new Response($this->twig->render(
|
||||
$this->findTemplate($request, $request->getRequestFormat(), $code, $showException),
|
||||
array(
|
||||
'status_code' => $code,
|
||||
|
@ -71,7 +71,7 @@ class ExceptionController
|
|||
'logger' => $logger,
|
||||
'currentContent' => $currentContent,
|
||||
)
|
||||
))->setCharset('UTF-8');
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,13 +36,13 @@ class TwigExtension extends Extension
|
|||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('twig.xml');
|
||||
|
||||
foreach ($configs as &$config) {
|
||||
foreach ($configs as $key => $config) {
|
||||
if (isset($config['globals'])) {
|
||||
foreach ($config['globals'] as $name => $value) {
|
||||
if (is_array($value) && isset($value['key'])) {
|
||||
$config['globals'][$name] = array(
|
||||
$configs[$key]['globals'][$name] = array(
|
||||
'key' => $name,
|
||||
'value' => $config['globals'][$name],
|
||||
'value' => $value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta charset="{{ _charset }}" />
|
||||
<title>An Error Occurred: {{ status_text }}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -40,8 +40,7 @@ class ExceptionControllerTest extends TestCase
|
|||
$request->headers->set('X-Php-Ob-Level', 1);
|
||||
|
||||
$controller = new ExceptionController($twig, false);
|
||||
$response = $controller->showAction($request, $flatten);
|
||||
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
|
||||
$controller->showAction($request, $flatten);
|
||||
}
|
||||
|
||||
public function testShowActionCanBeForcedToShowErrorPage()
|
||||
|
|
|
@ -29,7 +29,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
private $pass;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->builder = $this->getMock(
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
|
|
|
@ -55,24 +55,23 @@ class ExceptionController
|
|||
$template = $this->getTemplate();
|
||||
|
||||
if (!$this->twig->getLoader()->exists($template)) {
|
||||
$handler = new ExceptionHandler();
|
||||
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
|
||||
|
||||
return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
|
||||
$code = $exception->getStatusCode();
|
||||
|
||||
return Response::create(
|
||||
$this->twig->render($template, array(
|
||||
return new Response($this->twig->render(
|
||||
$template,
|
||||
array(
|
||||
'status_code' => $code,
|
||||
'status_text' => Response::$statusTexts[$code],
|
||||
'exception' => $exception,
|
||||
'logger' => null,
|
||||
'currentContent' => '',
|
||||
)),
|
||||
200,
|
||||
array('Content-Type' => 'text/html')
|
||||
)->setCharset('UTF-8');
|
||||
)
|
||||
), 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,16 +95,12 @@ class ExceptionController
|
|||
$template = $this->getTemplate();
|
||||
|
||||
if (!$this->templateExists($template)) {
|
||||
$handler = new ExceptionHandler();
|
||||
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
|
||||
|
||||
$response = new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
|
||||
} else {
|
||||
$response = new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
|
||||
return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
|
||||
}
|
||||
|
||||
$response->setCharset('UTF-8');
|
||||
|
||||
return $response;
|
||||
return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
|
||||
}
|
||||
|
||||
protected function getTemplate()
|
||||
|
|
|
@ -99,20 +99,16 @@ class ProfilerController
|
|||
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
|
||||
}
|
||||
|
||||
return Response::create(
|
||||
$this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
|
||||
'token' => $token,
|
||||
'profile' => $profile,
|
||||
'collector' => $profile->getCollector($panel),
|
||||
'panel' => $panel,
|
||||
'page' => $page,
|
||||
'request' => $request,
|
||||
'templates' => $this->getTemplateManager()->getTemplates($profile),
|
||||
'is_ajax' => $request->isXmlHttpRequest(),
|
||||
)),
|
||||
200,
|
||||
array('Content-Type' => 'text/html')
|
||||
)->setCharset('UTF-8');
|
||||
return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
|
||||
'token' => $token,
|
||||
'profile' => $profile,
|
||||
'collector' => $profile->getCollector($panel),
|
||||
'panel' => $panel,
|
||||
'page' => $page,
|
||||
'request' => $request,
|
||||
'templates' => $this->getTemplateManager()->getTemplates($profile),
|
||||
'is_ajax' => $request->isXmlHttpRequest(),
|
||||
)), 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,13 +147,9 @@ class ProfilerController
|
|||
|
||||
$this->profiler->disable();
|
||||
|
||||
return Response::create(
|
||||
$this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
|
||||
'about' => $about,
|
||||
)),
|
||||
200,
|
||||
array('Content-Type' => 'text/html')
|
||||
)->setCharset('UTF-8');
|
||||
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
|
||||
'about' => $about,
|
||||
)), 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,17 +197,13 @@ class ProfilerController
|
|||
// the profiler is not enabled
|
||||
}
|
||||
|
||||
return Response::create(
|
||||
$this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
|
||||
'position' => $position,
|
||||
'profile' => $profile,
|
||||
'templates' => $this->getTemplateManager()->getTemplates($profile),
|
||||
'profiler_url' => $url,
|
||||
'token' => $token,
|
||||
)),
|
||||
200,
|
||||
array('Content-Type' => 'text/html')
|
||||
)->setCharset('UTF-8');
|
||||
return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
|
||||
'position' => $position,
|
||||
'profile' => $profile,
|
||||
'templates' => $this->getTemplateManager()->getTemplates($profile),
|
||||
'profiler_url' => $url,
|
||||
'token' => $token,
|
||||
)), 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,7 +241,7 @@ class ProfilerController
|
|||
$token = $session->get('_profiler_search_token');
|
||||
}
|
||||
|
||||
return Response::create(
|
||||
return new Response(
|
||||
$this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
|
||||
'token' => $token,
|
||||
'ip' => $ip,
|
||||
|
@ -266,7 +254,7 @@ class ProfilerController
|
|||
)),
|
||||
200,
|
||||
array('Content-Type' => 'text/html')
|
||||
)->setCharset('UTF-8');
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,22 +284,18 @@ class ProfilerController
|
|||
$end = $request->query->get('end', null);
|
||||
$limit = $request->query->get('limit');
|
||||
|
||||
return Response::create(
|
||||
$this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
|
||||
'token' => $token,
|
||||
'profile' => $profile,
|
||||
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
|
||||
'ip' => $ip,
|
||||
'method' => $method,
|
||||
'url' => $url,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'limit' => $limit,
|
||||
'panel' => null,
|
||||
)),
|
||||
200,
|
||||
array('Content-Type' => 'text/html')
|
||||
)->setCharset('UTF-8');
|
||||
return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
|
||||
'token' => $token,
|
||||
'profile' => $profile,
|
||||
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
|
||||
'ip' => $ip,
|
||||
'method' => $method,
|
||||
'url' => $url,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'limit' => $limit,
|
||||
'panel' => null,
|
||||
)), 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -385,7 +369,7 @@ class ProfilerController
|
|||
phpinfo();
|
||||
$phpinfo = ob_get_clean();
|
||||
|
||||
return Response::create($phpinfo, 200, array('Content-Type' => 'text/html'))->setCharset('UTF-8');
|
||||
return new Response($phpinfo, 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,14 +68,10 @@ class RouterController
|
|||
|
||||
$request = $profile->getCollector('request');
|
||||
|
||||
return Response::create(
|
||||
$this->twig->render('@WebProfiler/Router/panel.html.twig', array(
|
||||
'request' => $request,
|
||||
'router' => $profile->getCollector('router'),
|
||||
'traces' => $matcher->getTraces($request->getPathInfo()),
|
||||
)),
|
||||
200,
|
||||
array('Content-Type' => 'text/html')
|
||||
)->setCharset('UTF-8');
|
||||
return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', array(
|
||||
'request' => $request,
|
||||
'router' => $profile->getCollector('router'),
|
||||
'traces' => $matcher->getTraces($request->getPathInfo()),
|
||||
)), 200, array('Content-Type' => 'text/html'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<meta charset="{{ _charset }}" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<title>{% block title 'Profiler' %}</title>
|
||||
<link rel="icon" type="image/x-icon" sizes="16x16" href="data:image/ico;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABMLAAATCwAAAAAAAAAAAAAAAAAAAAAAADIvMQAyLzEIMi8xSzEuMKoyLzHkMi8x/TIvMf0yLzHlMi8xrDIvMU4yLzEJMi8xAAAAAAAAAAAAAAAAADIvMQAyLzEYMS4wkTMwMu45Njj/MS4w/zEuMP8yLzH/Mi8x/zIvMf8yLzHvMi8xlDIvMRkyLzEAAAAAADIvMQAyLzEXMS4wrTk2OPyVk5T7kI6P/nl3ef8+Oz3/MS4w/zIvMf8yLzH/Mi8x/zIvMf4yLzGxMi8xGjIvMQAyLzEGMi8xkDEuMP4/PD79wcDA+oB+gP6Ni4z/paOk/zk2OP8xLjD/Mi8x/zIvMf8yLzH/Mi8x/zIvMZQyLzEIMi8xSTIvMewyLzH/MS4w/z06PP81MjT+TktN/93c3f97eXv/MC0v/zIvMf8yLzH/Mi8x/zIvMf8yLzHuMi8xTzIvMaUyLzH/Mi8x/0lHSf9kYmP/XFpb/zs4Ov/DwsL+ycjI/zs4Ov8xLjD/Mi8x/zIvMf8yLzH/Mi8x/zIvMawyLzHfMC0v/1tYWv+opqf/YV5g/8bFxf96eHn+m5qb/u7u7v9WVFX/MC0v/zIvMf8yLzH/Mi8x/zIvMf8yLzHkMi8x+jAtL/9iYGH/mZiZ/2dlZv/p6On/oJ+g/np4ev/6+vr/dXN1/y0qLP8xLjD/Mi8x/zIvMf8yLzH/Mi8x/DIvMfoyLzH/MzAy/0A+QP7JyMj85eXl/1tYWv9XVVf/8fDx/6qpqv9ZV1j/Q0BC/zIvMf8yLzH/Mi8x/zIvMfwyLzHeMi8x/zEuMP8/PD762dnZ9JWTlP81MjT/ZmRm/+Dg4P/DwsP/YV5g/6Wkpf9BPkD/MS4w/zIvMf8yLzHjMi8xozIvMf8yLzH/Mi8x/nZ0dv2amJn4dXN0+V5bXf+Pjo//0tLS/0hFR/9vbG7/Ozg6/zEuMP8yLzH/Mi8xqTIvMUcyLzHrMi8x/zIvMf8xLjD/Ozg6/Do3OfwwLS//REFD/728vP9nZWb/TktN/4mIif05Nzn/Mi8x7jMwMkwyLzEGMi8xjDIvMf4yLzH/Mi8x/zIvMf8yLzH/Mi8x/zAtL/9XVFb/goGC+Hx6e+6qqanwOzg6/DMwMpJDQEIIMi8xADIvMRUyLzGrMi8x/jIvMf8yLzH/Mi8x/zIvMf8yLzH/MS4w/zg2N/xBPkD3OTY4/DIvMa8yLzEYMi8xAAAAAAAyLzEAMi8xGDIvMY0yLzHqMi8x/zIvMf8yLzH/Mi8x/zIvMf8yLzH/MS4w7DEuMJEyLzEaMi8xAAAAAAAAAAAAAAAAADIvMQAyLzEGMi8xQzIvMZ4yLzHdMi8x+jIvMfoyLzHeMi8xoDIvMUUyLzEGMi8xAAAAAAAAAAAA4AcAAMADAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAADAAwAA4AcAAA==">
|
||||
<style>
|
||||
|
|
|
@ -69,7 +69,6 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found');
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
|
||||
|
||||
$response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound');
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
|
|
|
@ -41,7 +41,7 @@ class TemplateManagerTest extends TestCase
|
|||
*/
|
||||
protected $templateManager;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
private $metaFile = null;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->resourceFile = tempnam(sys_get_temp_dir(), '_resource');
|
||||
$this->cacheFile = tempnam(sys_get_temp_dir(), 'config_');
|
||||
|
@ -32,7 +32,7 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase
|
|||
$this->generateMetaFile();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$files = array($this->cacheFile, $this->metaFile, $this->resourceFile);
|
||||
|
||||
|
|
|
@ -191,14 +191,14 @@ class XmlUtils
|
|||
return;
|
||||
case ctype_digit($value):
|
||||
$raw = $value;
|
||||
$cast = intval($value);
|
||||
$cast = (int) $value;
|
||||
|
||||
return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
|
||||
$raw = $value;
|
||||
$cast = intval($value);
|
||||
|
||||
return '0' == $value[1] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||
case 'true' === $lowercaseValue:
|
||||
return true;
|
||||
case 'false' === $lowercaseValue:
|
||||
|
@ -206,9 +206,9 @@ class XmlUtils
|
|||
case isset($value[1]) && '0b' == $value[0].$value[1]:
|
||||
return bindec($value);
|
||||
case is_numeric($value):
|
||||
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
|
||||
return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
|
||||
case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value):
|
||||
return floatval($value);
|
||||
return (float) $value;
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,9 @@ class FormatterHelper extends Helper
|
|||
*/
|
||||
public function formatBlock($messages, $style, $large = false)
|
||||
{
|
||||
$messages = (array) $messages;
|
||||
if (!is_array($messages)) {
|
||||
$messages = array($messages);
|
||||
}
|
||||
|
||||
$len = 0;
|
||||
$lines = array();
|
||||
|
@ -56,15 +58,15 @@ class FormatterHelper extends Helper
|
|||
}
|
||||
|
||||
$messages = $large ? array(str_repeat(' ', $len)) : array();
|
||||
foreach ($lines as $line) {
|
||||
$messages[] = $line.str_repeat(' ', $len - $this->strlen($line));
|
||||
for ($i = 0; isset($lines[$i]); ++$i) {
|
||||
$messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
|
||||
}
|
||||
if ($large) {
|
||||
$messages[] = str_repeat(' ', $len);
|
||||
}
|
||||
|
||||
foreach ($messages as &$message) {
|
||||
$message = sprintf('<%s>%s</%s>', $style, $message, $style);
|
||||
for ($i = 0; isset($messages[$i]); ++$i) {
|
||||
$messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
|
||||
}
|
||||
|
||||
return implode("\n", $messages);
|
||||
|
|
|
@ -30,27 +30,37 @@ use Symfony\Component\Debug\Exception\OutOfMemoryException;
|
|||
class ExceptionHandler
|
||||
{
|
||||
private $debug;
|
||||
private $charset;
|
||||
private $handler;
|
||||
private $caughtBuffer;
|
||||
private $caughtLength;
|
||||
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->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
|
||||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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'));
|
||||
if (is_array($prev) && $prev[0] instanceof ErrorHandler) {
|
||||
|
@ -194,6 +204,7 @@ class ExceptionHandler
|
|||
foreach ($exception->getHeaders() as $name => $value) {
|
||||
header($name.': '.$value, false);
|
||||
}
|
||||
header('Content-Type: text/html; charset='.$this->charset);
|
||||
}
|
||||
|
||||
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
|
||||
|
@ -212,7 +223,7 @@ class ExceptionHandler
|
|||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,7 +251,7 @@ class ExceptionHandler
|
|||
foreach ($exception->toArray() as $position => $e) {
|
||||
$ind = $count - $position + 1;
|
||||
$class = $this->formatClass($e['class']);
|
||||
$message = nl2br(self::utf8Htmlize($e['message']));
|
||||
$message = nl2br($this->escapeHtml($e['message']));
|
||||
$content .= sprintf(<<<EOF
|
||||
<h2 class="block_exception clear_fix">
|
||||
<span class="exception_counter">%d/%d</span>
|
||||
|
@ -268,7 +279,7 @@ EOF
|
|||
} catch (\Exception $e) {
|
||||
// something nasty happened and we cannot throw an exception anymore
|
||||
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 {
|
||||
$title = 'Whoops, looks like something went wrong.';
|
||||
}
|
||||
|
@ -354,7 +365,7 @@ EOF;
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta charset="{$this->charset}" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<style>
|
||||
/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
|
||||
|
@ -382,7 +393,7 @@ EOF;
|
|||
|
||||
private function formatPath($path, $line)
|
||||
{
|
||||
$path = self::utf8Htmlize($path);
|
||||
$path = $this->escapeHtml($path);
|
||||
$file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
|
||||
|
||||
if ($linkFormat = $this->fileLinkFormat) {
|
||||
|
@ -410,7 +421,7 @@ EOF;
|
|||
} elseif ('array' === $item[0]) {
|
||||
$formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
|
||||
} elseif ('string' === $item[0]) {
|
||||
$formattedValue = sprintf("'%s'", self::utf8Htmlize($item[1]));
|
||||
$formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
|
||||
} elseif ('null' === $item[0]) {
|
||||
$formattedValue = '<em>null</em>';
|
||||
} elseif ('boolean' === $item[0]) {
|
||||
|
@ -418,7 +429,7 @@ EOF;
|
|||
} elseif ('resource' === $item[0]) {
|
||||
$formattedValue = '<em>resource</em>';
|
||||
} 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);
|
||||
|
@ -428,21 +439,10 @@ EOF;
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an UTF-8 and HTML encoded string
|
||||
* HTML-encodes a string
|
||||
*/
|
||||
protected static function utf8Htmlize($str)
|
||||
private function escapeHtml($str)
|
||||
{
|
||||
if (!preg_match('//u', $str) && function_exists('iconv')) {
|
||||
set_error_handler('var_dump', 0);
|
||||
$charset = ini_get('default_charset');
|
||||
if ('UTF-8' === $charset || $str !== @iconv($charset, $charset, $str)) {
|
||||
$charset = 'CP1252';
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
$str = iconv($charset, 'UTF-8', $str);
|
||||
}
|
||||
|
||||
return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1000,9 +1000,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
public function resolveServices($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
foreach ($value as &$v) {
|
||||
$v = $this->resolveServices($v);
|
||||
}
|
||||
$value = array_map(array($this, 'resolveServices'), $value);
|
||||
} elseif ($value instanceof Reference) {
|
||||
$value = $this->get((string) $value, $value->getInvalidBehavior());
|
||||
} elseif ($value instanceof Definition) {
|
||||
|
|
|
@ -1482,13 +1482,13 @@ EOF;
|
|||
|
||||
if ('' === $name) {
|
||||
$name .= $firstChars[$i%$firstCharsLength];
|
||||
$i = intval($i/$firstCharsLength);
|
||||
$i = (int) ($i/$firstCharsLength);
|
||||
}
|
||||
|
||||
while ($i > 0) {
|
||||
--$i;
|
||||
$name .= $nonFirstChars[$i%$nonFirstCharsLength];
|
||||
$i = intval($i/$nonFirstCharsLength);
|
||||
$i = (int) ($i/$nonFirstCharsLength);
|
||||
}
|
||||
|
||||
++$this->variableCount;
|
||||
|
|
|
@ -16,7 +16,7 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||
|
||||
class LegacyContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\Definition;
|
|||
|
||||
class LegacyDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class Link
|
|||
}
|
||||
|
||||
if ('.' === substr($path, -1)) {
|
||||
$path = $path.'/';
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
$output = array();
|
||||
|
|
|
@ -23,7 +23,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||
*/
|
||||
private $filesystem = null;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->filesystem = new Filesystem();
|
||||
|
|
|
@ -37,7 +37,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->umask = umask(0);
|
||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
|
||||
|
@ -45,7 +45,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||
$this->workspace = realpath($this->workspace);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->clean($this->workspace);
|
||||
umask($this->umask);
|
||||
|
|
|
@ -436,9 +436,9 @@ class Finder implements \IteratorAggregate, \Countable
|
|||
public function ignoreDotFiles($ignoreDotFiles)
|
||||
{
|
||||
if ($ignoreDotFiles) {
|
||||
$this->ignore = $this->ignore | static::IGNORE_DOT_FILES;
|
||||
$this->ignore |= static::IGNORE_DOT_FILES;
|
||||
} else {
|
||||
$this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;
|
||||
$this->ignore &= ~static::IGNORE_DOT_FILES;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -458,9 +458,9 @@ class Finder implements \IteratorAggregate, \Countable
|
|||
public function ignoreVCS($ignoreVCS)
|
||||
{
|
||||
if ($ignoreVCS) {
|
||||
$this->ignore = $this->ignore | static::IGNORE_VCS_FILES;
|
||||
$this->ignore |= static::IGNORE_VCS_FILES;
|
||||
} else {
|
||||
$this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES;
|
||||
$this->ignore &= ~static::IGNORE_VCS_FILES;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -134,7 +134,7 @@ class ChoiceType extends AbstractType
|
|||
// Add "[]" to the name in case a select tag with multiple options is
|
||||
// displayed. Otherwise only one of the selected options is sent in the
|
||||
// POST request.
|
||||
$view->vars['full_name'] = $view->vars['full_name'].'[]';
|
||||
$view->vars['full_name'] .= '[]';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class DataCollectorExtensionTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
private $dataCollector;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface');
|
||||
$this->extension = new DataCollectorExtension($this->dataCollector);
|
||||
|
|
|
@ -24,7 +24,7 @@ class DataCollectorTypeExtensionTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
private $dataCollector;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface');
|
||||
$this->extension = new DataCollectorTypeExtension($this->dataCollector);
|
||||
|
|
|
@ -44,7 +44,7 @@ class ServerParams
|
|||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
} else {
|
||||
$max = intval($max);
|
||||
$max = (int) $max;
|
||||
}
|
||||
|
||||
switch (substr($iniMax, -1)) {
|
||||
|
|
|
@ -270,7 +270,7 @@ class UploadedFile extends File
|
|||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
} else {
|
||||
$max = intval($max);
|
||||
$max = (int) $max;
|
||||
}
|
||||
|
||||
switch (substr($iniMax, -1)) {
|
||||
|
|
|
@ -1018,7 +1018,7 @@ class Request
|
|||
}
|
||||
|
||||
if (false !== $pos) {
|
||||
return intval(substr($host, $pos + 1));
|
||||
return (int) substr($host, $pos + 1);
|
||||
}
|
||||
|
||||
return 'https' === $this->getScheme() ? 443 : 80;
|
||||
|
|
|
@ -1267,7 +1267,7 @@ class Response
|
|||
protected function ensureIEOverSSLCompatibility(Request $request)
|
||||
{
|
||||
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
|
||||
if (intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) {
|
||||
if ((int) preg_replace("/(MSIE )(.*?);/", "$2", $match[0]) < 9) {
|
||||
$this->headers->remove('Cache-Control');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,24 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
* * id_field: The field name for storing the session id [default: _id]
|
||||
* * data_field: The field name for storing the session data [default: data]
|
||||
* * time_field: The field name for storing the timestamp [default: time]
|
||||
* * expiry_field: The field name for storing the expiry-timestamp [default: expires_at]
|
||||
*
|
||||
* It is strongly recommended to put an index on the `expiry_field` for
|
||||
* garbage-collection. Alternatively it's possible to automatically expire
|
||||
* the sessions in the database as described below:
|
||||
*
|
||||
* A TTL collections can be used on MongoDB 2.2+ to cleanup expired sessions
|
||||
* automatically. Such an index can for example look like this:
|
||||
*
|
||||
* db.<session-collection>.ensureIndex(
|
||||
* { "<expiry-field>": 1 },
|
||||
* { "expireAfterSeconds": 0 }
|
||||
* )
|
||||
*
|
||||
* More details on: http://docs.mongodb.org/manual/tutorial/expire-data/
|
||||
*
|
||||
* If you use such an index, you can drop `gc_probability` to 0 since
|
||||
* no garbage-collection is required.
|
||||
*
|
||||
* @param \Mongo|\MongoClient $mongo A MongoClient or Mongo instance
|
||||
* @param array $options An associative array of field options
|
||||
|
@ -65,7 +83,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
'id_field' => '_id',
|
||||
'data_field' => 'data',
|
||||
'time_field' => 'time',
|
||||
'expiry_field' => false,
|
||||
'expiry_field' => 'expires_at',
|
||||
), $options);
|
||||
}
|
||||
|
||||
|
@ -102,21 +120,8 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
*/
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
/* Note: MongoDB 2.2+ supports TTL collections, which may be used in
|
||||
* place of this method by indexing the "time_field" field with an
|
||||
* "expireAfterSeconds" option. Regardless of whether TTL collections
|
||||
* are used, consider indexing this field to make the remove query more
|
||||
* efficient.
|
||||
*
|
||||
* See: http://docs.mongodb.org/manual/tutorial/expire-data/
|
||||
*/
|
||||
if (false !== $this->options['expiry_field']) {
|
||||
return true;
|
||||
}
|
||||
$time = new \MongoDate(time() - $maxlifetime);
|
||||
|
||||
$this->getCollection()->remove(array(
|
||||
$this->options['time_field'] => array('$lt' => $time),
|
||||
$this->options['expiry_field'] => array('$lt' => new \MongoDate()),
|
||||
));
|
||||
|
||||
return true;
|
||||
|
@ -127,24 +132,14 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
*/
|
||||
public function write($sessionId, $data)
|
||||
{
|
||||
$expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime'));
|
||||
|
||||
$fields = array(
|
||||
$this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY),
|
||||
$this->options['time_field'] => new \MongoDate(),
|
||||
$this->options['expiry_field'] => $expiry,
|
||||
);
|
||||
|
||||
/* Note: As discussed in the gc method of this class. You can utilise
|
||||
* TTL collections in MongoDB 2.2+
|
||||
* We are setting the "expiry_field" as part of the write operation here
|
||||
* You will need to create the index on your collection that expires documents
|
||||
* at that time
|
||||
* e.g.
|
||||
* db.MySessionCollection.ensureIndex( { "expireAt": 1 }, { expireAfterSeconds: 0 } )
|
||||
*/
|
||||
if (false !== $this->options['expiry_field']) {
|
||||
$expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime'));
|
||||
$fields[$this->options['expiry_field']] = $expiry;
|
||||
}
|
||||
|
||||
$this->getCollection()->update(
|
||||
array($this->options['id_field'] => $sessionId),
|
||||
array('$set' => $fields),
|
||||
|
@ -160,7 +155,8 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
public function read($sessionId)
|
||||
{
|
||||
$dbData = $this->getCollection()->findOne(array(
|
||||
$this->options['id_field'] => $sessionId,
|
||||
$this->options['id_field'] => $sessionId,
|
||||
$this->options['expiry_field'] => array('$gte' => new \MongoDate()),
|
||||
));
|
||||
|
||||
return null === $dbData ? '' : $dbData[$this->options['data_field']]->bin;
|
||||
|
|
|
@ -38,7 +38,7 @@ class AutoExpireFlashBagTest extends \PHPUnit_Framework_TestCase
|
|||
$this->bag->initialize($this->array);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->bag = null;
|
||||
parent::tearDown();
|
||||
|
|
|
@ -38,7 +38,7 @@ class FlashBagTest extends \PHPUnit_Framework_TestCase
|
|||
$this->bag->initialize($this->array);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->bag = null;
|
||||
parent::tearDown();
|
||||
|
|
|
@ -40,6 +40,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
'id_field' => '_id',
|
||||
'data_field' => 'data',
|
||||
'time_field' => 'time',
|
||||
'expiry_field' => 'expires_at',
|
||||
'database' => 'sf2-test',
|
||||
'collection' => 'session-test',
|
||||
);
|
||||
|
@ -73,6 +74,40 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertTrue($this->storage->close(), 'The "close" method should always return true');
|
||||
}
|
||||
|
||||
public function testRead()
|
||||
{
|
||||
$collection = $this->createMongoCollectionMock();
|
||||
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
|
||||
// defining the timeout before the actual method call
|
||||
// allows to test for "greater than" values in the $criteria
|
||||
$testTimeout = time();
|
||||
|
||||
$collection->expects($this->once())
|
||||
->method('findOne')
|
||||
->will($this->returnCallback(function ($criteria) use ($testTimeout) {
|
||||
$this->assertArrayHasKey($this->options['id_field'], $criteria);
|
||||
$this->assertEquals($criteria[$this->options['id_field']], 'foo');
|
||||
|
||||
$this->assertArrayHasKey($this->options['expiry_field'], $criteria);
|
||||
$this->assertArrayHasKey('$gte', $criteria[$this->options['expiry_field']]);
|
||||
$this->assertInstanceOf('MongoDate', $criteria[$this->options['expiry_field']]['$gte']);
|
||||
$this->assertGreaterThanOrEqual($criteria[$this->options['expiry_field']]['$gte']->sec, $testTimeout);
|
||||
|
||||
return array(
|
||||
$this->options['id_field'] => 'foo',
|
||||
$this->options['data_field'] => new \MongoBinData('bar', \MongoBinData::BYTE_ARRAY),
|
||||
$this->options['id_field'] => new \MongoDate(),
|
||||
);
|
||||
}));
|
||||
|
||||
$this->assertEquals('bar', $this->storage->read('foo'));
|
||||
}
|
||||
|
||||
public function testWrite()
|
||||
{
|
||||
$collection = $this->createMongoCollectionMock();
|
||||
|
@ -93,10 +128,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
$data = $updateData['$set'];
|
||||
}));
|
||||
|
||||
$expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime');
|
||||
$this->assertTrue($this->storage->write('foo', 'bar'));
|
||||
|
||||
$this->assertEquals('bar', $data[$this->options['data_field']]->bin);
|
||||
$this->assertInstanceOf('MongoDate', $data[$this->options['time_field']]);
|
||||
$this->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]);
|
||||
$this->assertGreaterThanOrEqual($expectedExpiry, $data[$this->options['expiry_field']]->sec);
|
||||
}
|
||||
|
||||
public function testWriteWhenUsingExpiresField()
|
||||
|
@ -188,8 +226,8 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
$collection->expects($this->once())
|
||||
->method('remove')
|
||||
->will($this->returnCallback(function ($criteria) {
|
||||
$this->assertInstanceOf('MongoDate', $criteria[$this->options['time_field']]['$lt']);
|
||||
$this->assertGreaterThanOrEqual(time() - 1, $criteria[$this->options['time_field']]['$lt']->sec);
|
||||
$this->assertInstanceOf('MongoDate', $criteria[$this->options['expiry_field']]['$lt']);
|
||||
$this->assertGreaterThanOrEqual(time() - 1, $criteria[$this->options['expiry_field']]['$lt']->sec);
|
||||
}));
|
||||
|
||||
$this->assertTrue($this->storage->gc(1));
|
||||
|
|
|
@ -94,7 +94,7 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
|||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
} else {
|
||||
$max = intval($max);
|
||||
$max = (int) $max;
|
||||
}
|
||||
|
||||
switch (substr($memoryLimit, -1)) {
|
||||
|
|
|
@ -22,7 +22,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
private $requestStack;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class FragmentHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
private $requestStack;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack')
|
||||
->disableOriginalConstructor()
|
||||
|
|
|
@ -20,7 +20,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
private $path;
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
if ($this->path) {
|
||||
// Restore path if it was changed.
|
||||
|
|
|
@ -17,7 +17,7 @@ class SimpleProcessTest extends AbstractProcessTest
|
|||
{
|
||||
private $enabledSigchild = false;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL);
|
||||
|
|
|
@ -256,7 +256,7 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf
|
|||
if (null === $propertyChanges['parentAcl'][1]) {
|
||||
$sets[] = 'parent_object_identity_id = NULL';
|
||||
} else {
|
||||
$sets[] = 'parent_object_identity_id = '.intval($propertyChanges['parentAcl'][1]->getId());
|
||||
$sets[] = 'parent_object_identity_id = '.(int) $propertyChanges['parentAcl'][1]->getId();
|
||||
}
|
||||
|
||||
$this->regenerateAncestorRelations($acl);
|
||||
|
@ -478,7 +478,7 @@ QUERY;
|
|||
$query,
|
||||
$this->options['entry_table_name'],
|
||||
$classId,
|
||||
null === $objectIdentityId ? 'NULL' : intval($objectIdentityId),
|
||||
null === $objectIdentityId ? 'NULL' : (int) $objectIdentityId,
|
||||
null === $field ? 'NULL' : $this->connection->quote($field),
|
||||
$aceOrder,
|
||||
$securityIdentityId,
|
||||
|
@ -596,7 +596,7 @@ QUERY;
|
|||
$classId,
|
||||
null === $oid ?
|
||||
$this->connection->getDatabasePlatform()->getIsNullExpression('object_identity_id')
|
||||
: 'object_identity_id = '.intval($oid),
|
||||
: 'object_identity_id = '.(int) $oid,
|
||||
null === $field ?
|
||||
$this->connection->getDatabasePlatform()->getIsNullExpression('field_name')
|
||||
: 'field_name = '.$this->connection->quote($field),
|
||||
|
@ -879,7 +879,7 @@ QUERY;
|
|||
|
||||
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
|
||||
$aceIdProperty->setAccessible(true);
|
||||
$aceIdProperty->setValue($ace, intval($aceId));
|
||||
$aceIdProperty->setValue($ace, (int) $aceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -953,7 +953,7 @@ QUERY;
|
|||
|
||||
$aceIdProperty = new \ReflectionProperty($ace, 'id');
|
||||
$aceIdProperty->setAccessible(true);
|
||||
$aceIdProperty->setValue($ace, intval($aceId));
|
||||
$aceIdProperty->setValue($ace, (int) $aceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase
|
|||
private $authorizationChecker;
|
||||
private $tokenStorage;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
$this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
|
||||
|
|
|
@ -21,7 +21,7 @@ class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase
|
|||
private $authorizationChecker;
|
||||
private $securityContext;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac
|
|||
$authenticateHeader = sprintf('Digest realm="%s", qop="auth", nonce="%s"', $this->realmName, $nonceValueBase64);
|
||||
|
||||
if ($authException instanceof NonceExpiredException) {
|
||||
$authenticateHeader = $authenticateHeader.', stale="true"';
|
||||
$authenticateHeader .= ', stale="true"';
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
|
|
|
@ -31,7 +31,7 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
private $response;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->successHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface');
|
||||
$this->failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface');
|
||||
|
|
|
@ -92,7 +92,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
|||
$listener->handle($this->event);
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -115,7 +115,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
|||
$this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->authenticationManager = null;
|
||||
$this->dispatcher = null;
|
||||
|
|
|
@ -25,7 +25,7 @@ class AbstractVoterTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
private $token;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->voter = new VoterFixture();
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
private $metadata;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->loader = new XmlFileLoader(__DIR__.'/../../Fixtures/serialization.xml');
|
||||
$this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
|
|
|
@ -29,7 +29,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
private $metadata;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
$this->loader = new YamlFileLoader(__DIR__.'/../../Fixtures/serialization.yml');
|
||||
$this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
|
|
|
@ -25,7 +25,7 @@ class TranslatorCacheTest extends \PHPUnit_Framework_TestCase
|
|||
$this->deleteTmpDir();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->deleteTmpDir();
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class IsbnValidator extends ConstraintValidator
|
|||
return Isbn::INVALID_CHARACTERS_ERROR;
|
||||
}
|
||||
|
||||
$checkSum += $digit * intval(10 - $i);
|
||||
$checkSum += $digit * (10 - $i);
|
||||
}
|
||||
|
||||
if (isset($isbn{$i})) {
|
||||
|
|
|
@ -129,7 +129,7 @@ class Inline
|
|||
setlocale(LC_NUMERIC, 'C');
|
||||
}
|
||||
if (is_float($value)) {
|
||||
$repr = strval($value);
|
||||
$repr = (string) $value;
|
||||
if (is_infinite($value)) {
|
||||
$repr = str_ireplace('INF', '.Inf', $repr);
|
||||
} elseif (floor($value) == $value && $repr == $value) {
|
||||
|
@ -137,7 +137,7 @@ class Inline
|
|||
$repr = '!!float '.$repr;
|
||||
}
|
||||
} else {
|
||||
$repr = is_string($value) ? "'$value'" : strval($value);
|
||||
$repr = is_string($value) ? "'$value'" : (string) $value;
|
||||
}
|
||||
if (false !== $locale) {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
|
@ -169,8 +169,9 @@ class Inline
|
|||
{
|
||||
// array
|
||||
$keys = array_keys($value);
|
||||
if ((1 == count($keys) && '0' == $keys[0])
|
||||
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
|
||||
$keysCount = count($keys);
|
||||
if ((1 === $keysCount && '0' == $keys[0])
|
||||
|| ($keysCount > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) === $keysCount * ($keysCount - 1) / 2)
|
||||
) {
|
||||
$output = array();
|
||||
foreach ($value as $val) {
|
||||
|
@ -466,7 +467,7 @@ class Inline
|
|||
case 0 === strpos($scalar, '!str'):
|
||||
return (string) substr($scalar, 5);
|
||||
case 0 === strpos($scalar, '! '):
|
||||
return intval(self::parseScalar(substr($scalar, 2)));
|
||||
return (int) self::parseScalar(substr($scalar, 2));
|
||||
case 0 === strpos($scalar, '!!php/object:'):
|
||||
if (self::$objectSupport) {
|
||||
return unserialize(substr($scalar, 13));
|
||||
|
@ -481,23 +482,23 @@ class Inline
|
|||
return (float) substr($scalar, 8);
|
||||
case ctype_digit($scalar):
|
||||
$raw = $scalar;
|
||||
$cast = intval($scalar);
|
||||
$cast = (int) $scalar;
|
||||
|
||||
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
|
||||
$raw = $scalar;
|
||||
$cast = intval($scalar);
|
||||
$cast = (int) $scalar;
|
||||
|
||||
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||
case is_numeric($scalar):
|
||||
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
|
||||
return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
|
||||
case '.inf' === $scalarLower:
|
||||
case '.nan' === $scalarLower:
|
||||
return -log(0);
|
||||
case '-.inf' === $scalarLower:
|
||||
return log(0);
|
||||
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
|
||||
return floatval(str_replace(',', '', $scalar));
|
||||
return (float) str_replace(',', '', $scalar);
|
||||
case preg_match(self::getTimestampRegex(), $scalar):
|
||||
return strtotime($scalar);
|
||||
}
|
||||
|
|
|
@ -460,7 +460,7 @@ class Parser
|
|||
if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) {
|
||||
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
|
||||
|
||||
return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
|
||||
return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Reference in New Issue