diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 45bca47798..f310613d10 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -46,8 +46,9 @@ class TranslationUpdateCommand extends ContainerAwareCommand )) ->setDescription('Updates the translation file') ->setHelp(<<<'EOF' -The %command.name% command extract translation strings from templates +The %command.name% 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. diff --git a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php index 3b5156118a..64378336e9 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php @@ -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); } /** diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 108f0402e8..1e3291be7a 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -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; } /**