8000 Merge branch '2.6' into 2.7 · symfony/symfony@6a63cc5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a63cc5

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: Extract an AbstractEventDispatcherTest from EventDispatcherTest and also use it in ContainerAwareEventDispatcherTest [SecurityBundle] Authentication entry point is only registered with firewall exception listener, not with authentication listeners be smarter when guessing the document root Azerbaijani locale Fixed grammar error in docblock [HttpKernel] fix parse error in DumpDataCollector [TwigBundle/DebugBundle] move dump extension & cleanups Adjust upgrade file rendering [Bridge/Propel1] Changed deps to accepts all upcoming propel1 versions compare version using PHP_VERSION_ID [Form] Add doc for FormEvents *_timezone changes also affect the BirthdayType don't override internal PHP constants Drop support for model_timezone and view_timezone options in TimeType and DateType. [DomCrawler] Added support for link tags in the Link class [Session] Fix parameter names in WriteCheckSessionHandler Add consistency with request type checking [FrameworkBundle] Fix server run in case the router script does not exist
2 parents 69b07e9 + f288a69 commit 6a63cc5

File tree

80 files changed

+1312
-733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1312
-733
lines changed

UPGRADE-3.0.md

Lines changed: 85 additions & 74 deletions
Large diffs are not rendered by default.

autoload.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if (version_compare(PHP_VERSION, '5.4', '>=') && gc_enabled()) {
3+
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
44
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
55
// https://bugs.php.net/bug.php?id=53976
66
gc_disable();

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"doctrine/orm": "~2.2,>=2.2.3",
7474
"doctrine/doctrine-bundle": "~1.2",
7575
"monolog/monolog": "~1.11",
76-
"propel/propel1": "1.6.*",
76+
"propel/propel1": "~1.6",
7777
"ircmaxell/password-compat": "1.0.*",
7878
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev",
7979
"egulias/email-validator": "~1.2"

src/Symfony/Bridge/Propel1/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"symfony/http-foundation": "~2.0",
2121
"symfony/http-kernel": "~2.0",
2222
"symfony/form": "~2.2",
23-
"propel/propel1": "1.6.*"
23+
"propel/propel1": "~1.6"
2424
},
2525
"require-dev": {
2626
"symfony/stopwatch": "~2.2"

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
namespace Symfony\Bridge\Twig\Extension;
1313

14-
if (!defined('ENT_SUBSTITUTE')) {
15-
define('ENT_SUBSTITUTE', 8);
16-
}
17-
1814
/**
1915
* Twig extension relate to PHP code and used by the profiler and the default exception templates.
2016
*
@@ -178,7 +174,13 @@ public function formatFile($file, $line, $text = null)
178174
$text = "$text at line $line";
179175

180176
if (false !== $link = $this->getFileLink($file, $line)) {
181-
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), $text);
177+
if (PHP_VERSION_ID >= 50400) {
178+
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
179+
} else {
180+
$flags = ENT_QUOTES;
181+
}
182+
183+
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
182184
}
183185

184186
return $text;

src/Symfony/Bridge/Twig/Extension/DumpExtension.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
*/
2323
class DumpExtension extends \Twig_Extension
2424
{
25-
public function __construct(ClonerInterface $cloner = null)
25+
private $cloner;
26+
27+
public function __construct(ClonerInterface $cloner)
2628
{
2729
$this->cloner = $cloner;
2830
}
@@ -46,7 +48,7 @@ public function getName()
4648

4749
public function dump(\Twig_Environment $env, $context)
4850
{
49-
if (!$env->isDebug() || !$this->cloner) {
51+
if (!$env->isDebug()) {
5052
return;
5153
}
5254

@@ -64,17 +66,14 @@ public function dump(\Twig_Environment $env, $context)
6466
unset($vars[0], $vars[1]);
6567
}
6668

67-
$html = '';
68-
$dumper = new HtmlDumper(function ($line, $depth) use (&$html) {
69-
if (-1 !== $depth) {
70-
$html .= str_repeat(' ', $depth).$line."\n";
71-
}
72-
});
69+
$dump = fopen('php://memory', 'r+b');
70+
$dumper = new HtmlDumper($dump);
7371

7472
foreach ($vars as $value) {
7573
$dumper->dump($this->cloner->cloneVar($value));
7674
}
75+
rewind($dump);
7776

78-
return $html;
77+
return stream_get_contents($dump);
7978
}
8079
}

src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testCompile()
6666

6767
protected function getVariableGetter($name)
6868
{
69-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
69+
if (PHP_VERSION_ID >= 50400) {
7070
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
7171
}
7272

src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
263263

264264
protected function getVariableGetter($name)
265265
{
266-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
266+
if (PHP_VERSION_ID >= 50400) {
267267
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
268268
}
269269

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testCompileStrict()
3838
}
3939
protected function getVariableGetterWithoutStrictCheck($name)
4040
{
41-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
41+
if (PHP_VERSION_ID >= 50400) {
4242
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
4343
}
4444

@@ -47,7 +47,7 @@ protected function getVariableGetterWithoutStrictCheck($name)
4747

4848
protected function getVariableGetterWithStrictCheck($name)
4949
{
50-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
50+
if (PHP_VERSION_ID >= 50400) {
5151
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
5252
}
5353

src/Symfony/Bundle/DebugBundle/Resources/config/services.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<services>
8+
<service id="twig.extension.dump" class="Symfony\Bridge\Twig\Extension\DumpExtension" public="false">
9+
<tag name="twig.extension" />
10+
<argument type="service" id="var_dumper.cloner" />
11+
</service>
12+
813
<service id="data_collector.dump" class="Symfony\Component\HttpKernel\DataCollector\DumpDataCollector">
914
<tag name="data_collector" id="dump" template="@Debug/Profiler/dump.html.twig" />
1015
<argument type="service" id="debug.stopwatch" on-invalid="ignore" />

src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Input\InputOption;
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Output\OutputInterface;
18+
use Symfony\Component\Process\PhpExecutableFinder;
1819
use Symfony\Component\Process\ProcessBuilder;
1920

2021
/**
@@ -29,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand
2930
*/
3031
public function isEnabled()
3132
{
32-
if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) {
33+
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
3334
return false;
3435
}
3536

@@ -44,7 +45,7 @@ protected function configure()
4445
$this
4546
->setDefinition(array(
4647
new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
47-
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', 'web/'),
48+
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null),
4849
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
4950
))
5051
->setName('server:run')
@@ -82,8 +83,18 @@ protected function configure()
8283
*/
8384
protected function execute(InputInterface $input, OutputInterface $output)
8485
{
86+
if (defined('HHVM_VERSION')) {
87+
$output->writeln('<error>This command is not supported on HHVM.</error>');
88+
89+
return 1;
90+
}
91+
8592
$documentRoot = $input->getOption('docroot');
8693

94+
if (null === $documentRoot) {
95+
$documentRoot = $this->getContainer()->getParameter('kernel.root_dir').'/../web';
96+
}
97+
8798
if (!is_dir($documentRoot)) {
8899
$output->writeln(sprintf('<error>The given document root directory "%s" does not exist</error>', $documentRoot));
89100

@@ -99,7 +110,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
99110
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
100111
$output->writeln('Quit the server with CONTROL-C.');
101112

102-
$builder = $this->createPhpProcessBuilder($input, $output, $env);
113+
if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
114+
return 1;
115+
}
116+
103117
$builder->setWorkingDirectory($documentRoot);
104118
$builder->setTimeout(null);
105119
$process = $builder->getProcess();
@@ -134,11 +148,18 @@ private function createPhpProcessBuilder(InputInterface $input, OutputInterface
134148
if (!file_exists($router)) {
135149
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));
136150

137-
return 1;
151+
return;
138152
}
139153

140154
$router = realpath($router);
155+
$finder = new PhpExecutableFinder();
156 10000 +
157+
if (false === $binary = $finder->find()) {
158+
$output->writeln('<error>Unable to find PHP binary to run server</error>');
159+
160+
return;
161+
}
141162

142-
return new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
163+
return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router));
143164
}
144165
}

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313

