Skip to content

Commit

Permalink
Merge branch '2.5' into 2.6
Browse files Browse the repository at this point in the history
* 2.5:
  [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
  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
  don't override internal PHP constants
  [Session] Fix parameter names in WriteCheckSessionHandler
  Add consistency with request type checking
  [FrameworkBundle] Fix server run in case the router script does not exist

Conflicts:
	composer.json
	src/Symfony/Component/Debug/ErrorHandler.php
	src/Symfony/Component/Debug/ExceptionHandler.php
  • Loading branch information
fabpot committed Nov 20, 2014
2 parents 10e208b + 891ebe5 commit f288a69
Show file tree
Hide file tree
Showing 64 changed files with 850 additions and 228 deletions.
159 changes: 85 additions & 74 deletions UPGRADE-3.0.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion autoload.php.dist
@@ -1,6 +1,6 @@
<?php

if (version_compare(PHP_VERSION, '5.4', '>=') && gc_enabled()) {
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
// https://bugs.php.net/bug.php?id=53976
gc_disable();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -73,7 +73,7 @@
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"monolog/monolog": "~1.11",
"propel/propel1": "1.6.*",
"propel/propel1": "~1.6",
"ircmaxell/password-compat": "1.0.*",
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev",
"egulias/email-validator": "~1.2"
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Propel1/composer.json
Expand Up @@ -20,7 +20,7 @@
"symfony/http-foundation": "~2.0",
"symfony/http-kernel": "~2.0",
"symfony/form": "~2.2",
"propel/propel1": "1.6.*"
"propel/propel1": "~1.6"
},
"require-dev": {
"symfony/stopwatch": "~2.2"
Expand Down
12 changes: 7 additions & 5 deletions src/Symfony/Bridge/Twig/Extension/CodeExtension.php
Expand Up @@ -11,10 +11,6 @@

namespace Symfony\Bridge\Twig\Extension;

if (!defined('ENT_SUBSTITUTE')) {
define('ENT_SUBSTITUTE', 8);
}

/**
* Twig extension relate to PHP code and used by the profiler and the default exception templates.
*
Expand Down Expand Up @@ -178,7 +174,13 @@ public function formatFile($file, $line, $text = null)
$text = "$text at line $line";

if (false !== $link = $this->getFileLink($file, $line)) {
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);
if (PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;
}

return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
}

return $text;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
Expand Up @@ -66,7 +66,7 @@ public function testCompile()

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

Expand Down
Expand Up @@ -263,7 +263,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()

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

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
Expand Up @@ -38,7 +38,7 @@ public function testCompileStrict()
}
protected function getVariableGetterWithoutStrictCheck($name)
{
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
if (PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
}

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

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

Expand Down
31 changes: 26 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\ProcessBuilder;

/**
Expand All @@ -29,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand
*/
public function isEnabled()
{
if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) {
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
return false;
}

Expand All @@ -44,7 +45,7 @@ protected function configure()
$this
->setDefinition(array(
new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', 'web/'),
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null),
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
))
->setName('server:run')
Expand Down Expand Up @@ -82,8 +83,18 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (defined('HHVM_VERSION')) {
$output->writeln('<error>This command is not supported on HHVM.</error>');

return 1;
}

$documentRoot = $input->getOption('docroot');

if (null === $documentRoot) {
$documentRoot = $this->getContainer()->getParameter('kernel.root_dir').'/../web';
}

if (!is_dir($documentRoot)) {
$output->writeln(sprintf('<error>The given document root directory "%s" does not exist</error>', $documentRoot));

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

$builder = $this->createPhpProcessBuilder($input, $output, $env);
if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
return 1;
}

$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$process = $builder->getProcess();
Expand Down Expand Up @@ -134,11 +148,18 @@ private function createPhpProcessBuilder(InputInterface $input, OutputInterface
if (!file_exists($router)) {
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));

return 1;
return;
}

$router = realpath($router);
$finder = new PhpExecutableFinder();

if (false === $binary = $finder->find()) {
$output->writeln('<error>Unable to find PHP binary to run server</error>');

return;
}

return new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router));
}
}
Expand Up @@ -13,10 +13,6 @@

use Symfony\Component\Templating\Helper\Helper;

if (!defined('ENT_SUBSTITUTE')) {
define('ENT_SUBSTITUTE', 8);
}

/**
* CodeHelper.
*
Expand Down Expand Up @@ -170,7 +166,13 @@ public function formatFile($file, $line, $text = null)
}

if (false !== $link = $this->getFileLink($file, $line)) {
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);
if (PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;
}

return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
}

return $text;
Expand Down
Expand Up @@ -351,8 +351,11 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
;
}

// Determine default entry point
$defaultEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null;

// Authentication listeners
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider);
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $defaultEntryPoint);

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

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

// Determine default entry point
if (isset($firewall['entry_point'])) {
$defaultEntryPoint = $firewall['entry_point'];
}

// Exception listener
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $defaultEntryPoint));

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

private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider)
private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider, $defaultEntryPoint)
{
$listeners = array();
$hasListeners = false;
$defaultEntryPoint = null;

foreach ($this->listenerPositions as $position) {
foreach ($this->factories[$position] as $factory) {
Expand Down
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class FirewallEntryPointExtension extends Extension
{
public function load(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
}
}
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class FirewallEntryPointBundle extends Bundle
{
}
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="firewall_entry_point.entry_point.stub"
class="Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub"
/>
</services>
</container>
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;

class EntryPointStub implements AuthenticationEntryPointInterface
{
const RESPONSE_TEXT = '2be8e651259189d841a19eecdf37e771e2431741';

public function start(Request $request, AuthenticationException $authException = null)
{
return new Response(self::RESPONSE_TEXT);
}
}
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\SecurityBundle\Tests\Functional;

use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub;

/**
* @group functional
*/
class FirewallEntryPointTest extends WebTestCase
{
public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()
{
$client = $this->createClient(array('test_case' => 'FirewallEntryPoint'));
$client->insulate();

$client->request('GET', '/secure/resource', array(), array(), array(
'PHP_AUTH_USER' => 'unknown',
'PHP_AUTH_PW' => 'credentials',
));

$this->assertEquals(
EntryPointStub::RESPONSE_TEXT,
$client->getResponse()->getContent(),
"Custom entry point wasn't started"
);
}

protected function setUp()
{
parent::setUp();

$this->deleteTmpDir('FirewallEntryPoint');
}

protected function tearDown()
{
parent::tearDown();

$this->deleteTmpDir('FirewallEntryPoint');
}
}
Expand Up @@ -30,7 +30,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
*/
public function testRoutingErrorIsExposedWhenNotProtected($config)
{
if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) {
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
}

Expand All @@ -46,7 +46,7 @@ public function testRoutingErrorIsExposedWhenNotProtected($config)
*/
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
{
if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) {
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
}

Expand Down
@@ -0,0 +1,7 @@
<?php

return array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\FirewallEntryPointBundle(),
);

0 comments on commit f288a69

Please sign in to comment.