From 70f2b3eb8c538dea6130959353e94a4017dde1cc Mon Sep 17 00:00:00 2001 From: spdionis Date: Tue, 18 Nov 2014 02:17:03 +0200 Subject: [PATCH 01/13] global commands are always first in command list --- .../Descriptor/ApplicationDescription.php | 8 +++-- .../Console/Tests/Command/ListCommandTest.php | 32 +++++++++++++++++++ .../Console/Tests/Fixtures/Foo6Command.php | 13 ++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index 81aa1b0e27..511921cb24 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -134,15 +134,17 @@ class ApplicationDescription private function sortCommands(array $commands) { $namespacedCommands = array(); + $globalCommands = array(); foreach ($commands as $name => $command) { $key = $this->application->extractNamespace($name, 1); if (!$key) { - $key = '_global'; + $globalCommands['_global'][$name] = $command; + } else { + $namespacedCommands[$key][$name] = $command; } - - $namespacedCommands[$key][$name] = $command; } ksort($namespacedCommands); + $namespacedCommands = array_merge($globalCommands, $namespacedCommands); foreach ($namespacedCommands as &$commandsSet) { ksort($commandsSet); diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index fbb9feeb68..cfc1b99dd3 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -61,4 +61,36 @@ EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); } + + public function testExecuteListsCommandsNameAndNamespaceRaw() + { + require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php'); + $application = new Application(); + $application->add(new \Foo6Command()); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName())); + $output = <<foo + foo:bar +EOF; + + $this->assertEquals($output, trim($commandTester->getDisplay(true))); + } } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php new file mode 100644 index 0000000000..20ec2679b7 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php @@ -0,0 +1,13 @@ +setName('foo:bar'); + } + +} From 2984f8ed605c4bbdce9411e3ad6d86400df236c2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Oct 2015 15:59:28 +0200 Subject: [PATCH 02/13] fixed previous commit --- .../Console/Tests/Command/ListCommandTest.php | 44 +++++++++++++------ .../Console/Tests/Fixtures/Foo6Command.php | 3 +- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index cfc1b99dd3..d5b5bfbdbb 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -62,33 +62,49 @@ EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); } - public function testExecuteListsCommandsNameAndNamespaceRaw() + public function testExecuteListsCommandsOrder() { require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php'); $application = new Application(); $application->add(new \Foo6Command()); $commandTester = new CommandTester($command = $application->get('list')); - $commandTester->execute(array('command' => $command->getName())); + $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); $output = <<foo - foo:bar + help Displays help for a command + list Lists commands +0foo + 0foo:bar 0foo:bar command +EOF; + + $this->assertEquals($output, trim($commandTester->getDisplay(true))); + } + + public function testExecuteListsCommandsOrderRaw() + { + require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php'); + $application = new Application(); + $application->add(new \Foo6Command()); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); + $output = <<assertEquals($output, trim($commandTester->getDisplay(true))); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php index 20ec2679b7..6ae987e484 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php @@ -7,7 +7,6 @@ class Foo6Command extends Command { protected function configure() { - $this->setName('foo:bar'); + $this->setName('0foo:bar')->setDescription('0foo:bar command'); } - } From a25beb623d02dafea8203e773a35fbcd901343eb Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Oct 2015 19:32:31 +0200 Subject: [PATCH 03/13] Fix docblocks about callables --- .../Component/Finder/Iterator/CustomFilterIterator.php | 4 ++-- .../Component/HttpKernel/Controller/ControllerResolver.php | 2 +- .../Component/HttpKernel/Event/FilterControllerEvent.php | 2 -- src/Symfony/Component/Process/Process.php | 2 +- src/Symfony/Component/Templating/PhpEngine.php | 6 +++--- src/Symfony/Component/Translation/PluralizationRules.php | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php index 24b15d97ad..b43b88d98d 100644 --- a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php @@ -26,8 +26,8 @@ class CustomFilterIterator extends FilterIterator /** * Constructor. * - * @param \Iterator $iterator The Iterator to filter - * @param array $filters An array of PHP callbacks + * @param \Iterator $iterator The Iterator to filter + * @param callable[] $filters An array of PHP callbacks * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index d3bc6ad2e8..fbdc993036 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -145,7 +145,7 @@ class ControllerResolver implements ControllerResolverInterface * * @param string $controller A Controller string * - * @return mixed A PHP callable + * @return callable A PHP callable * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php index b61999cd6d..77a5c1a2ad 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php @@ -29,8 +29,6 @@ class FilterControllerEvent extends KernelEvent { /** * The current controller. - * - * @var callable */ private $controller; diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index ec5d211e40..64f6d15cb9 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1015,7 +1015,7 @@ class Process * * @param callback|null $callback The user defined PHP callback * - * @return callback A PHP callable + * @return \Closure A PHP closure */ protected function buildCallback($callback) { diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 93da75bf35..bf3261b18e 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -354,8 +354,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess /** * Adds an escaper for the given context. * - * @param string $context The escaper context (html, js, ...) - * @param mixed $escaper A PHP callable + * @param string $context The escaper context (html, js, ...) + * @param callable $escaper A PHP callable */ public function setEscaper($context, $escaper) { @@ -368,7 +368,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess * * @param string $context The context name * - * @return mixed $escaper A PHP callable + * @return callable $escaper A PHP callable * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/Translation/PluralizationRules.php b/src/Symfony/Component/Translation/PluralizationRules.php index 4264e5c802..6d91da7fc6 100644 --- a/src/Symfony/Component/Translation/PluralizationRules.php +++ b/src/Symfony/Component/Translation/PluralizationRules.php @@ -190,8 +190,8 @@ class PluralizationRules /** * Overrides the default plural rule for a given locale. * - * @param string $rule A PHP callable - * @param string $locale The locale + * @param callable $rule A PHP callable + * @param string $locale The locale * * @throws \LogicException */ From 1ecbc672387c5a8101c86919eda9711eb2b6516c Mon Sep 17 00:00:00 2001 From: ogizanagi Date: Mon, 5 Oct 2015 19:46:50 +0200 Subject: [PATCH 04/13] [SecurityBundle] Remove duplicated require-dev --- src/Symfony/Bundle/SecurityBundle/composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index d135a9f96e..1ceb4ed0eb 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -32,7 +32,6 @@ "symfony/http-foundation": "~2.3", "symfony/twig-bundle": "~2.2", "symfony/twig-bridge": "~2.2,>=2.2.6", - "symfony/form": "~2.3", "symfony/process": "~2.0,>=2.0.5", "symfony/validator": "~2.2", "symfony/yaml": "~2.0,>=2.0.5", From 7bc836cc723aec221c733dd119e328c7b58d60bf Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 5 Oct 2015 23:04:03 +0200 Subject: [PATCH 05/13] compatibility with Security component split The FrameworkBundle in version 2.3 can be used with recent versions of the Security component. However, after the Security component has been split with Symfony 2.4, translations resources have been moved to the `symfony/security-core` package. Thus, the changed location must be taken into account. --- .../DependencyInjection/FrameworkExtension.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index c6801f56e2..1129dfe1f4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -553,7 +553,16 @@ class FrameworkExtension extends Extension if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); - $dirs[] = dirname($r->getFilename()).'/../../Resources/translations'; + $legacyTranslationsDir = dirname($r->getFilename()).'/../../Resources/translations'; + + if (file_exists($legacyTranslationsDir)) { + // in Symfony 2.3, translations are located in the symfony/security package + $dirs[] = $legacyTranslationsDir; + } else { + // with Symfony 2.4, the Security component was split into several subpackages + // and the translations have been moved to the symfony/security-core package + $dirs[] = dirname($r->getFilename()).'/../Resources/translations'; + } } $overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations'; foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { From 7b12fe982b2aefef25410a0845db48d4aaaba390 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Oct 2015 19:39:38 +0200 Subject: [PATCH 06/13] [2.7] Fix docblocks about callables --- src/Symfony/Bridge/Twig/Command/DebugCommand.php | 2 +- .../Bundle/FrameworkBundle/Resources/config/debug_prod.xml | 2 +- src/Symfony/Component/Console/Question/Question.php | 4 ++-- .../Component/Serializer/Normalizer/AbstractNormalizer.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index dea7c4834e..4bf52c5dd3 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -150,7 +150,7 @@ EOF return; } $refl = new \ReflectionMethod($cb[0], $cb[1]); - } elseif (is_object($cb) && is_callable($cb)) { + } elseif (is_object($cb) && method_exists($cb, '__invoke')) { $refl = new \ReflectionMethod($cb, '__invoke'); } elseif (function_exists($cb)) { $refl = new \ReflectionFunction($cb); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml index 9d70124fbe..36347eccb2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml @@ -14,7 +14,7 @@ - + null null null diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 01702b208f..ffe9417117 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -217,7 +217,7 @@ class Question * * The normalizer can be a callable (a string), a closure or a class implementing __invoke. * - * @param string|\Closure $normalizer + * @param callable $normalizer * * @return Question The current instance */ @@ -233,7 +233,7 @@ class Question * * The normalizer can ba a callable (a string), a closure or a class implementing __invoke. * - * @return string|\Closure + * @return callable */ public function getNormalizer() { diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 8cc85e5b61..55c60c0f95 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -105,7 +105,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N /** * Set normalization callbacks. * - * @param array $callbacks help normalize the result + * @param callable[] $callbacks help normalize the result * * @return self * From 742547c099910f162f11fbc54c0f3db5f89b6ecd Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Oct 2015 08:51:57 +0200 Subject: [PATCH 07/13] [Security\Core] Fix test failure after sebastianbergmann/phpunit#1821 --- .../Tests/Core/Authorization/AccessDecisionManagerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php index b416e9577c..5341baf95d 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php @@ -96,7 +96,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase protected function getVoterFor2Roles($token, $vote1, $vote2) { $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); - $voter->expects($this->exactly(2)) + $voter->expects($this->any()) ->method('vote') ->will($this->returnValueMap(array( array($token, null, array('ROLE_FOO'), $vote1), From f37ceef819ab87d3cab414caaa16d95c0910f01d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Oct 2015 10:41:18 +0200 Subject: [PATCH 08/13] [FrameworkBundle] Fix translations dir discovery --- .../DependencyInjection/FrameworkExtension.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 1129dfe1f4..ba4ac6b949 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -553,16 +553,16 @@ class FrameworkExtension extends Extension if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); - $legacyTranslationsDir = dirname($r->getFilename()).'/../../Resources/translations'; + // with Symfony 2.4, the Security component was split into several subpackages + // and the translations have been moved to the symfony/security-core package + $translationsDir = dirname($r->getFilename()).'/../Resources/translations'; - if (file_exists($legacyTranslationsDir)) { + if (!file_exists($translationsDir) && file_exists($dir = dirname($r->getFilename()).'/../../Resources/translations')) { // in Symfony 2.3, translations are located in the symfony/security package - $dirs[] = $legacyTranslationsDir; - } else { - // with Symfony 2.4, the Security component was split into several subpackages - // and the translations have been moved to the symfony/security-core package - $dirs[] = dirname($r->getFilename()).'/../Resources/translations'; + $translationsDir = $dir; } + + $dirs[] = $translationsDir; } $overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations'; foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { From 8d3bf0348e9a344fdb14f1b1f595409cb2850a5e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Oct 2015 10:54:15 +0200 Subject: [PATCH 09/13] [Console] Fix merge --- .../Console/Tests/Command/ListCommandTest.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index c73f292939..36d2380602 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -76,19 +76,19 @@ Usage: command [options] [arguments] Options: - --help -h Display this help message - --quiet -q Do not output any message - --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug - --version -V Display this application version - --ansi Force ANSI output - --no-ansi Disable ANSI output - --no-interaction -n Do not ask any interactive question + -h, --help Display this help message + -q, --quiet Do not output any message + -V, --version Display this application version + --ansi Force ANSI output + --no-ansi Disable ANSI output + -n, --no-interaction Do not ask any interactive question + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: - help Displays help for a command - list Lists commands -0foo - 0foo:bar 0foo:bar command + help Displays help for a command + list Lists commands + 0foo + 0foo:bar 0foo:bar command EOF; $this->assertEquals($output, trim($commandTester->getDisplay(true))); From 1ed07a09d89318ec46c7d4c335ccfa0fbe61af3f Mon Sep 17 00:00:00 2001 From: "maxime.steinhausser" Date: Tue, 6 Oct 2015 11:27:38 +0200 Subject: [PATCH 10/13] [FrameworkBundle] [Security] Remove trans from the security/core in 2.3 & dir loading --- .../FrameworkExtension.php | 14 ++-- .../Resources/translations/security.az.xlf | 71 ------------------- .../Resources/translations/security.he.xlf | 71 ------------------- 3 files changed, 6 insertions(+), 150 deletions(-) delete mode 100644 src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf delete mode 100644 src/Symfony/Component/Security/Core/Resources/translations/security.he.xlf diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index ba4ac6b949..76264b3c0e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -553,16 +553,14 @@ class FrameworkExtension extends Extension if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); - // with Symfony 2.4, the Security component was split into several subpackages - // and the translations have been moved to the symfony/security-core package - $translationsDir = dirname($r->getFilename()).'/../Resources/translations'; - - if (!file_exists($translationsDir) && file_exists($dir = dirname($r->getFilename()).'/../../Resources/translations')) { + if (file_exists(dirname($r->getFilename()).'/../composer.json')) { + // with Symfony 2.4, the Security component was split into several subpackages + // and the translations have been moved to the symfony/security-core package + $dirs[] = dirname($r->getFilename()).'/../Resources/translations'; + } else { // in Symfony 2.3, translations are located in the symfony/security package - $translationsDir = $dir; + $dirs[] = dirname($r->getFilename()).'/../../Resources/translations'; } - - $dirs[] = $translationsDir; } $overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations'; foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf deleted file mode 100644 index a974ed0f02..0000000000 --- a/src/Symfony/Component/Security/Core/Resources/translations/security.az.xlf +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - An authentication exception occurred. - Doğrulama istisnası baş verdi. - - - Authentication credentials could not be found. - Doğrulama məlumatları tapılmadı. - - - Authentication request could not be processed due to a system problem. - Sistem xətası səbəbilə doğrulama istəyi emal edilə bilmədi. - - - Invalid credentials. - Yanlış məlumat. - - - Cookie has already been used by someone else. - Kuki başqası tərəfindən istifadə edilib. - - - Not privileged to request the resource. - Resurs istəyi üçün imtiyaz yoxdur. - - - Invalid CSRF token. - Yanlış CSRF nişanı. - - - Digest nonce has expired. - Dərləmə istifadə müddəti bitib. - - - No authentication provider found to support the authentication token. - Doğrulama nişanını dəstəkləyəcək provayder tapılmadı. - - - No session available, it either timed out or cookies are not enabled. - Uyğun seans yoxdur, vaxtı keçib və ya kuki aktiv deyil. - - - No token could be found. - Nişan tapılmadı. - - - Username could not be found. - İstifadəçi adı tapılmadı. - - - Account has expired. - Hesabın istifadə müddəti bitib. - - - Credentials have expired. - Məlumatların istifadə müddəti bitib. - - - Account is disabled. - Hesab qeyri-aktiv edilib. - - - Account is locked. - Hesab kilitlənib. - - - - diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.he.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.he.xlf deleted file mode 100644 index 3640698ce9..0000000000 --- a/src/Symfony/Component/Security/Core/Resources/translations/security.he.xlf +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - An authentication exception occurred. - An authentication exception occurred. - - - Authentication credentials could not be found. - Authentication credentials could not be found. - - - Authentication request could not be processed due to a system problem. - Authentication request could not be processed due to a system problem. - - - Invalid credentials. - Invalid credentials. - - - Cookie has already been used by someone else. - Cookie has already been used by someone else. - - - Not privileged to request the resource. - Not privileged to request the resource. - - - Invalid CSRF token. - Invalid CSRF token. - - - Digest nonce has expired. - Digest nonce has expired. - - - No authentication provider found to support the authentication token. - No authentication provider found to support the authentication token. - - - No session available, it either timed out or cookies are not enabled. - No session available, it either timed out or cookies are not enabled. - - - No token could be found. - No token could be found. - - - Username could not be found. - Username could not be found. - - - Account has expired. - Account has expired. - - - Credentials have expired. - Credentials have expired. - - - Account is disabled. - Account is disabled. - - - Account is locked. - Account is locked. - - - - From 26ca3dc6c229b9ab089da1fba1ab18ecf7612dd2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Oct 2015 15:19:40 +0200 Subject: [PATCH 11/13] [FrameworkBundle] Fix deps=low/high tests --- .../DependencyInjection/FrameworkExtension.php | 16 ++++++++-------- .../FrameworkExtensionTest.php | 6 +++++- .../Security/Tests/Core/SecurityContextTest.php | 5 +++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 76264b3c0e..de97b1f44c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -543,29 +543,29 @@ class FrameworkExtension extends Extension if (class_exists('Symfony\Component\Validator\Validator')) { $r = new \ReflectionClass('Symfony\Component\Validator\Validator'); - $dirs[] = dirname($r->getFilename()).'/Resources/translations'; + $dirs[] = dirname($r->getFileName()).'/Resources/translations'; } if (class_exists('Symfony\Component\Form\Form')) { $r = new \ReflectionClass('Symfony\Component\Form\Form'); - $dirs[] = dirname($r->getFilename()).'/Resources/translations'; + $dirs[] = dirname($r->getFileName()).'/Resources/translations'; } if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); - if (file_exists(dirname($r->getFilename()).'/../composer.json')) { + if (file_exists(dirname($r->getFileName()).'/../composer.json')) { // with Symfony 2.4, the Security component was split into several subpackages // and the translations have been moved to the symfony/security-core package - $dirs[] = dirname($r->getFilename()).'/../Resources/translations'; + $dirs[] = dirname($r->getFileName()).'/../Resources/translations'; } else { // in Symfony 2.3, translations are located in the symfony/security package - $dirs[] = dirname($r->getFilename()).'/../../Resources/translations'; + $dirs[] = dirname($r->getFileName()).'/../../Resources/translations'; } } $overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations'; foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { $reflection = new \ReflectionClass($class); - if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/translations')) { + if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) { $dirs[] = $dir; } if (is_dir($dir = sprintf($overridePath, $bundle))) { @@ -645,7 +645,7 @@ class FrameworkExtension extends Extension foreach ($container->getParameter('kernel.bundles') as $bundle) { $reflection = new \ReflectionClass($bundle); - if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.xml')) { + if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.xml')) { $files[] = realpath($file); $container->addResource(new FileResource($file)); } @@ -660,7 +660,7 @@ class FrameworkExtension extends Extension foreach ($container->getParameter('kernel.bundles') as $bundle) { $reflection = new \ReflectionClass($bundle); - if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.yml')) { + if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.yml')) { $files[] = realpath($file); $container->addResource(new FileResource($file)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 67d57e9254..33b5fa7f34 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -196,8 +196,12 @@ abstract class FrameworkExtensionTest extends TestCase '->registerTranslatorConfiguration() finds Form translation resources' ); $ref = new \ReflectionClass('Symfony\Component\Security\Core\SecurityContext'); + $ref = dirname($ref->getFileName()); + if (!file_exists($ref.'/composer.json')) { + $ref = dirname($ref); + } $this->assertContains( - strtr(dirname(dirname($ref->getFileName())).'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR), + strtr($ref.'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Security translation resources' ); diff --git a/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php b/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php index 124ebf9f44..66958892d3 100644 --- a/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php +++ b/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php @@ -89,4 +89,9 @@ class SecurityContextTest extends \PHPUnit_Framework_TestCase $context->setToken($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); $this->assertSame($token, $context->getToken()); } + + public function testTranslationsAreNotInCore() + { + $this->assertFalse(file_exists(__DIR__.'/../../Core/Resources/translations/')); + } } From e8f0e5afd854a13842c3e4bd2cf9f38d9f39c1f7 Mon Sep 17 00:00:00 2001 From: Klaas Cuvelier Date: Tue, 28 Apr 2015 09:07:44 +0200 Subject: [PATCH 12/13] [2.3][SECURITY] Add remember me cookie configuration --- .../Http/RememberMe/AbstractRememberMeServices.php | 7 +++++-- .../Http/RememberMe/AbstractRememberMeServicesTest.php | 10 ---------- .../PersistentTokenBasedRememberMeServicesTest.php | 7 ------- .../RememberMe/TokenBasedRememberMeServicesTest.php | 7 ------- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php index 51eddb6206..be22a1daff 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php @@ -34,7 +34,10 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface const COOKIE_DELIMITER = ':'; protected $logger; - protected $options; + protected $options = array( + 'secure' => false, + 'httponly' => true, + ); private $providerKey; private $key; private $userProviders; @@ -65,7 +68,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface $this->userProviders = $userProviders; $this->key = $key; $this->providerKey = $providerKey; - $this->options = $options; + $this->options = array_merge($this->options, $options); $this->logger = $logger; } diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php index 9dbcf3f510..c98b6b45b5 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php @@ -91,11 +91,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $request = new Request(); $response = new Response(); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - $service->logout($request, $response, $token); - $cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie); $this->assertTrue($cookie->isCleared()); $this->assertSame($options['name'], $cookie->getName()); @@ -286,13 +283,6 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $userProvider = $this->getProvider(); } - if (!isset($options['secure'])) { - $options['secure'] = false; - } - if (!isset($options['httponly'])) { - $options['httponly'] = true; - } - return $this->getMockForAbstractClass('Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices', array( array($userProvider), 'fookey', 'fookey', $options, $logger, )); diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index fe64abcc71..61c3559abf 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -313,13 +313,6 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $userProvider = $this->getProvider(); } - if (!isset($options['secure'])) { - $options['secure'] = false; - } - if (!isset($options['httponly'])) { - $options['httponly'] = true; - } - return new PersistentTokenBasedRememberMeServices(array($userProvider), 'fookey', 'fookey', $options, $logger, new SecureRandom(sys_get_temp_dir().'/_sf2.seed')); } diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php index 929680dfa2..b988c7dc0f 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php @@ -266,13 +266,6 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $userProvider = $this->getProvider(); } - if (!isset($options['secure'])) { - $options['secure'] = false; - } - if (!isset($options['httponly'])) { - $options['httponly'] = true; - } - $service = new TokenBasedRememberMeServices(array($userProvider), 'fookey', 'fookey', $options, $logger); return $service; From 08333ecb11472cad6ffa954e12835ec056360545 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 6 Oct 2015 15:29:06 +0200 Subject: [PATCH 13/13] [Security] sync translations and add a test for it --- .../Resources/translations/security.tr.xlf | 12 ++-- .../Tests/TranslationSyncStatusTest.php | 63 +++++++++++++++++++ src/Symfony/Component/Security/composer.json | 1 + .../Component/Security/phpunit.xml.dist | 2 + 4 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/Security/Tests/TranslationSyncStatusTest.php diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf index fbf9b260b0..68c44213d1 100644 --- a/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf +++ b/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf @@ -8,7 +8,7 @@ Authentication credentials could not be found. - Yetkilendirme girdileri bulunamadı. + Kimlik bilgileri bulunamadı. Authentication request could not be processed due to a system problem. @@ -16,7 +16,7 @@ Invalid credentials. - Geçersiz girdiler. + Geçersiz kimlik bilgileri. Cookie has already been used by someone else. @@ -32,7 +32,7 @@ Digest nonce has expired. - Derleme zaman aşımı gerçekleşti. + Derleme zaman aşımına uğradı. No authentication provider found to support the authentication token. @@ -44,7 +44,7 @@ No token could be found. - Bilet bulunamadı. + Fiş bulunamadı. Username could not be found. @@ -56,11 +56,11 @@ Credentials have expired. - Girdiler zaman aşımına uğradı. + Kimlik bilgileri zaman aşımına uğradı. Account is disabled. - Hesap devre dışı bırakılmış. + Hesap engellenmiş. Account is locked. diff --git a/src/Symfony/Component/Security/Tests/TranslationSyncStatusTest.php b/src/Symfony/Component/Security/Tests/TranslationSyncStatusTest.php new file mode 100644 index 0000000000..4b72d41d5a --- /dev/null +++ b/src/Symfony/Component/Security/Tests/TranslationSyncStatusTest.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Tests; + +use Symfony\Component\Finder\Finder; + +class TranslationSyncStatusTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getTranslationDirectoriesData + */ + public function testTranslationFileIsNotMissingInCore($dir1, $dir2) + { + $finder = new Finder(); + $files = $finder->in($dir1)->files(); + + foreach ($files as $file) { + $this->assertFileExists($dir2.'/'.$file->getFilename(), 'Missing file '.$file->getFilename().' in directory '.$dir2); + } + } + + public function getTranslationDirectoriesData() + { + $legacyTranslationsDir = $this->getLegacyTranslationsDirectory(); + $coreTranslationsDir = $this->getCoreTranslationsDirectory(); + + return array( + 'file-not-missing-in-core' => array($legacyTranslationsDir, $coreTranslationsDir), + 'file-not-added-in-core' => array($coreTranslationsDir, $legacyTranslationsDir), + ); + } + + public function testFileContentsAreEqual() + { + $finder = new Finder(); + $files = $finder->in($this->getLegacyTranslationsDirectory())->files(); + + foreach ($files as $file) { + $coreFile = $this->getCoreTranslationsDirectory().'/'.$file->getFilename(); + + $this->assertFileEquals($file->getRealPath(), $coreFile, $file.' and '.$coreFile.' have equal content.'); + } + } + + private function getLegacyTranslationsDirectory() + { + return __DIR__.'/../Resources/translations'; + } + + private function getCoreTranslationsDirectory() + { + return __DIR__.'/../Core/Resources/translations'; + } +} diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 1f0584467e..826dcebb37 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -28,6 +28,7 @@ "symfony/security-http": "self.version" }, "require-dev": { + "symfony/finder": "~2.3", "symfony/phpunit-bridge": "~2.7", "symfony/intl": "~2.3", "symfony/routing": "~2.2", diff --git a/src/Symfony/Component/Security/phpunit.xml.dist b/src/Symfony/Component/Security/phpunit.xml.dist index 7747b371c1..3e7ec38526 100644 --- a/src/Symfony/Component/Security/phpunit.xml.dist +++ b/src/Symfony/Component/Security/phpunit.xml.dist @@ -12,6 +12,7 @@ + ./Tests/ ./Acl/Tests/ ./Core/Tests/ ./Http/Tests/ @@ -23,6 +24,7 @@ ./ ./vendor + ./Tests ./Acl/Tests ./Core/Tests ./Http/Tests