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 all commits
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 DomCrawler\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
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/CompatAssetsBundle/CompatAssetsBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Symfony\Bundle\CompatAssetsBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

/*
* This file is part of the Symfony framework.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ protected function loadDbalConnection(array $connection, ContainerBuilder $conta

$driverOptions = array();
$driverDef = new Definition('Doctrine\DBAL\DriverManager');
$driverDef->setPublic(false);
$driverDef->setFactoryMethod('getConnection');
$container->setDefinition(sprintf('doctrine.dbal.%s_connection', $connection['name']), $driverDef);
}
Expand Down
29 changes: 11 additions & 18 deletions src/Symfony/Bundle/FrameworkBundle/Debug/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ public function __construct(LoggerInterface $logger = null)
}

/**
* Notifies all listeners of a given event.
*
* @param Event $event A Event instance
*
* @return Event The Event instance
* {@inheritDoc}
*/
public function notify(Event $event)
{
Expand All @@ -57,11 +53,7 @@ public function notify(Event $event)
}

/**
* Notifies all listeners of a given event until one returns a non null value.
*
* @param Event $event A Event instance
*
* @return Event The Event instance
* {@inheritDoc}
*/
public function notifyUntil(Event $event)
{
Expand All @@ -87,12 +79,7 @@ public function notifyUntil(Event $event)
}

/**
* Filters a value by calling all listeners of a given event.
*
* @param Event $event A Event instance
* @param mixed $value The value to be filtered
*
* @return Event The Event instance
* {@inheritDoc}
*/
public function filter(Event $event, $value)
{
Expand All @@ -107,12 +94,18 @@ public function filter(Event $event, $value)
return $event;
}

public function getCalledEvents()
/**
* {@inheritDoc}
*/
public function getCalledListeners()
{
return $this->called;
}

public function getNotCalledEvents()
/**
* {@inheritDoc}
*/
public function getNotCalledListeners()
{
$notCalled = array();

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function boot()
});
}

public function shutdown()
{
FormConfiguration::clearDefaultCsrfSecrets();
}

