Merge branch '2.8'

* 2.8:
  Fixed the wrong source name and the ja translation
  [Debug] fix readme: DebugClassLoader moved to debug itself
  [SecurityBundle] disable the init:acl command if ACL is not used
  [DI] remove useless condition around unset
  [Console] Fix bug with  overloading
  [Form] Fixed wrong usages of the "text" type
  [Form] Disabled view data validation if "data_class" is set to null
  [HttpFoundation] Workaround HHVM rewriting HTTP response line
This commit is contained in:
Fabien Potencier 2015-11-27 06:46:53 +01:00
commit 0468f745d8
9 changed files with 37 additions and 38 deletions

View File

@ -74,7 +74,7 @@ EOF
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$output = new SymfonyStyle($input, $output); $output = new SymfonyStyle($input, $cliOutput = $output);
if (!extension_loaded('pcntl')) { if (!extension_loaded('pcntl')) {
$output->error(array( $output->error(array(
@ -85,7 +85,7 @@ EOF
if ($output->ask('Do you want to execute <info>server:run</info> immediately? [Yn] ', true)) { if ($output->ask('Do you want to execute <info>server:run</info> immediately? [Yn] ', true)) {
$command = $this->getApplication()->find('server:run'); $command = $this->getApplication()->find('server:run');
return $command->run($input, $output); return $command->run($input, $cliOutput);
} }
return 1; return 1;

View File

@ -23,6 +23,18 @@ use Doctrine\DBAL\Schema\SchemaException;
*/ */
class InitAclCommand extends ContainerAwareCommand class InitAclCommand extends ContainerAwareCommand
{ {
/**
* {@inheritdoc}
*/
public function isEnabled()
{
if (!$this->getContainer()->has('security.acl.dbal.connection')) {
return false;
}
return parent::isEnabled();
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -15,6 +15,7 @@ Debug::enable();
You can also use the tools individually: You can also use the tools individually:
```php ```php
use Symfony\Component\Debug\DebugClassLoader;
use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\Debug\ExceptionHandler;
@ -25,11 +26,9 @@ if ('cli' !== php_sapi_name()) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
} }
ErrorHandler::register(); ErrorHandler::register();
DebugClassLoader::enable();
``` ```
Note that the `Debug::enable()` call also registers the debug class loader
from the Symfony ClassLoader component when available.
This component can optionally take advantage of the features of the HttpKernel This component can optionally take advantage of the features of the HttpKernel
component. component.

View File

@ -393,9 +393,7 @@ class Definition
*/ */
public function clearTag($name) public function clearTag($name)
{ {
if (isset($this->tags[$name])) { unset($this->tags[$name]);
unset($this->tags[$name]);
}
return $this; return $this;
} }

View File

@ -355,21 +355,11 @@ class Form implements \IteratorAggregate, FormInterface
if (!FormUtil::isEmpty($viewData)) { if (!FormUtil::isEmpty($viewData)) {
$dataClass = $this->config->getDataClass(); $dataClass = $this->config->getDataClass();
$actualType = is_object($viewData) ? 'an instance of class '.get_class($viewData) : 'a(n) '.gettype($viewData);
if (null === $dataClass && is_object($viewData) && !$viewData instanceof \ArrayAccess) {
$expectedType = 'scalar, array or an instance of \ArrayAccess';
throw new LogicException(
'The form\'s view data is expected to be of type '.$expectedType.', '.
'but is '.$actualType.'. You '.
'can avoid this error by setting the "data_class" option to '.
'"'.get_class($viewData).'" or by adding a view transformer '.
'that transforms '.$actualType.' to '.$expectedType.'.'
);
}
if (null !== $dataClass && !$viewData instanceof $dataClass) { if (null !== $dataClass && !$viewData instanceof $dataClass) {
$actualType = is_object($viewData)
? 'an instance of class '.get_class($viewData)
: 'a(n) '.gettype($viewData);
throw new LogicException( throw new LogicException(
'The form\'s view data is expected to be an instance of class '. 'The form\'s view data is expected to be an instance of class '.
$dataClass.', but is '.$actualType.'. You can avoid this error '. $dataClass.', but is '.$actualType.'. You can avoid this error '.
@ -856,7 +846,7 @@ class Form implements \IteratorAggregate, FormInterface
$options['auto_initialize'] = false; $options['auto_initialize'] = false;
if (null === $type && null === $this->config->getDataClass()) { if (null === $type && null === $this->config->getDataClass()) {
$type = 'text'; $type = 'Symfony\Component\Form\Extension\Core\Type\TextType';
} }
if (null === $type) { if (null === $type) {

View File

@ -11,8 +11,8 @@
<target>アップロードされたファイルが大きすぎます。小さなファイルで再度アップロードしてください。</target> <target>アップロードされたファイルが大きすぎます。小さなファイルで再度アップロードしてください。</target>
</trans-unit> </trans-unit>
<trans-unit id="30"> <trans-unit id="30">
<source>The CSRF token is invalid.</source> <source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>CSRFトークンが無効です。</target> <target>CSRFトークンが無効です、再送信してください。</target>
</trans-unit> </trans-unit>
</body> </body>
</file> </file>

View File

@ -172,13 +172,13 @@ class CompoundFormTest extends AbstractFormTest
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createNamed') ->method('createNamed')
->with('foo', 'text', null, array( ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
'bar' => 'baz', 'bar' => 'baz',
'auto_initialize' => false, 'auto_initialize' => false,
)) ))
->will($this->returnValue($child)); ->will($this->returnValue($child));
$this->form->add('foo', 'text', array('bar' => 'baz')); $this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('bar' => 'baz'));
$this->assertTrue($this->form->has('foo')); $this->assertTrue($this->form->has('foo'));
$this->assertSame($this->form, $child->getParent()); $this->assertSame($this->form, $child->getParent());
@ -191,14 +191,14 @@ class CompoundFormTest extends AbstractFormTest
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createNamed') ->method('createNamed')
->with('0', 'text', null, array( ->with('0', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
'bar' => 'baz', 'bar' => 'baz',
'auto_initialize' => false, 'auto_initialize' => false,
)) ))
->will($this->returnValue($child)); ->will($this->returnValue($child));
// in order to make casting unnecessary // in order to make casting unnecessary
$this->form->add(0, 'text', array('bar' => 'baz')); $this->form->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType', array('bar' => 'baz'));
$this->assertTrue($this->form->has(0)); $this->assertTrue($this->form->has(0));
$this->assertSame($this->form, $child->getParent()); $this->assertSame($this->form, $child->getParent());
@ -211,7 +211,7 @@ class CompoundFormTest extends AbstractFormTest
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createNamed') ->method('createNamed')
->with('foo', 'text') ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->will($this->returnValue($child)); ->will($this->returnValue($child));
$this->form->add('foo'); $this->form->add('foo');

View File

@ -829,19 +829,19 @@ class SimpleFormTest extends AbstractFormTest
$this->assertEquals(new PropertyPath('[name]'), $form->getPropertyPath()); $this->assertEquals(new PropertyPath('[name]'), $form->getPropertyPath());
} }
/** public function testViewDataMayBeObjectIfDataClassIsNull()
* @expectedException \Symfony\Component\Form\Exception\LogicException
*/
public function testViewDataMustNotBeObjectIfDataClassIsNull()
{ {
$object = new \stdClass();
$config = new FormConfigBuilder('name', null, $this->dispatcher); $config = new FormConfigBuilder('name', null, $this->dispatcher);
$config->addViewTransformer(new FixedDataTransformer(array( $config->addViewTransformer(new FixedDataTransformer(array(
'' => '', '' => '',
'foo' => new \stdClass(), 'foo' => $object,
))); )));
$form = new Form($config); $form = new Form($config);
$form->setData('foo'); $form->setData('foo');
$this->assertSame($object, $form->getViewData());
} }
public function testViewDataMayBeArrayAccessIfDataClassIsNull() public function testViewDataMayBeArrayAccessIfDataClassIsNull()

View File

@ -329,9 +329,6 @@ class Response
$this->setDate(\DateTime::createFromFormat('U', time())); $this->setDate(\DateTime::createFromFormat('U', time()));
} }
// status
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
// headers // headers
foreach ($this->headers->allPreserveCase() as $name => $values) { foreach ($this->headers->allPreserveCase() as $name => $values) {
foreach ($values as $value) { foreach ($values as $value) {
@ -339,6 +336,9 @@ class Response
} }
} }
// status
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
// cookies // cookies
foreach ($this->headers->getCookies() as $cookie) { foreach ($this->headers->getCookies() as $cookie) {
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());