Merge branch '2.3' into 2.5

* 2.3:
  enforce memcached version to be 2.1.0
  [FrameworkBundle] improve server:run feedback
  [Form] no need to add the url listener when it does not do anything
  [Form] Fix #11694 - Enforce options value type check in some form types
  Lithuanian security translations
  [Router] Cleanup
  [FrameworkBundle] Fixed ide links
  Add missing argument
  [TwigBundle] do not pass a template reference to twig
  [TwigBundle] show correct fallback exception template in debug mode
  [TwigBundle] remove unused email placeholder from error page
  use meta charset in layouts without legacy http-equiv

Conflicts:
	src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php
	src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig
This commit is contained in:
Fabien Potencier 2014-10-24 07:49:22 +02:00
commit 7b43827b17
28 changed files with 266 additions and 44 deletions

View File

@ -26,7 +26,7 @@ before_install:
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;'
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then pecl install -f memcached-2.1.0; fi;'
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
- sudo locale-gen fr_FR.UTF-8 && sudo update-locale
# - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;'

View File

@ -39,7 +39,7 @@ class YamlExtension extends \Twig_Extension
$dumper = new YamlDumper();
}
return $dumper->dump($input, $inline, false, $dumpObjects);
return $dumper->dump($input, $inline, 0, false, $dumpObjects);
}
public function dump($value, $inline = 0, $dumpObjects = false)

View File

@ -97,6 +97,7 @@ EOF
}
$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);
$builder->setWorkingDirectory($documentRoot);

View File

@ -426,8 +426,8 @@ class FrameworkExtension extends Extension
$links = array(
'textmate' => 'txmt://open?url=file://%%f&line=%%l',
'macvim' => 'mvim://open?url=file://%%f&line=%%l',
'emacs' => 'emacs://open?url=file://%file&line=%line',
'sublime' => 'subl://open?url=file://%file&line=%line',
'emacs' => 'emacs://open?url=file://%%f&line=%%l',
'sublime' => 'subl://open?url=file://%%f&line=%%l',
);
$container->setParameter('templating.helper.code.file_link_format', isset($links[$ide]) ? $links[$ide] : $ide);

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}{% endblock %}
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />

View File

@ -16,6 +16,7 @@ use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Templating\TemplateReferenceInterface;
/**
* ExceptionController.
@ -51,7 +52,7 @@ class ExceptionController
$code = $exception->getStatusCode();
return new Response($this->twig->render(
$this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
(string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
@ -84,7 +85,7 @@ class ExceptionController
* @param int $code An HTTP response status code
* @param bool $debug
*
* @return TemplateReference
* @return TemplateReferenceInterface
*/
protected function findTemplate(Request $request, $format, $code, $debug)
{
@ -110,7 +111,7 @@ class ExceptionController
// default to a generic HTML exception
$request->setRequestFormat('html');
return new TemplateReference('TwigBundle', 'Exception', $name, 'html', 'twig');
return new TemplateReference('TwigBundle', 'Exception', $debug ? 'exception_full' : $name, 'html', 'twig');
}
// to be removed when the minimum required version of Twig is >= 2.0

View File

