From 9c87eccf9f8750241d8a22b546496db1a01d6e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 2 Apr 2015 22:29:07 +0200 Subject: [PATCH 01/70] [Serializer] Supports hassers and setters for groups annotations --- .../Serializer/Mapping/Loader/AnnotationLoader.php | 8 ++++---- .../Serializer/Tests/Fixtures/GroupDummy.php | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php index 2db9b9d3d3..801c317767 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/AnnotationLoader.php @@ -54,7 +54,7 @@ class AnnotationLoader implements LoaderInterface $classMetadata->addAttributeMetadata($attributesMetadata[$property->name]); } - if ($property->getDeclaringClass()->name == $className) { + if ($property->getDeclaringClass()->name === $className) { foreach ($this->reader->getPropertyAnnotations($property) as $groups) { if ($groups instanceof Groups) { foreach ($groups->getGroups() as $group) { @@ -68,10 +68,10 @@ class AnnotationLoader implements LoaderInterface } foreach ($reflectionClass->getMethods() as $method) { - if ($method->getDeclaringClass()->name == $className) { + if ($method->getDeclaringClass()->name === $className) { foreach ($this->reader->getMethodAnnotations($method) as $groups) { if ($groups instanceof Groups) { - if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) { + if (preg_match('/^(get|is|has|set)(.+)$/i', $method->name, $matches)) { $attributeName = lcfirst($matches[2]); if (isset($attributesMetadata[$attributeName])) { @@ -85,7 +85,7 @@ class AnnotationLoader implements LoaderInterface $attributeMetadata->addGroup($group); } } else { - throw new MappingException(sprintf('Groups on "%s::%s" cannot be added. Groups can only be added on methods beginning with "get" or "is".', $className, $method->name)); + throw new MappingException(sprintf('Groups on "%s::%s" cannot be added. Groups can only be added on methods beginning with "get", "is", "has" or "set".', $className, $method->name)); } } diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummy.php index 90d45f5b91..0a623d8912 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/GroupDummy.php @@ -22,18 +22,21 @@ class GroupDummy extends GroupDummyParent implements GroupDummyInterface * @Groups({"a"}) */ private $foo; - /** - * @Groups({"b", "c"}) - */ protected $bar; private $fooBar; private $symfony; + /** + * @Groups({"b"}) + */ public function setBar($bar) { $this->bar = $bar; } + /** + * @Groups({"c"}) + */ public function getBar() { return $this->bar; @@ -57,7 +60,7 @@ class GroupDummy extends GroupDummyParent implements GroupDummyInterface /** * @Groups({"a", "b"}) */ - public function getFooBar() + public function isFooBar() { return $this->fooBar; } From c3eecb591df221cc8851217bccc3053d20902a11 Mon Sep 17 00:00:00 2001 From: Baptiste Dupuch Date: Mon, 13 Apr 2015 12:57:04 +0200 Subject: [PATCH 02/70] Add better phpdoc message for getListeners method of the EventDispatcher --- .../Component/EventDispatcher/EventDispatcherInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index efb7c5beca..9d9fc4d44c 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -77,7 +77,7 @@ interface EventDispatcherInterface public function removeSubscriber(EventSubscriberInterface $subscriber); /** - * Gets the listeners of a specific event or all listeners. + * Gets the listeners of a specific event or all listeners sorted by descending priority. * * @param string $eventName The name of the event * From aca1f288435415afbf24cd252cfcf1380728e243 Mon Sep 17 00:00:00 2001 From: Alexander Schwenn Date: Sat, 18 Apr 2015 23:27:35 +0200 Subject: [PATCH 03/70] [FrameworkBundle] Check for 'xlf' instead of 'xliff' There is no translation writer format named 'xliff', but 'xlf' only. So the TranslationUpdateCommand can't be called with 'output-format' == 'xliff' and the version info will never be shown. --- .../Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 8477b120a4..6a9b37227b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -125,7 +125,7 @@ EOF } } - if ($input->getOption('output-format') == 'xliff') { + if ($input->getOption('output-format') == 'xlf') { $output->writeln('Xliff output version is 1.2'); } } From 238589d4e8135f896dd0cbc16fd1853bf6476422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Blaise?= Date: Sun, 19 Apr 2015 18:34:12 +0200 Subject: [PATCH 04/70] Add $objectForMap as argument of Yaml::parse() --- src/Symfony/Component/Yaml/Yaml.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index c9295b094b..e17698a07c 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -41,6 +41,7 @@ class Yaml * @param string $input Path to a YAML file or a string containing YAML * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise * @param bool $objectSupport True if object support is enabled, false otherwise + * @param bool $objectForMap True if maps should return a stdClass instead of array() * * @return array The YAML converted to a PHP array * @@ -50,7 +51,7 @@ class Yaml * * @api */ - public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) + public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false) { // if input is a file, process it $file = ''; @@ -68,7 +69,7 @@ class Yaml $yaml = new Parser(); try { - return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); + return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport, $objectForMap); } catch (ParseException $e) { if ($file) { $e->setParsedFile($file); From 1233baa66987002380e482bb969af12a3b38821d Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Tue, 21 Apr 2015 22:51:01 +0200 Subject: [PATCH 05/70] CS: unalign => --- .../Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php | 2 +- .../SecurityBundle/Tests/Functional/FirewallEntryPointTest.php | 2 +- .../Session/Storage/Handler/MongoDbSessionHandler.php | 2 +- .../Component/Validator/Tests/ConstraintViolationTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php index 3b899131dd..40722c0433 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php @@ -51,7 +51,7 @@ class PhpStringTokenParser { protected static $replacements = array( '\\' => '\\', - '$' => '$', + '$' => '$', 'n' => "\n", 'r' => "\r", 't' => "\t", diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php index 269cea3b72..aab98f273f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php @@ -22,7 +22,7 @@ class FirewallEntryPointTest extends WebTestCase $client->request('GET', '/secure/resource', array(), array(), array( 'PHP_AUTH_USER' => 'unknown', - 'PHP_AUTH_PW' => 'credentials', + 'PHP_AUTH_PW' => 'credentials', )); $this->assertEquals( diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 3876434ebe..cadef07aba 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -155,7 +155,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface public function read($sessionId) { $dbData = $this->getCollection()->findOne(array( - $this->options['id_field'] => $sessionId, + $this->options['id_field'] => $sessionId, $this->options['expiry_field'] => array('$gte' => new \MongoDate()), )); diff --git a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php index 2ceb0169a1..dffc3840c9 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php @@ -40,7 +40,7 @@ EOF; '42 cannot be used here', 'this is the message template', array(), - array('some_value' => 42), + array('some_value' => 42), 'some_value', null ); From 34e000e59a3712ae57d16b116acac147d44cdbf9 Mon Sep 17 00:00:00 2001 From: Diego Saint Esteben Date: Tue, 21 Apr 2015 22:28:59 -0300 Subject: [PATCH 06/70] Show a better error when the port is in use --- .../Command/ServerRunCommand.php | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 462ff09ca5..78468a5b7e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -95,16 +95,29 @@ EOF } $env = $this->getContainer()->getParameter('kernel.environment'); + $address = $input->getArgument('address'); + + if (false === strpos($address, ':')) { + $output->writeln('The address has to be of the form bind-address:port.'); + + return 1; + } + + if ($this->isOtherServerProcessRunning($address)) { + $output->writeln(sprintf('A process is already listening on http://%s.', $address)); + + return 1; + } if ('prod' === $env) { $output->writeln('Running PHP built-in server in production environment is NOT recommended!'); } - if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) { + if (null === $builder = $this->createPhpProcessBuilder($output, $address, $input->getOption('router'), $env)) { return 1; } - $output->writeln(sprintf("Server running on http://%s\n", $input->getArgument('address'))); + $output->writeln(sprintf("Server running on http://%s\n", $address)); $output->writeln('Quit the server with CONTROL-C.'); $builder->setWorkingDirectory($documentRoot); @@ -127,9 +140,24 @@ EOF return $process->getExitCode(); } - private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env) + private function isOtherServerProcessRunning($address) { - $router = $input->getOption('router') ?: $this + list($hostname, $port) = explode(':', $address); + + $fp = @fsockopen($hostname, $port, $errno, $errstr, 5); + + if (false !== $fp) { + fclose($fp); + + return true; + } + + return false; + } + + private function createPhpProcessBuilder(OutputInterface $output, $address, $router, $env) + { + $router = $router ?: $this ->getContainer() ->get('kernel') ->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env)) @@ -150,6 +178,6 @@ EOF return; } - return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router)); + return new ProcessBuilder(array($binary, '-S', $address, $router)); } } From d5742c18b0f80e67669876eb3867f2f1dee9cbb4 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Wed, 22 Apr 2015 09:13:42 +0200 Subject: [PATCH 07/70] CS: unalign = --- .../RememberMe/DoctrineTokenProvider.php | 2 +- .../Twig/TokenParser/TransChoiceTokenParser.php | 2 +- .../Bridge/Twig/TokenParser/TransTokenParser.php | 2 +- .../Bundle/TwigBundle/Command/LintCommand.php | 2 +- src/Symfony/Component/HttpKernel/UriSigner.php | 16 ++++++++-------- src/Symfony/Component/Process/ProcessUtils.php | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index feb170cb72..d078fea14e 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -95,7 +95,7 @@ class DoctrineTokenProvider implements TokenProviderInterface $paramValues = array('value' => $tokenValue, 'lastUsed' => $lastUsed, 'series' => $series,); - $paramTypes = array('value' => \PDO::PARAM_STR, + $paramTypes = array('value' => \PDO::PARAM_STR, 'lastUsed' => DoctrineType::DATETIME, 'series' => \PDO::PARAM_STR,); $updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes); diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php index 1c75d8bb85..e4757d8b9d 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php @@ -56,7 +56,7 @@ class TransChoiceTokenParser extends TransTokenParser if ($stream->test('into')) { // {% transchoice count into "fr" %} $stream->next(); - $locale = $this->parser->getExpressionParser()->parseExpression(); + $locale = $this->parser->getExpressionParser()->parseExpression(); } $stream->expect(\Twig_Token::BLOCK_END_TYPE); diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index 86f9579cf6..96e420e5ce 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -53,7 +53,7 @@ class TransTokenParser extends \Twig_TokenParser if ($stream->test('into')) { // {% trans into "fr" %} $stream->next(); - $locale = $this->parser->getExpressionParser()->parseExpression(); + $locale = $this->parser->getExpressionParser()->parseExpression(); } elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) { throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getFilename()); } diff --git a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php index 308d53b54e..88cbf90401 100644 --- a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php +++ b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php @@ -110,7 +110,7 @@ EOF protected function renderException(OutputInterface $output, $template, \Twig_Error $exception, $file = null) { - $line = $exception->getTemplateLine(); + $line = $exception->getTemplateLine(); $lines = $this->getContext($template, $line); if ($file) { diff --git a/src/Symfony/Component/HttpKernel/UriSigner.php b/src/Symfony/Component/HttpKernel/UriSigner.php index 0f49487f05..d77d27430d 100644 --- a/src/Symfony/Component/HttpKernel/UriSigner.php +++ b/src/Symfony/Component/HttpKernel/UriSigner.php @@ -94,14 +94,14 @@ class UriSigner ksort($params); $url['query'] = http_build_query($params); - $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; - $host = isset($url['host']) ? $url['host'] : ''; - $port = isset($url['port']) ? ':'.$url['port'] : ''; - $user = isset($url['user']) ? $url['user'] : ''; - $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; - $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($url['path']) ? $url['path'] : ''; - $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; + $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; + $host = isset($url['host']) ? $url['host'] : ''; + $port = isset($url['port']) ? ':'.$url['port'] : ''; + $user = isset($url['user']) ? $url['user'] : ''; + $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; + $pass = ($user || $pass) ? "$pass@" : ''; + $path = isset($url['path']) ? $url['path'] : ''; + $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; $fragment = isset($url['fragment']) ? '#'.$url['fragment'] : ''; return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index 748de2371a..ed3dc35032 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -48,7 +48,7 @@ class ProcessUtils } $escapedArgument = ''; - $quote = false; + $quote = false; foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { if ('"' === $part) { $escapedArgument .= '\\"'; From 8b3b3ce18a0566f34c8d11099ef33a13feb40c9e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 22 Apr 2015 16:02:46 +0200 Subject: [PATCH 08/70] [DependencyInjection] resolve circular reference This issue has been fixed in #11422. Due to a bad merge in 3bed1b7988e94a897a64c6a2ad3bf70bde9005c1 it partially appeared again in Symfony 2.6 or higher. --- src/Symfony/Component/DependencyInjection/Container.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index df62b22ff9..60325e75df 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -86,8 +86,6 @@ class Container implements IntrospectableContainerInterface public function __construct(ParameterBagInterface $parameterBag = null) { $this->parameterBag = $parameterBag ?: new ParameterBag(); - - $this->set('service_container', $this); } /** From c3bd418483716f397274d771d2bf30ca89c1371c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 11 Apr 2015 12:32:53 +0200 Subject: [PATCH 09/70] improved exception when missing required component --- .../Component/Translation/Dumper/YamlFileDumper.php | 4 ++++ .../Component/Translation/Loader/CsvFileLoader.php | 5 ++++- .../Component/Translation/Loader/IcuDatFileLoader.php | 5 ++++- .../Component/Translation/Loader/IcuResFileLoader.php | 5 ++++- .../Component/Translation/Loader/IniFileLoader.php | 5 ++++- .../Component/Translation/Loader/MoFileLoader.php | 5 ++++- .../Component/Translation/Loader/PhpFileLoader.php | 5 ++++- .../Component/Translation/Loader/PoFileLoader.php | 5 ++++- .../Component/Translation/Loader/QtFileLoader.php | 5 ++++- .../Component/Translation/Loader/XliffFileLoader.php | 5 ++++- .../Component/Translation/Loader/YamlFileLoader.php | 9 ++++++++- 11 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php index 5920fef20c..870fb98380 100644 --- a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php @@ -26,6 +26,10 @@ class YamlFileDumper extends FileDumper */ protected function format(MessageCatalogue $messages, $domain) { + if (!class_exists('Symfony\Component\Yaml\Yaml')) { + throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); + } + return Yaml::dump($messages->all($domain)); } diff --git a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php index ddcf595baf..fc927601d9 100644 --- a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php @@ -71,7 +71,10 @@ class CsvFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php index a36cd76e71..71ba90a39d 100644 --- a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php @@ -52,7 +52,10 @@ class IcuDatFileLoader extends IcuResFileLoader $messages = $this->flatten($rb); $catalogue = new MessageCatalogue($locale); $catalogue->add($messages, $domain); - $catalogue->addResource(new FileResource($resource.'.dat')); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource.'.dat')); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php index d864c7bd0c..2f8037fb16 100644 --- a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php @@ -52,7 +52,10 @@ class IcuResFileLoader implements LoaderInterface $messages = $this->flatten($rb); $catalogue = new MessageCatalogue($locale); $catalogue->add($messages, $domain); - $catalogue->addResource(new DirectoryResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\DirectoryResource')) { + $catalogue->addResource(new DirectoryResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/IniFileLoader.php b/src/Symfony/Component/Translation/Loader/IniFileLoader.php index 3f01ab4e99..1b3a7b1911 100644 --- a/src/Symfony/Component/Translation/Loader/IniFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IniFileLoader.php @@ -38,7 +38,10 @@ class IniFileLoader extends ArrayLoader $messages = parse_ini_file($resource, true); $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/MoFileLoader.php b/src/Symfony/Component/Translation/Loader/MoFileLoader.php index 9cab3f0d8d..ab4e7a9574 100644 --- a/src/Symfony/Component/Translation/Loader/MoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/MoFileLoader.php @@ -66,7 +66,10 @@ class MoFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php index 1cc9d06d9c..9ce2e7d2fa 100644 --- a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php @@ -42,7 +42,10 @@ class PhpFileLoader extends ArrayLoader $messages = require $resource; $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index 8c8f1a297a..b5d12e9821 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -44,7 +44,10 @@ class PoFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/QtFileLoader.php b/src/Symfony/Component/Translation/Loader/QtFileLoader.php index aacfb4a55e..6dd0696c6f 100644 --- a/src/Symfony/Component/Translation/Loader/QtFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/QtFileLoader.php @@ -68,7 +68,10 @@ class QtFileLoader implements LoaderInterface } $translation = $translation->nextSibling; } - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } } libxml_use_internal_errors($internalErrors); diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 79723f3830..a36217268d 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -69,7 +69,10 @@ class XliffFileLoader implements LoaderInterface $catalogue->set((string) $source, $target, $domain); } - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index e50e0fa385..fb0946cc57 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -43,6 +43,10 @@ class YamlFileLoader extends ArrayLoader throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource)); } + if (!class_exists('Symfony\Component\Yaml\Parser')) { + throw new \LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); + } + if (null === $this->yamlParser) { $this->yamlParser = new YamlParser(); } @@ -64,7 +68,10 @@ class YamlFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } From b62eb73590f77fb7a1a3eb4d5c11dee95c8a4bff Mon Sep 17 00:00:00 2001 From: Restless-ET Date: Wed, 22 Apr 2015 16:50:37 +0100 Subject: [PATCH 10/70] Fix Portuguese (Portugal) translation for Security --- .../Security/Resources/translations/security.pt_PT.xlf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf b/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf index e661000148..f2af13ea3d 100644 --- a/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf +++ b/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf @@ -4,7 +4,7 @@ An authentication exception occurred. - Ocorreu um excepção durante a autenticação. + Ocorreu uma excepção durante a autenticação. Authentication credentials could not be found. @@ -20,7 +20,7 @@ Cookie has already been used by someone else. - Este cookie já esta em uso. + Este cookie já está em uso. Not privileged to request the resource. @@ -64,7 +64,7 @@ Account is locked. - A conta esta trancada. + A conta está trancada. From 7c2b8755e8fdc45fab200131eae762d3bb7d196f Mon Sep 17 00:00:00 2001 From: Per Modin Date: Thu, 23 Apr 2015 00:16:43 +0200 Subject: [PATCH 11/70] [StringUtil] Fixed singularification of 'selfies' --- src/Symfony/Component/PropertyAccess/StringUtil.php | 3 +++ src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php | 1 + 2 files changed, 4 insertions(+) diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index 2160f0f422..2f31925e73 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -60,6 +60,9 @@ class StringUtil // indices (index), appendices (appendix), prices (price) array('seci', 4, false, true, array('ex', 'ix', 'ice')), + // selfies (selfie) + array('seifles', 7, true, true, 'selfie'), + // movies (movie) array('seivom', 6, true, true, 'movie'), diff --git a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php index 73922cd72a..c5691ed7bd 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php @@ -119,6 +119,7 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase array('sandwiches', array('sandwich', 'sandwiche')), array('scarves', array('scarf', 'scarve', 'scarff')), array('schemas', 'schema'), //schemata + array('selfies', 'selfie'), array('sheriffs', 'sheriff'), array('shoes', array('sho', 'shoe')), array('spies', 'spy'), From 2892902ead6bbf6cd26a8f9db731df7803efff4d Mon Sep 17 00:00:00 2001 From: Diego Saint Esteben Date: Thu, 23 Apr 2015 18:00:03 -0300 Subject: [PATCH 12/70] Fixed tests --- .../ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php | 3 --- src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php | 3 --- .../DependencyInjection/Tests/Fixtures/php/services10.php | 3 --- .../DependencyInjection/Tests/Fixtures/php/services11.php | 3 --- .../DependencyInjection/Tests/Fixtures/php/services12.php | 3 --- .../Tests/Fixtures/php/services9_compiled.php | 3 --- 6 files changed, 18 deletions(-) diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php index 457686c80d..cbe96c1d5a 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php @@ -26,9 +26,6 @@ class LazyServiceProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 385400dac6..fd82e6df91 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -839,9 +839,6 @@ EOF; \$this->services = \$this->scopedServices = \$this->scopeStacks = array(); - - \$this->set('service_container', \$this); - EOF; $code .= "\n"; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index a33b08e3ab..457eb3cce6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -29,9 +29,6 @@ class ProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); $this->methodMap = array( diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php index 5a2744f6f7..630d28db06 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php @@ -27,9 +27,6 @@ class ProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); $this->methodMap = array( diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index f7acc1947a..e9bd56e34b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -33,9 +33,6 @@ class ProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); $this->methodMap = array( diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 25b4835058..f4345fe449 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -29,9 +29,6 @@ class ProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); $this->methodMap = array( From faee0d714b611b54e2557ce8c7d25782e413590d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 23 Apr 2015 23:36:48 +0200 Subject: [PATCH 13/70] [Filesystem] deprecate chmod support in dumpFile() The ability to support a custom permission mask in the `dumpFile()` method is deprecated since Symfony Symfony 2.3.12. This commit adds the `trigger_error()` call if a custom permission mask is passed. --- src/Symfony/Component/Filesystem/Filesystem.php | 4 ++++ .../Component/Filesystem/Tests/FilesystemTest.php | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 03f44e6c37..a18a137145 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -480,6 +480,10 @@ class Filesystem $this->rename($tmpFile, $filename, true); if (null !== $mode) { + if (func_num_args() > 2) { + trigger_error('Support for modifying file permissions is deprecated since version 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED); + } + $this->chmod($filename, $mode); } } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 538994a1f5..50f5fa94b2 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -19,7 +19,7 @@ use Symfony\Component\Filesystem\Filesystem; class FilesystemTest extends FilesystemTestCase { /** - * @var \Symfony\Component\Filesystem\Filesystem $filesystem + * @var \Symfony\Component\Filesystem\Filesystem */ private $filesystem = null; @@ -959,6 +959,19 @@ class FilesystemTest extends FilesystemTestCase { $filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt'; + $this->filesystem->dumpFile($filename, 'bar'); + + $this->assertFileExists($filename); + $this->assertSame('bar', file_get_contents($filename)); + } + + /** + * @group legacy + */ + public function testDumpFileAndSetPermissions() + { + $filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt'; + $this->filesystem->dumpFile($filename, 'bar', 0753); $this->assertFileExists($filename); From 8bf855620f959d77ce97b813f485aa9352ef6468 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 24 Apr 2015 12:06:28 +0200 Subject: [PATCH 14/70] [Validator] Fixed Choice when an empty array is used in the "choices" option --- .../Validator/Constraints/ChoiceValidator.php | 2 +- .../Tests/Constraints/ChoiceValidatorTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 0581d7da74..5455b7217f 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -32,7 +32,7 @@ class ChoiceValidator extends ConstraintValidator */ public function validate($value, Constraint $constraint) { - if (!$constraint->choices && !$constraint->callback) { + if (!is_array($constraint->choices) && !$constraint->callback) { throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index 59b9e03f41..f3ccd8ad5f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -143,6 +143,20 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest ->assertRaised(); } + public function testInvalidChoiceEmptyChoices() + { + $constraint = new Choice(array( + 'choices' => array(), + 'message' => 'myMessage', + )); + + $this->validator->validate('baz', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"baz"') + ->assertRaised(); + } + public function testInvalidChoiceMultiple() { $constraint = new Choice(array( From c0300f57d555c5e1e21f6abb65de91a44432d8a9 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 9 Apr 2015 10:44:56 +0200 Subject: [PATCH 15/70] Remaining tweaks for translator tests on 2.7 This are the remaining changes on the 2.7 branch after #14437 merged most of the improvements into 2.6. --- .../Tests/Translation/TranslatorTest.php | 22 +++++++++------- .../Translation/Tests/TranslatorCacheTest.php | 26 +++++++++++++++++++ 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 58f2dea753..c7b61cb881 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Translation; use Symfony\Bundle\FrameworkBundle\Translation\Translator; -use Symfony\Component\Translation\Loader\ArrayLoader; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Translation\MessageSelector; @@ -105,7 +104,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase $translator->trans('foo'); } - public function testLoadRessourcesWithCaching() + public function testLoadResourcesWithCaching() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( @@ -133,7 +132,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase $this->assertEquals('folder', $translator->trans('folder')); } - public function testLoadRessourcesWithoutCaching() + public function testLoadResourcesWithoutCaching() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( @@ -271,17 +270,20 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', ), ); - $catalogueHash = sha1(serialize(array( - 'resources' => array(), - 'fallback_locales' => array(), - ))); // prime the cache $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml'); - - $this->assertFalse(file_exists($this->tmpDir.'/catalogue.fr.'.$catalogueHash.'.php')); + $translator->setLocale('fr'); $translator->warmup($this->tmpDir); - $this->assertTrue(file_exists($this->tmpDir.'/catalogue.fr.'.$catalogueHash.'.php')); + + $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $loader + ->expects($this->never()) + ->method('load'); + + $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml'); + $translator->setLocale('fr'); + $this->assertEquals('répertoire', $translator->trans('folder')); } private function createTranslator($loader, $options, $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $loaderFomat = 'loader') diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 2b6fb0ca03..d5d4639984 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -150,6 +150,32 @@ class TranslatorCacheTest extends \PHPUnit_Framework_TestCase $translator->trans($msgid); } + /** + * @dataProvider runForDebugAndProduction + */ + public function testDifferentTranslatorsForSameLocaleDoNotInterfere($debug) + { + $locale = 'any_locale'; + $format = 'some_format'; + $msgid = 'test'; + + // Create a Translator and prime its cache + $translator = new Translator($locale, null, $this->tmpDir, $debug); + $translator->addLoader($format, new ArrayLoader()); + $translator->addResource($format, array($msgid => 'FAIL'), $locale); + $translator->trans($msgid); + + /* + * Create another Translator with the same locale but a different resource. + * It should not use the first translator's cache but return the value from its own resource. + */ + $translator = new Translator($locale, null, $this->tmpDir, $debug); + $translator->addLoader($format, new ArrayLoader()); + $translator->addResource($format, array($msgid => 'OK'), $locale); + + $this->assertEquals('OK', $translator->trans($msgid), '-> different translators for the same domain interfere in '.($debug ? 'debug' : 'production')); + } + /** * @dataProvider runForDebugAndProduction */ From efb10f641ad88723c7f3814bec3aa01b384c4c66 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Fri, 24 Apr 2015 09:52:20 +0100 Subject: [PATCH 16/70] [FrameworkBundle][Translation] skip warmUp when cache is not used. --- .../Bundle/FrameworkBundle/Translation/Translator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index 0466fafc74..9cc92f9c2d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -77,6 +77,11 @@ class Translator extends BaseTranslator implements WarmableInterface */ public function warmUp($cacheDir) { + // skip warmUp when translator doesn't use cache + if (null === $this->options['cache_dir']) { + return; + } + foreach ($this->resourceLocales as $locale) { $this->loadCatalogue($locale); } From e94b31f3a03edabf6aeee5317aa51475dbcdc90e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 25 Apr 2015 17:02:32 +0200 Subject: [PATCH 17/70] [Debug] PHP7 compatibility with BaseException --- src/Symfony/Component/Debug/ErrorHandler.php | 28 +++++++++--- .../Debug/Exception/FatalBaseException.php | 44 +++++++++++++++++++ .../Debug/Tests/DebugClassLoaderTest.php | 9 +++- .../Debug/Tests/ErrorHandlerTest.php | 4 +- 4 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 src/Symfony/Component/Debug/Exception/FatalBaseException.php diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 7720ad9e73..eed05c191f 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -14,6 +14,7 @@ namespace Symfony\Component\Debug; use Psr\Log\LogLevel; use Psr\Log\LoggerInterface; use Symfony\Component\Debug\Exception\ContextErrorException; +use Symfony\Component\Debug\Exception\FatalBaseException; use Symfony\Component\Debug\Exception\FatalErrorException; use Symfony\Component\Debug\Exception\OutOfMemoryException; use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; @@ -430,22 +431,34 @@ class ErrorHandler /** * Handles an exception by logging then forwarding it to an other handler. * - * @param \Exception $exception An exception to handle - * @param array $error An array as returned by error_get_last() + * @param \Exception|\BaseException $exception An exception to handle + * @param array $error An array as returned by error_get_last() * * @internal */ - public function handleException(\Exception $exception, array $error = null) + public function handleException($exception, array $error = null) { - if ($this->loggedErrors & E_ERROR) { + if (!$exception instanceof \Exception) { + $exception = new FatalBaseException($exception); + } + $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR; + + if ($this->loggedErrors & $type) { $e = array( - 'type' => E_ERROR, + 'type' => $type, 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'level' => error_reporting(), 'stack' => $exception->getTrace(), ); - if ($exception instanceof FatalErrorException) { + if ($exception instanceof FatalBaseException) { + $error = array( + 'type' => $type, + 'message' => $message = $exception->getMessage(), + 'file' => $e['file'], + 'line' => $e['line'], + ); + } elseif ($exception instanceof FatalErrorException) { $message = 'Fatal '.$exception->getMessage(); } elseif ($exception instanceof \ErrorException) { $message = 'Uncaught '.$exception->getMessage(); @@ -475,6 +488,9 @@ class ErrorHandler } catch (\Exception $handlerException) { $this->exceptionHandler = null; $this->handleException($handlerException); + } catch (\BaseException $handlerException) { + $this->exceptionHandler = null; + $this->handleException($handlerException); } } diff --git a/src/Symfony/Component/Debug/Exception/FatalBaseException.php b/src/Symfony/Component/Debug/Exception/FatalBaseException.php new file mode 100644 index 0000000000..769d30ccb1 --- /dev/null +++ b/src/Symfony/Component/Debug/Exception/FatalBaseException.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Base Fatal Error Exception. + * + * @author Nicolas Grekas + */ +class FatalBaseException extends FatalErrorException +{ + public function __construct(\BaseException $e) + { + if ($e instanceof \ParseException) { + $message = 'Parse error: '.$e->getMessage(); + $severity = E_PARSE; + } elseif ($e instanceof \TypeException) { + $message = 'Type error: '.$e->getMessage(); + $severity = E_RECOVERABLE_ERROR; + } else { + $message = 'Fatal error: '.$e->getMessage(); + $severity = E_ERROR; + } + + \ErrorException::__construct( + $message, + $e->getCode(), + $severity, + $e->getFile(), + $e->getLine() + ); + + $this->setTrace($e->getTrace()); + } +} diff --git a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php index efa5d14cc2..169f4210ed 100644 --- a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -104,9 +104,14 @@ class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase // if an exception is thrown, the test passed restore_error_handler(); restore_exception_handler(); - $this->assertEquals(E_STRICT, $exception->getSeverity()); $this->assertStringStartsWith(__FILE__, $exception->getFile()); - $this->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage()); + if (PHP_VERSION_ID < 70000) { + $this->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage()); + $this->assertEquals(E_STRICT, $exception->getSeverity()); + } else { + $this->assertRegexp('/^Warning: Declaration/', $exception->getMessage()); + $this->assertEquals(E_WARNING, $exception->getSeverity()); + } } catch (\Exception $exception) { restore_error_handler(); restore_exception_handler(); diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 0f52680370..1b3f7b41ed 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -336,7 +336,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase $logArgCheck = function ($level, $message, $context) use ($that) { $that->assertEquals('Fatal Parse Error: foo', $message); $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_ERROR); + $that->assertEquals($context['type'], E_PARSE); }; $logger @@ -345,7 +345,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase ->will($this->returnCallback($logArgCheck)) ; - $handler->setDefaultLogger($logger, E_ERROR); + $handler->setDefaultLogger($logger, E_PARSE); $handler->handleFatalError($error); From 74983d7fd7e8383a560b39a4bd2b541f9a0f13ab Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Sun, 26 Apr 2015 17:49:19 -0400 Subject: [PATCH 18/70] Use https://symfony.com/search for searching Using https for symfony.com/search stops chrome (and eventually firefox) from warning us about "Mixed Content" when developing sites that use SSL for the entire site. --- src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig | 2 +- .../WebProfilerBundle/Resources/views/Profiler/header.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig index c63a7e145d..7ae1d42be3 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig @@ -16,7 +16,7 @@