1414
use Symfony\Component\Templating\Helper\Helper;
1515

16-
if (!defined('ENT_SUBSTITUTE')) {
17-
define('ENT_SUBSTITUTE', 8);
18-
}
19-
2016
/**
2117
* CodeHelper.
2218
*
@@ -170,7 +166,13 @@ public function formatFile($file, $line, $text = null)
170166
}
171167

172168
if (false !== $link = $this->getFileLink($file, $line)) {
173-
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), $text);
169+
if (PHP_VERSION_ID >= 50400) {
170+
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
171+
} else {
172+
$flags = ENT_QUOTES;
173+
}
174+
175+
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
174176
}
175177

176178
return $text;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 5 10000 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,11 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
351351
;
352352
}
353353

354+
// Determine default entry point
355+
$defaultEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null;
356+
354357
// Authentication listeners
355-
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider);
358+
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $defaultEntryPoint);
356359

357360
$listeners = array_merge($listeners, $authListeners);
358361

@@ -364,11 +367,6 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
364367
// Access listener
365368
$listeners[] = new Reference('security.access_listener');
366369

367-
// Determine default entry point
368-
if (isset($firewall['entry_point'])) {
369-
$defaultEntryPoint = $firewall['entry_point'];
370-
}
371-
372370
// Exception listener
373371
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $defaultEntryPoint));
374372

@@ -388,11 +386,10 @@ private function createContextListener($container, $contextKey)
388386
return $this->contextListeners[$contextKey] = $listenerId;
389387
}
390388

391-
private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider)
389+
private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider, $defaultEntryPoint)
392390
{
393391
$listeners = array();
394392
$hasListeners = false;
395-
$defaultEntryPoint = null;
396393

397394
foreach ($this->listenerPositions as $position) {
398395
foreach ($this->factories[$position] as $factory) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\DependencyInjection;
13+
14+
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
17+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18+
19+
class FirewallEntryPointExtension extends Extension
20+
{
21+
public function load(array $config, ContainerBuilder $container)
22+
{
23+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
24+
$loader->load('services.xml');
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle;
13+
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
class FirewallEntryPointBundle extends Bundle
17+
{
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
5+
<services>
6+
<service id="firewall_entry_point.entry_point.stub"
7+
class="Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub"
8+
/>
9+
</services>
10+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security;
13+
14+
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
17+
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
18+
19+
class EntryPointStub implements AuthenticationEntryPointInterface
20+
{
21+
const RESPONSE_TEXT = '2be8e651259189d841a19eecdf37e771e2431741';
22+
23+
public function start(Request $request, AuthenticationException $authException = null)
24+
{
25+
return new Response(self::RESPONSE_TEXT);
26+
}
27+
}

0 commit comments

Comments
 (0)
0