@ -47,18 +47,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem
*/
public function exists($name)
{
if (parent::exists((string) $name)) {
return true;
}
// same logic as findTemplate below for the fallback
try {
$this->cache[(string) $name] = $this->locator->locate($this->parser->parse($name));
} catch (\Exception $e) {
return false;
}
return true;
return parent::exists((string) $name);
}
/**
@ -92,11 +81,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem
// for BC
try {
$template = $this->parser->parse($template);
try {
$file = $this->locator->locate($template);
} catch (\InvalidArgumentException $e) {
$previous = $e;
}
$file = $this->locator->locate($template);
} catch (\Exception $e) {
$previous = $e;
}

View File

@ -1 +1 @@
{% include 'TwigBundle:Exception:error.xml.twig' with { 'exception': exception } %}
{% include 'TwigBundle:Exception:error.xml.twig' %}

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="UTF-8" />
<title>An Error Occurred: {{ status_text }}</title>
</head>
<body>
@ -9,9 +9,8 @@
<h2>The server returned a "{{ status_code }} {{ status_text }}".</h2>
<div>
Something is broken. Please e-mail us at [email] and let us know
what you were doing when this error occurred. We will fix it as soon
as possible. Sorry for any inconvenience caused.
Something is broken. Please let us know what you were doing when this error occurred.
We will fix it as soon as possible. Sorry for any inconvenience caused.
</div>
</body>
</html>

View File

@ -1 +1 @@
{% include 'TwigBundle:Exception:error.xml.twig' with { 'exception': exception } %}
{% include 'TwigBundle:Exception:error.xml.twig' %}

View File

@ -3,6 +3,5 @@ Oops! An Error Occurred
The server returned a "{{ status_code }} {{ status_text }}".
Please e-mail us at [email] and let us know what you were doing when this
error occurred. We will fix it as soon as possible. Sorry for any
inconvenience caused.
Something is broken. Please let us know what you were doing when this error occurred.
We will fix it as soon as possible. Sorry for any inconvenience caused.

View File

@ -1,11 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={{ _charset }}"/>
<meta charset="{{ _charset }}" />
<meta name="robots" content="noindex,nofollow" />
<title>{% block title %}{% endblock %}</title>
<link href="{{ asset('bundles/framework/css/structure.css', absolute=true) }}" rel="stylesheet" type="text/css" media="all" />
<link href="{{ asset('bundles/framework/css/body.css', absolute=true) }}" rel="stylesheet" type="text/css" media="all" />
<link href="{{ asset('bundles/framework/css/structure.css', absolute=true) }}" rel="stylesheet" />
<link href="{{ asset('bundles/framework/css/body.css', absolute=true) }}" rel="stylesheet" />
{% block head %}{% endblock %}
</head>
<body>

View File

@ -321,7 +321,7 @@ EOF;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta charset="UTF-8" />
<meta name="robots" content="noindex,nofollow" />
<style>
/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */

View File