public function registerExtensions(ContainerBuilder $container)
{
parent::registerExtensions($container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<argument type="collection"></argument>
</service>

<service id="security.encoder_factory" alias="security.encoder_factory.generic" public="false"></service>
<service id="security.encoder_factory" alias="security.encoder_factory.generic"></service>

<service id="security.logout.handler.session" class="%security.logout.handler.session.class%" public="false"></service>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</parameters>

<services>
<service id="security.acl.dbal.connection" alias="doctrine.dbal.default_connection" public="false" />
<service id="security.acl.dbal.connection" alias="doctrine.dbal.default_connection" />

<service id="security.acl.object_identity_retrieval_strategy" class="%security.acl.object_identity_retrieval_strategy.class%" public="false"></service>

Expand Down Expand Up @@ -76,4 +76,4 @@
<tag name="security.voter" />
</service>
</services>
</container>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ public function configLoad($config, ContainerBuilder $container)
$globals = $this->fixConfig($config, 'global');
if (isset($globals[0])) {
foreach ($globals as $global) {
$def->addMethodCall('addGlobal', array($global['key'], new Reference($global['id'])));
if (isset($global['type']) && 'service' === $global['type']) {
$def->addMethodCall('addGlobal', array($global['key'], new Reference($global['id'])));
} elseif (isset($global['value'])) {
$def->addMethodCall('addGlobal', array($global['key'], $global['value']));
} else {
throw new \InvalidArgumentException(sprintf('Unable to understand global configuration (%s).', var_export($global, true)));
}
}
} else {
foreach ($globals as $key => $id) {
$def->addMethodCall('addGlobal', array($key, new Reference($id)));
foreach ($globals as $key => $value) {
if ('@' === substr($value, 0, 1)) {
$def->addMethodCall('addGlobal', array($key, new Reference(substr($value, 1))));
} else {
$def->addMethodCall('addGlobal', array($key, $value));
}
}
}
unset($config['globals'], $config['global']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<xsd:complexType name="config">
<xsd:sequence>
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="1" />
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="extension" type="extension" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>

Expand All @@ -29,8 +29,9 @@
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="global">
<xsd:attribute name="key" type="xsd:string" />
<xsd:complexType name="global" mixed="true">
<xsd:attribute name="key" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="id" type="xsd:string" />
</xsd:complexType>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class TwigExtensionTest extends TestCase
{
Expand All @@ -36,18 +37,28 @@ public function testConfigGlobals()
// XML
$container = new ContainerBuilder();
$loader = new TwigExtension();
$loader->configLoad(array('global' => array(array('key' => 'foo', 'id' => 'bar'))), $container);
$loader->configLoad(array('global' => array(
array('key' => 'foo', 'type' => 'service', 'id' => 'bar'),
array('key' => 'pi', 'value' => 3.14),
)), $container);
$config = $container->getDefinition('twig')->getMethodCalls();
$this->assertEquals('foo', $config[0][1][0]);
$this->assertEquals('bar', (string) $config[0][1][1]);
$this->assertEquals(new Reference('bar'), $config[0][1][1]);
$this->assertEquals('pi', $config[1][1][0]);
$this->assertEquals(3.14, $config[1][1][1]);

// YAML, PHP
$container = new ContainerBuilder();
$loader = new TwigExtension();
$loader->configLoad(array('globals' => array('foo' => 'bar')), $container);
$loader->configLoad(array('globals' => array(
'foo' => '@bar',
'pi' => 3.14,
)), $container);
$config = $container->getDefinition('twig')->getMethodCalls();
$this->assertEquals('foo', $config[0][1][0]);
$this->assertEquals('bar', (string) $config[0][1][1]);
$this->assertEquals(new Reference('bar'), $config[0][1][1]);
$this->assertEquals('pi', $config[1][1][0]);
$this->assertEquals(3.14, $config[1][1][1]);
}

public function testConfigExtensions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ Events
{% endblock %}

{% block panel %}
<h2>Called Events</h2>
<h2>Called Listeners</h2>

<table>
<tr>
<th>Event</th>
<th>Caller</th>
<th>Listener</th>
</tr>
{% for event in collector.calledevents %}
{% for elements in collector.calledlisteners %}
<tr>
<td><code>{{ event.event }}</code></td>
<td><code>{{ event.caller|abbr_class }}</code></td>
<td><code>{{ event.listener|abbr_method }}()</code></td>
<td><code>{{ elements.event }}</code></td>
<td><code>{{ elements.caller|abbr_class }}</code></td>
<td><code>{{ elements.listener|abbr_method }}()</code></td>
</tr>
{% endfor %}
</table>

{% if collector.notcalledevents %}
<h2>Not Called Events</h2>
{% if collector.notcalledlisteners %}
<h2>Not Called Listeners</h2>

<table>
<tr>
<th>Event</th>
<th>Listener</th>
</tr>
{% for event in collector.notcalledevents %}
{% for elements in collector.notcalledlisteners %}
<tr>
<td><code>{{ event.event }}</code></td>
<td><code>{{ event.listener|abbr_method }}()</code></td>
<td><code>{{ elements.event }}</code></td>
<td><code>{{ elements.listener|abbr_method }}()</code></td>
</tr>
{% endfor %}
</table>
Expand Down
82 changes: 42 additions & 40 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,55 +657,57 @@ public function renderException($e, $output)
return function_exists('mb_strlen') ? mb_strlen($string) : strlen($string);
};

$title = sprintf(' [%s] ', get_class($e));
$len = $strlen($title);
$lines = array();
foreach (explode("\n", $e->getMessage()) as $line) {
$lines[] = sprintf(' %s ', $line);
$len = max($strlen($line) + 4, $len);
}

$messages = array(str_repeat(' ', $len), $title.str_repeat(' ', $len - $strlen($title)));
do {
$title = sprintf(' [%s] ', get_class($e));
$len = $strlen($title);
$lines = array();
foreach (explode("\n", $e->getMessage()) as $line) {
$lines[] = sprintf(' %s ', $line);
$len = max($strlen($line) + 4, $len);
}

foreach ($lines as $line) {
$messages[] = $line.str_repeat(' ', $len - $strlen($line));
}
$messages = array(str_repeat(' ', $len), $title.str_repeat(' ', $len - $strlen($title)));

$messages[] = str_repeat(' ', $len);
foreach ($lines as $line) {
$messages[] = $line.str_repeat(' ', $len - $strlen($line));
}

$output->writeln("\n");
foreach ($messages as $message) {
$output->writeln('<error>'.$message.'</error>');
}
$output->writeln("\n");
$messages[] = str_repeat(' ', $len);

if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));
$output->writeln("\n");
}

if (Output::VERBOSITY_VERBOSE === $output->getVerbosity()) {
$output->writeln('</comment>Exception trace:</comment>');

// exception related properties
$trace = $e->getTrace();
array_unshift($trace, array(
'function' => '',
'file' => $e->getFile() != null ? $e->getFile() : 'n/a',
'line' => $e->getLine() != null ? $e->getLine() : 'n/a',
'args' => array(),
));
foreach ($messages as $message) {
$output->writeln('<error>'.$message.'</error>');
}
$output->writeln("\n");

for ($i = 0, $count = count($trace); $i < $count; $i++) {
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
$function = $trace[$i]['function'];
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
if (Output::VERBOSITY_VERBOSE === $output->getVerbosity()) {
$output->writeln('</comment>Exception trace:</comment>');

// exception related properties
$trace = $e->getTrace();
array_unshift($trace, array(
'function' => '',
'file' => $e->getFile() != null ? $e->getFile() : 'n/a',
'line' => $e->getLine() != null ? $e->getLine() : 'n/a',
'args' => array(),
));

for ($i = 0, $count = count($trace); $i < $count; $i++) {
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
$function = $trace[$i]['function'];
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';

$output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line));
}

$output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line));
$output->writeln("\n");
}
} while ($e = $e->getPrevious());

if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));
$output->writeln("\n");
}
}
Expand Down
Loading