8000 Fix form csrf tokens on kernel reload by avalanche123 · Pull Request #47 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fix form csrf tokens on kernel reload #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bdada47
[Translation] Added CsvFileLoader to support csv translation resources.
umpirsky Jan 8, 2011
e85546e
[DependencyInjection] made some improvments to the container compiler
schmittjoh Jan 8, 2011
d1a2a65
[DependencyInjection] performance improvement, better analysis tools
schmittjoh Jan 9, 2011
f1e41a9
[DependencyInjection] made some improvments to the container compiler
schmittjoh Jan 9, 2011
99a5097
[HttpFoundation] Correcting the PHPDoc for the public $headers proper…
weaverryan Jan 9, 2011
09a876b
[HttpFoundation] Adding a few internal notes to clarify the process o…
weaverryan Jan 9, 2011
361a0dc
[Translation] Adding PHPDoc to the MessageSelector::choose() method.
weaverryan Jan 9, 2011
98c787a
[CompatAssetsBundle] Add missing namespace
ornicar Jan 10, 2011
dedf29f
[HttpKernel] No longer reformat {} "a la python"
igorw Jan 9, 2011
3734c0e
updated bootstrap file
fabpot Jan 10, 2011
d6b57bc
[HttpFoundation] fixed error casting broken in DomCrawl 8000 er\Form::getPh…
avalanche123 Jan 10, 2011
7cab551
[FrameworkBundle] removed public=false from security.encoder_factory
ruudk Jan 11, 2011
c85b587
made security.acl.dbal.connection public for use in acl:init
Jan 10, 2011
18a34c5
[DoctrineBundle] Changed visibility of doctrine db connections to public
Jan 10, 2011
f41654f
[Console] added rendering previous exceptions
hason Jan 11, 2011
08c3a2b
method buildContainer divided into logical parts
hason Jan 10, 2011
9a2e053
[Event] Collected data is about listener (not event) calls
vicb Jan 9, 2011
47b87e9
[TwigBundle] made global more powerful
fabpot Jan 11, 2011
4beac30
[Form, FrameworkBundle] added csrf tokens reset on Kernel::shutdown()…
avalanche123 Jan 11, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[DependencyInjection] made some improvments to the container compiler
- added generic repeated pass
- better optimization of services
- started adding some integration tests
  • Loading branch information
schmittjoh authored and fabpot committed Jan 9, 2011
commit e85546ef7de757e6f36f29d17665886f47d59aa2
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class InlineServiceDefinitionsPass implements CompilerPassInterface
class InlineServiceDefinitionsPass implements RepeatablePassInterface
{
protected $aliasMap;
protected $repeatedPass;

public function setRepeatedPass(RepeatedPass $repeatedPass)
{
$this->repeatedPass = $repeatedPass;
}

public function process(ContainerBuilder $container)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public function __construct()
$this->removingPasses = array(
new RemovePrivateAliasesPass(),
new ReplaceAliasByActualDefinitionPass(),
new InlineServiceDefinitionsPass(),
new RemoveUnusedDefinitionsPass(),
new RepeatedPass(array(
new InlineServiceDefinitionsPass(),
new RemoveUnusedDefinitionsPass(),
)),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class RemoveUnusedDefinitionsPass implements CompilerPassInterface
class RemoveUnusedDefinitionsPass implements RepeatablePassInterface
{
protected $repeatedPass;

public function setRepeatedPass(RepeatedPass $repeatedPass)
{
$this->repeatedPass = $repeatedPass;
}

public function process(ContainerBuilder $container)
{
$hasChanged = false;
Expand All @@ -45,7 +52,7 @@ public function process(ContainerBuilder $container)
}

if ($hasChanged) {
$this->process($container);
$this->repeatedPass->setRepeat();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Symfony\Component\DependencyInjection\Compiler;

/**
* Interface that must be implemented by passes that are run as part of an
* RepeatedPass.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface RepeatablePassInterface extends CompilerPassInterface
{
function setRepeatedPass(RepeatedPass $repeatedPass);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Symfony\Component\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* A pass that might be run repeatedly.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class RepeatedPass implements CompilerPassInterface
{
protected $repeat;
protected $passes;

public function __construct(array $passes)
{
foreach ($passes as $pass) {
if (!$pass instanceof RepeatablePassInterface) {
throw new \InvalidArgumentException('$passes must be an array of RepeatablePassInterface.');
}

$pass->setRepeatedPass($this);
}

$this->passes = $passes;
}

public function process(ContainerBuilder $container)
{
$this->repeat = false;
foreach ($this->passes as $pass) {
$pass->process($container);
}

if ($this->repeat) {
$this->process($container);
}
}

public function setRepeat()
{
$this->repeat = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Symfony\Tests\Component\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Alias;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* This class tests the integration of the different compiler passes
*/
class IntegrationTest extends \PHPUnit_Framework_TestCase
{
/**
* This tests that the following dependencies are correctly processed:
*
* A is public, B/C are private
* A -> C
* B -> C
*/
public function testProcessRemovesAndInlinesRecursively()
{
$container = new ContainerBuilder();

$a = $container
->register('a')
->addArgument(new Reference('c'))
;

$b = $container
->register('b')
->addArgument(new Reference('c'))
->setPublic(false)
;

$c = $container
->register('c')
->setPublic(false)
;

$container->freeze();

$this->assertTrue($container->hasDefinition('a'));
$arguments = $a->getArguments();
$this->assertSame($c, $arguments[0]);
$this->assertFalse($container->hasDefinition('b'));
$this->assertFalse($container->hasDefinition('c'));
}

public function testProcessInlinesReferencesToAliases()
{
$container = new ContainerBuilder();

$a = $container
->register('a')
->addArgument(new Reference('b'))
;

$container->setAlias('b', new Alias('c', false));

$c = $container
->register('c')
->setPublic(false)
;

$container->freeze();

$this->assertTrue($container->hasDefinition('a'));
$arguments = $a->getArguments();
$this->assertSame($c, $arguments[0]);
$this->assertFalse($container->hasAlias('b'));
$this->assertFalse($container->hasDefinition('c'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Symfony\Tests\Component\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\RepeatedPass;

use Symfony\Component\DependencyInjection\Compiler\RemoveUnusedDefinitionsPass;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -72,6 +74,7 @@ public function testProcessWorksWithInlinedDefinitions()
protected function process(ContainerBuilder $container)
{
$pass = new RemoveUnusedDefinitionsPass();
$repeatedPass = new RepeatedPass(array($pass));
$pass->process($container);
}
}
0