@ -24,6 +24,11 @@ class FixUrlProtocolListener implements EventSubscriberInterface
{
private $defaultProtocol;
/**
* Constructor.
*
* @param string|null $defaultProtocol The URL scheme to add when there is none or null to not modify the data
*/
public function __construct($defaultProtocol = 'http')
{
$this->defaultProtocol = $defaultProtocol;

View File

@ -24,6 +24,10 @@ class BirthdayType extends AbstractType
$resolver->setDefaults(array(
'years' => range(date('Y') - 120, date('Y')),
));
$resolver->setAllowedTypes(array(
'years' => 'array',
));
}
/**

View File

@ -237,6 +237,9 @@ class DateType extends AbstractType
$resolver->setAllowedTypes(array(
'format' => array('int', 'string'),
'years' => 'array',
'months' => 'array',
'days' => 'array',
));
}

View File

@ -55,6 +55,12 @@ class RepeatedType extends AbstractType
'second_name' => 'second',
'error_bubbling' => false,
));
$resolver->setAllowedTypes(array(
'options' => 'array',
'first_options' => 'array',
'second_options' => 'array',
));
}
/**

View File

@ -221,6 +221,12 @@ class TimeType extends AbstractType
'choice',
),
));
$resolver->setAllowedTypes(array(
'hours' => 'array',
'minutes' => 'array',
'seconds' => 'array',
));
}
/**

View File

@ -23,7 +23,9 @@ class UrlType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(new FixUrlProtocolListener($options['default_protocol']));
if (null !== $options['default_protocol']) {
$builder->addEventSubscriber(new FixUrlProtocolListener($options['default_protocol']));
}
}
/**
@ -34,6 +36,10 @@ class UrlType extends AbstractType
$resolver->setDefaults(array(
'default_protocol' => 'http',
));
$resolver->setAllowedTypes(array(
'default_protocol' => array('null', 'string'),
));
}
/**

View File

@ -0,0 +1,33 @@
<?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\Component\Form\Tests\Extension\Core\Type;
/**
* @author Stepan Anchugov <kixxx1@gmail.com>
*/
class BirthdayTypeTest extends BaseTypeTest
{
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testSetInvalidYearsOption()
{
$this->factory->create('birthday', null, array(
'years' => 'bad value',
));
}
protected function getTestedType()
{
return 'birthday';
}
}

View File

@ -340,6 +340,36 @@ class DateTypeTest extends TypeTestCase
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfYearsIsInvalid()
{
$this->factory->create('date', null, array(
'years' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfMonthsIsInvalid()
{
$this->factory->create('date', null, array(
'months' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfDaysIsInvalid()
{
$this->factory->create('date', null, array(
'days' => 'bad value',
));
}
public function testSetDataWithDifferentTimezones()
{
$form = $this->factory->create('date', null, array(

View File

@ -72,6 +72,39 @@ class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
$this->assertFalse($form['second']->isRequired());
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testSetInvalidOptions()
{
$this->factory->create('repeated', null, array(
'type' => 'text',
'options' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testSetInvalidFirstOptions()
{
$this->factory->create('repeated', null, array(
'type' => 'text',
'first_options' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testSetInvalidSecondOptions()
{
$this->factory->create('repeated', null, array(
'type' => 'text',
'second_options' => 'bad value',
));
}
public function testSetErrorBubblingToTrue()
{
$form = $this->factory->create('repeated', null, array(

View File

@ -673,4 +673,34 @@ class TimeTypeTest extends TypeTestCase
'with_seconds' => true,
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfHoursIsInvalid()
{
$this->factory->create('time', null, array(
'hours' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfMinutesIsInvalid()
{
$this->factory->create('time', null, array(
'minutes' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfSecondsIsInvalid()
{
$this->factory->create('time', null, array(
'seconds' => 'bad value',
));
}
}

View File

@ -70,4 +70,14 @@ class UrlTypeTest extends TypeTestCase
$this->assertSame('www.domain.com', $form->getData());
$this->assertSame('www.domain.com', $form->getViewData());
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfDefaultProtocolIsInvalid()
{
$this->factory->create('url', null, array(
'default_protocol' => array(),
));
}
}

View File

@ -89,7 +89,7 @@ class RedirectResponse extends Response
sprintf('<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="1;url=%1$s" />
<title>Redirecting to %1$s</title>

View File

@ -31,6 +31,10 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Skipped tests Memcached class is not present');
}
if (version_compare(phpversion('memcached'), '2.2.0', '>=')) {
$this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower');
}
$this->memcached = $this->getMock('Memcached');
$this->storage = new MemcachedSessionHandler(
$this->memcached,

View File

@ -37,12 +37,8 @@ class RouteCompiler implements RouteCompilerInterface
*/
public static function compile(Route $route)
{
$staticPrefix = null;
$hostVariables = array();
$pathVariables = array();
$variables = array();
$tokens = array();
$regex = null;
$hostRegex = null;
$hostTokens = array();

View File

@ -0,0 +1,71 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>An authentication exception occurred.</source>
<target>Įvyko autentifikacijos klaida.</target>
</trans-unit>
<trans-unit id="2">
<source>Authentication credentials could not be found.</source>
<target>Nepavyko rasti autentifikacijos duomneų.</target>
</trans-unit>
<trans-unit id="3">
<source>Authentication request could not be processed due to a system problem.</source>
<target>Autentifikacijos užklausos nepavyko įvykdyti dėl sistemos klaidų.</target>
</trans-unit>
<trans-unit id="4">
<source>Invalid credentials.</source>
<target>Klaidingi duomenys.</target>
</trans-unit>
<trans-unit id="5">
<source>Cookie has already been used by someone else.</source>
<target>Slapukas buvo panaudotas kažkam kitam.</target>
</trans-unit>
<trans-unit id="6">
<source>Not privileged to request the resource.</source>
<target>Neturite teisių pasiektį resursą.</target>
</trans-unit>
<trans-unit id="7">
<source>Invalid CSRF token.</source>
<target>Neteisingas CSRF raktas.</target>
</trans-unit>
<trans-unit id="8">
<source>Digest nonce has expired.</source>
<target>Prieigos kodas yra pasibaigęs.</target>
</trans-unit>
<trans-unit id="9">
<source>No authentication provider found to support the authentication token.</source>
<target>Nerastas autentifikacijos tiekėjas, kuris palaikytų autentifikacijos raktą.</target>
</trans-unit>
<trans-unit id="10">
<source>No session available, it either timed out or cookies are not enabled.</source>
<target>Sesija yra nepasiekiama, pasibaigė galiojimo laikas arba slapukai yra išjungti.</target>
</trans-unit>
<trans-unit id="11">
<source>No token could be found.</source>
<target>Nepavyko rasti rakto.</target>
</trans-unit>
<trans-unit id="12">
<source>Username could not be found.</source>
<target>Tokio naudotojo vardo nepavyko rasti.</target>
</trans-unit>
<trans-unit id="13">
<source>Account has expired.</source>
<target>Paskyros galiojimo laikas baigėsi.</target>
</trans-unit>
<trans-unit id="14">
<source>Credentials have expired.</source>
<target>Autentifikacijos duomenų galiojimo laikas baigėsi.</target>
</trans-unit>
<trans-unit id="15">
<source>Account is disabled.</source>
<target>Paskyra yra išjungta.</target>
</trans-unit>
<trans-unit id="16">
<source>Account is locked.</source>
<target>Paskyra yra užblokuota.</target>
</trans-unit>
</body>
</file>
</xliff>