Merge branch '2.7' into 2.8

* 2.7:
  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
  [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:45:55 +01:00
commit 5de9c354dd
8 changed files with 30 additions and 34 deletions

View File

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

View File

@ -15,6 +15,7 @@ Debug::enable();
You can also use the tools individually:
```php
use Symfony\Component\Debug\DebugClassLoader;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\ExceptionHandler;
@ -25,11 +26,9 @@ if ('cli' !== php_sapi_name()) {
ini_set('display_errors', 1);
}
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
and HttpFoundation components.

View File

@ -312,10 +312,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
$service = $this->$method();
} catch (\Exception $e) {
unset($this->loading[$id]);
if (array_key_exists($id, $this->services)) {
unset($this->services[$id]);
}
unset($this->services[$id]);
if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
return;

View File

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

View File

@ -356,21 +356,11 @@ class Form implements \IteratorAggregate, FormInterface
if (!FormUtil::isEmpty($viewData)) {
$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) {
$actualType = is_object($viewData)
? 'an instance of class '.get_class($viewData)
: 'a(n) '.gettype($viewData);
throw new LogicException(
'The form\'s view data is expected to be an instance of class '.
$dataClass.', but is '.$actualType.'. You can avoid this error '.

View File

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

View File

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

View File

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