Skip to content

Commit

Permalink
Merge branch '2.5'
Browse files Browse the repository at this point in the history
* 2.5:
  added missing files
  [TwigBundle] added a test
  Indicate which file was being parsed if an exception is thrown while running translation:debug
  [ClassLoader] Cast $useIncludePath property to boolean
  [HttpFoundation] Minor spelling fix in PHPDocs
  improve error message for multiple documents
  Remove aligned '=>' and '='
  [Session] remove invalid workaround in session regenerate
  [Kernel] ensure session is saved before sending response
  [Routing] serialize the compiled route to speed things up
  [Form] Fixed usage of "name" variable in form_start block
  [Validator] Fixed Regex::getHtmlPattern() to work with complex and negated patterns
  [DependencyInjection] use inheritdoc for loaders
  [Config] fix filelocator with empty name
  [Form] fix form handling with unconventional request methods like OPTIONS
  CSRF warning docs on Request::enableHttpMethodParameterOverride()

Conflicts:
	src/Symfony/Component/Console/Helper/ProgressBar.php
  • Loading branch information
fabpot committed Nov 3, 2014
2 parents add32ce + 14c417a commit 4982984
Show file tree
Hide file tree
Showing 77 changed files with 633 additions and 461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD

if (!isset($cacheDriver['namespace'])) {
// generate a unique namespace for the given application
$env = $container->getParameter('kernel.root_dir').$container->getParameter('kernel.environment');
$hash = hash('sha256', $env);
$namespace = 'sf2'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.$hash;
$env = $container->getParameter('kernel.root_dir').$container->getParameter('kernel.environment');
$hash = hash('sha256', $env);
$namespace = 'sf2'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.$hash;

$cacheDriver['namespace'] = $namespace;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,21 @@ public function providerBasicDrivers()
*/
public function testLoadBasicCacheDriver($class, array $config, array $expectedCalls = array())
{
$container = $this->createContainer();
$cacheName = 'metadata_cache';
$objectManager = array(
'name' => 'default',
$container = $this->createContainer();
$cacheName = 'metadata_cache';
$objectManager = array(
'name' => 'default',
'metadata_cache_driver' => $config,
);

$this->invokeLoadCacheDriver($objectManager, $container, $cacheName);

$this->assertTrue($container->hasDefinition('doctrine.orm.default_metadata_cache'));

$definition = $container->getDefinition('doctrine.orm.default_metadata_cache');
$defCalls = $definition->getMethodCalls();
$definition = $container->getDefinition('doctrine.orm.default_metadata_cache');
$defCalls = $definition->getMethodCalls();
$expectedCalls[] = 'setNamespace';
$actualCalls = array_map(function ($call) {
$actualCalls = array_map(function ($call) {
return $call[0];
}, $defCalls);

Expand All @@ -220,14 +220,14 @@ public function testLoadBasicCacheDriver($class, array $config, array $expectedC

public function testServiceCacheDriver()
{
$cacheName = 'metadata_cache';
$container = $this->createContainer();
$definition = new Definition('%doctrine.orm.cache.apc.class%');
$objectManager = array(
'name' => 'default',
$cacheName = 'metadata_cache';
$container = $this->createContainer();
$definition = new Definition('%doctrine.orm.cache.apc.class%');
$objectManager = array(
'name' => 'default',
'metadata_cache_driver' => array(
'type' => 'service',
'id' => 'service_driver',
'id' => 'service_driver',
),
);

Expand All @@ -244,10 +244,10 @@ public function testServiceCacheDriver()
*/
public function testUnrecognizedCacheDriverException()
{
$cacheName = 'metadata_cache';
$container = $this->createContainer();
$objectManager = array(
'name' => 'default',
$cacheName = 'metadata_cache';
$container = $this->createContainer();
$objectManager = array(
'name' => 'default',
'metadata_cache_driver' => array(
'type' => 'unrecognized_type',
),
Expand All @@ -273,12 +273,12 @@ protected function invokeLoadCacheDriver(array $objectManager, ContainerBuilder
protected function createContainer(array $data = array())
{
return new ContainerBuilder(new ParameterBag(array_merge(array(
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
'kernel.cache_dir' => __DIR__,
'kernel.debug' => false,
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
'kernel.cache_dir' => __DIR__,
'kernel.debug' => false,
'kernel.environment' => 'test',
'kernel.name' => 'kernel',
'kernel.root_dir' => __DIR__,
'kernel.name' => 'kernel',
'kernel.root_dir' => __DIR__,
), $data)));
}
}
8 changes: 4 additions & 4 deletions src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public function format(array $record)
{
if ($record['level'] >= Logger::ERROR) {
$record['start_tag'] = '<error>';
$record['end_tag'] = '</error>';
$record['end_tag'] = '</error>';
} elseif ($record['level'] >= Logger::NOTICE) {
$record['start_tag'] = '<comment>';
$record['end_tag'] = '</comment>';
$record['end_tag'] = '</comment>';
} elseif ($record['level'] >= Logger::INFO) {
$record['start_tag'] = '<info>';
$record['end_tag'] = '</info>';
$record['end_tag'] = '</info>';
} else {
$record['start_tag'] = '';
$record['end_tag'] = '';
$record['end_tag'] = '';
}

return parent::format($record);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
{%- else -%}
{% set form_method = "POST" %}
{%- endif -%}
<form name="{{ form.vars.name }}" method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
<form name="{{ name }}" method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
{%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}" />
{%- endif -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% syntax error
13 changes: 13 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,17 @@ public function getExtractData()
array('{{ "new key" | transchoice(domain="domain", count=1) }}', array('new key' => 'domain')),
);
}

/**
* @expectedException \Twig_Error
* @expectedExceptionMessage Unclosed "block" in "extractor/syntax_error.twig" at line 1
*/
public function testExtractSyntaxError()
{
$twig = new \Twig_Environment(new \Twig_Loader_Array(array()));
$twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));

$extractor = new TwigExtractor($twig);
$extractor->extract(__DIR__.'/../Fixtures', new MessageCatalogue('en'));
}
}
8 changes: 7 additions & 1 deletion src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public function extract($directory, MessageCatalogue $catalogue)
$finder = new Finder();
$files = $finder->files()->name('*.twig')->sortByName()->in($directory);
foreach ($files as $file) {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
try {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
} catch (\Twig_Error $e) {
$e->setTemplateFile($file->getRelativePathname());

throw $e;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ protected function getRouteData(Route $route)
unset($requirements['_scheme'], $requirements['_method']);

return array(
'path' => $route->getPath(),
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
'class' => get_class($route),
'defaults' => $route->getDefaults(),
'path' => $route->getPath(),
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
'class' => get_class($route),
'defaults' => $route->getDefaults(),
'requirements' => $requirements ?: 'NO CUSTOM',
'options' => $route->getOptions(),
'pathRegex' => $route->compile()->getRegex(),
'options' => $route->getOptions(),
'pathRegex' => $route->compile()->getRegex(),
);
}

Expand All @@ -206,11 +206,11 @@ protected function getRouteData(Route $route)
private function getContainerDefinitionData(Definition $definition, $omitTags = false)
{
$data = array(
'class' => (string) $definition->getClass(),
'scope' => $definition->getScope(),
'public' => $definition->isPublic(),
'class' => (string) $definition->getClass(),
'scope' => $definition->getScope(),
'public' => $definition->isPublic(),
'synthetic' => $definition->isSynthetic(),
'file' => $definition->getFile(),
'file' => $definition->getFile(),
);

if (!$omitTags) {
Expand All @@ -236,7 +236,7 @@ private function getContainerAliasData(Alias $alias)
{
return array(
'service' => (string) $alias,
'public' => $alias->isPublic(),
'public' => $alias->isPublic(),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<argument type="service" id="service_container" />
</service>

<service id="session.save_listener" class="Symfony\Component\HttpKernel\EventListener\SaveSessionListener">
<tag name="kernel.event_subscriber" />
</service>

<!-- for BC -->
<service id="session.storage.filesystem" alias="session.storage.mock_file" />
</services>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php $method = strtoupper($method) ?>
<?php $form_method = $method === 'GET' || $method === 'POST' ? $method : 'POST' ?>
<form name="<?php echo $form->vars['name'] ?>" method="<?php echo strtolower($form_method) ?>" action="<?php echo $action ?>"<?php foreach ($attr as $k => $v) { printf(' %s="%s"', $view->escape($k), $view->escape($v)); } ?><?php if ($multipart): ?> enctype="multipart/form-data"<?php endif ?>>
<form name="<?php echo $name ?>" method="<?php echo strtolower($form_method) ?>" action="<?php echo $action ?>"<?php foreach ($attr as $k => $v) { printf(' %s="%s"', $view->escape($k), $view->escape($v)); } ?><?php if ($multipart): ?> enctype="multipart/form-data"<?php endif ?>>
<?php if ($form_method !== $method): ?>
<input type="hidden" name="_method" value="<?php echo $method ?>" />
<?php endif ?>
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ private function getContainerBuilderDescriptionTestData(array $objects)
{
$variations = array(
'services' => array('show_private' => true),
'public' => array('show_private' => false),
'tag1' => array('show_private' => true, 'tag' => 'tag1'),
'tags' => array('group_by' => 'tags', 'show_private' => true),
'public' => array('show_private' => false),
'tag1' => array('show_private' => true, 'tag' => 'tag1'),
'tags' => array('group_by' => 'tags', 'show_private' => true),
);

$data = array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public static function getContainerParameters()
return array(
'parameters_1' => new ParameterBag(array(
'integer' => 12,
'string' => 'Hello world!',
'string' => 'Hello world!',
'boolean' => true,
'array' => array(12, 'Hello world!', true),
'array' => array(12, 'Hello world!', true),
)),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ protected static function getBundleDefaultConfig()
'validation' => array(
'enabled' => false,
'enable_annotations' => false,
'static_method' => array('loadValidatorMetadata'),
'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators',
'strict_email' => false,
'api' => version_compare(PHP_VERSION, '5.3.9', '<') ? '2.4' : '2.5-bc',
'strict_email' => false,
'api' => version_compare(PHP_VERSION, '5.3.9', '<') ? '2.4' : '2.5-bc',
),
'annotations' => array(
'cache' => 'file',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'api' => '2.4',
'enabled' => true,
'api' => '2.4',
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'api' => '2.5',
'enabled' => true,
'api' => '2.5',
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'api' => '2.5-bc',
'enabled' => true,
'api' => '2.5-bc',
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'api' => 'auto',
'enabled' => true,
'api' => 'auto',
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'enabled' => true,
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'static_method' => array('loadFoo', 'loadBar'),
'enabled' => true,
'static_method' => array('loadFoo', 'loadBar'),
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'validation' => array(
'enabled' => true,
'static_method' => false,
'enabled' => true,
'static_method' => false,
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public function testSchemeRedirect()

$this->assertEquals(array(
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction',
'path' => '/foo',
'permanent' => true,
'scheme' => 'https',
'httpPort' => $context->getHttpPort(),
'httpsPort' => $context->getHttpsPort(),
'_route' => 'foo',
'path' => '/foo',
'permanent' => true,
'scheme' => 'https',
'httpPort' => $context->getHttpPort(),
'httpsPort' => $context->getHttpsPort(),
'_route' => 'foo',
),
$matcher->match('/foo')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public function testGetInvalidHelper()
protected function getContainer()
{
$container = new Container();
$session = new Session(new MockArraySessionStorage());
$request = new Request();
$stack = new RequestStack();
$session = new Session(new MockArraySessionStorage());
$request = new Request();
$stack = new RequestStack();
$stack->push($request);

$request->setSession($session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Translator extends BaseTranslator

protected $options = array(
'cache_dir' => null,
'debug' => false,
'debug' => false,
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function addPrefix($prefix, $paths)
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
$this->useIncludePath = (bool) $useIncludePath;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/UniversalClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class UniversalClassLoader
*/
public function useIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
$this->useIncludePath = (bool) $useIncludePath;
}

/**
Expand Down
Loading

0 comments on commit 4982984

Please sign in to comment.