Merge branch '2.3' into 2.7

* 2.3:
  remove unnecessary retrieval and setting of data
  avoid (string) catchable fatal error for __PHP_Incomplete_Class instances
  sendContent return as parent.
  [FrameworkBundle] Fix a typo
This commit is contained in:
Fabien Potencier 2016-02-12 07:23:50 +01:00
commit 4598b74906
3 changed files with 19 additions and 13 deletions

View File

@ -46,8 +46,9 @@ class TranslationUpdateCommand extends ContainerAwareCommand
))
->setDescription('Updates the translation file')
->setHelp(<<<'EOF'
The <info>%command.name%</info> command extract translation strings from templates
The <info>%command.name%</info> command extracts translation strings from templates
of a given bundle or the app folder. It can display them or merge the new ones into the translation files.
When new translation strings are found it can automatically add a prefix to the translation
message.

View File

@ -94,9 +94,10 @@ class CsrfValidationListener implements EventSubscriberInterface
public function preSubmit(FormEvent $event)
{
$form = $event->getForm();
$data = $event->getData();
if ($form->isRoot() && $form->getConfig()->getOption('compound')) {
$data = $event->getData();
if (!isset($data[$this->fieldName]) || !$this->tokenManager->isTokenValid(new CsrfToken($this->tokenId, $data[$this->fieldName]))) {
$errorMessage = $this->errorMessage;
@ -109,10 +110,9 @@ class CsrfValidationListener implements EventSubscriberInterface
if (is_array($data)) {
unset($data[$this->fieldName]);
$event->setData($data);
}
}
$event->setData($data);
}
/**

View File

@ -27,6 +27,9 @@ class BinaryFileResponse extends Response
{
protected static $trustXSendfileTypeHeader = false;
/**
* @var File
*/
protected $file;
protected $offset;
protected $maxlen;
@ -180,7 +183,7 @@ class BinaryFileResponse extends Response
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
}
if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) {
if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) {
$this->setProtocolVersion('1.1');
}
@ -197,17 +200,17 @@ class BinaryFileResponse extends Response
if (false === $path) {
$path = $this->file->getPathname();
}
if (strtolower($type) == 'x-accel-redirect') {
if (strtolower($type) === 'x-accel-redirect') {
// Do X-Accel-Mapping substitutions.
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) {
$mapping = explode('=', $mapping, 2);
if (2 == count($mapping)) {
if (2 === count($mapping)) {
$pathPrefix = trim($mapping[0]);
$location = trim($mapping[1]);
if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) {
if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) {
$path = $location.substr($path, strlen($pathPrefix));
break;
}
@ -218,7 +221,7 @@ class BinaryFileResponse extends Response
$this->maxlen = 0;
} elseif ($request->headers->has('Range')) {
// Process the range headers.
if (!$request->headers->has('If-Range') || $this->getEtag() == $request->headers->get('If-Range')) {
if (!$request->headers->has('If-Range') || $this->getEtag() === $request->headers->get('If-Range')) {
$range = $request->headers->get('Range');
$fileSize = $this->file->getSize();
@ -253,17 +256,17 @@ class BinaryFileResponse extends Response
/**
* Sends the file.
*
* {@inheritdoc}
*/
public function sendContent()
{
if (!$this->isSuccessful()) {
parent::sendContent();
return;
return parent::sendContent();
}
if (0 === $this->maxlen) {
return;
return $this;
}
$out = fopen('php://output', 'wb');
@ -277,6 +280,8 @@ class BinaryFileResponse extends Response
if ($this->deleteFileAfterSend) {
unlink($this->file->getPathname());
}
return $this;
}
/**