From f23255022589ce9abee10c45a570819e6542e5fe Mon Sep 17 00:00:00 2001 From: franek Date: Tue, 1 Oct 2013 14:55:47 +0200 Subject: [PATCH 01/31] remove deprecated constraints calls (Min, Max, MaxLength, MinLength) --- .../Extension/Validator/ValidatorTypeGuesser.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index e5942858bb..84df7e4c89 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -145,14 +145,10 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface case 'Symfony\Component\Validator\Constraints\Ip': return new TypeGuess('text', array(), Guess::MEDIUM_CONFIDENCE); - case 'Symfony\Component\Validator\Constraints\MaxLength': - case 'Symfony\Component\Validator\Constraints\MinLength': case 'Symfony\Component\Validator\Constraints\Length': case 'Symfony\Component\Validator\Constraints\Regex': return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE); - case 'Symfony\Component\Validator\Constraints\Min': - case 'Symfony\Component\Validator\Constraints\Max': case 'Symfony\Component\Validator\Constraints\Range': return new TypeGuess('number', array(), Guess::LOW_CONFIDENCE); @@ -197,9 +193,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface public function guessMaxLengthForConstraint(Constraint $constraint) { switch (get_class($constraint)) { - case 'Symfony\Component\Validator\Constraints\MaxLength': - return new ValueGuess($constraint->limit, Guess::HIGH_CONFIDENCE); - case 'Symfony\Component\Validator\Constraints\Length': if (is_numeric($constraint->max)) { return new ValueGuess($constraint->max, Guess::HIGH_CONFIDENCE); @@ -212,9 +205,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface } break; - case 'Symfony\Component\Validator\Constraints\Max': - return new ValueGuess(strlen((string) $constraint->limit), Guess::LOW_CONFIDENCE); - case 'Symfony\Component\Validator\Constraints\Range': if (is_numeric($constraint->max)) { return new ValueGuess(strlen((string) $constraint->max), Guess::LOW_CONFIDENCE); @@ -235,9 +225,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface public function guessPatternForConstraint(Constraint $constraint) { switch (get_class($constraint)) { - case 'Symfony\Component\Validator\Constraints\MinLength': - return new ValueGuess(sprintf('.{%s,}', (string) $constraint->limit), Guess::LOW_CONFIDENCE); - case 'Symfony\Component\Validator\Constraints\Length': if (is_numeric($constraint->min)) { return new ValueGuess(sprintf('.{%s,}', (string) $constraint->min), Guess::LOW_CONFIDENCE); @@ -252,9 +239,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface } break; - case 'Symfony\Component\Validator\Constraints\Min': - return new ValueGuess(sprintf('.{%s,}', strlen((string) $constraint->limit)), Guess::LOW_CONFIDENCE); - case 'Symfony\Component\Validator\Constraints\Range': if (is_numeric($constraint->min)) { return new ValueGuess(sprintf('.{%s,}', strlen((string) $constraint->min)), Guess::LOW_CONFIDENCE); From cdb5ae0ede9a4c1ae92fa582f1078bff2fa912ad Mon Sep 17 00:00:00 2001 From: Abdellatif AitBoudad Date: Sat, 7 Dec 2013 14:24:25 +0000 Subject: [PATCH 02/31] [Validator]Fixed getting wrong msg when value is an object in UnexpectedTypeException --- .../Component/Validator/Exception/UnexpectedTypeException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php index 573fecd2e8..49d8cc2082 100644 --- a/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php @@ -15,6 +15,6 @@ class UnexpectedTypeException extends ValidatorException { public function __construct($value, $expectedType) { - parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, gettype($value))); + parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); } } From 454ce16709c7b551ea2412c8b982e7d38fa03047 Mon Sep 17 00:00:00 2001 From: Evan Villemez Date: Thu, 5 Dec 2013 17:33:29 -0500 Subject: [PATCH 03/31] allow TraceableEventDispatcher to reuse event instance in nested events --- .../Debug/TraceableEventDispatcher.php | 5 +++-- .../Tests/Debug/TraceableEventDispatcherTest.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index 6bfd7a01dd..6fa3065f11 100644 --- a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -39,6 +39,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve private $wrappedListeners; private $firstCalledEvent; private $id; + private $lastEventId = 0; /** * Constructor. @@ -124,7 +125,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve $event = new Event(); } - $this->id = spl_object_hash($event); + $this->id = $eventId = ++$this->lastEventId; $this->preDispatch($eventName, $event); @@ -139,7 +140,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve $this->dispatcher->dispatch($eventName, $event); // reset the id as another event might have been dispatched during the dispatching of this event - $this->id = spl_object_hash($event); + $this->id = $eventId; unset($this->firstCalledEvent[$eventName]); diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index a5f507cd4e..b9bc1d7f97 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -159,6 +159,22 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase $dispatcher->dispatch('foo'); } + public function testDispatchReusedEventNested() + { + $nestedCall = false; + $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $dispatcher->addListener('foo', function (Event $e) use ($dispatcher) { + $dispatcher->dispatch('bar', $e); + }); + $dispatcher->addListener('bar', function (Event $e) use (&$nestedCall) { + $nestedCall = true; + }); + + $this->assertFalse($nestedCall); + $dispatcher->dispatch('foo'); + $this->assertTrue($nestedCall); + } + public function testStopwatchSections() { $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch = new Stopwatch()); From 923640ac4a23fbf4679350eab201f3842e58fbf8 Mon Sep 17 00:00:00 2001 From: Arturas Smorgun Date: Thu, 12 Dec 2013 16:38:34 +0100 Subject: [PATCH 04/31] Add missing lithuanian validator translations --- .../Resources/translations/validators.lt.xlf | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf index d47fa54b16..ff2e67b2e2 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf @@ -214,6 +214,70 @@ This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. Sąraše turi būti lygiai {{ limit }} įrašas.|Sąraše turi būti lygiai {{ limit }} įrašai.|Sąraše turi būti lygiai {{ limit }} įrašų. + + Invalid card number. + Klaidingas kortelės numeris. + + + Unsupported card type or invalid card number. + Kortelės tipas nepalaikomas arba klaidingas kortelės numeris. + + + This is not a valid International Bank Account Number (IBAN). + Ši reišmė neatitinka tarptautinio banko sąskaitos numerio formato (IBAN). + + + This value is not a valid ISBN-10. + Ši reikšmė neatitinka ISBN-10 formato. + + + This value is not a valid ISBN-13. + Ši reikšmė neatitinka ISBN-13 formato. + + + This value is neither a valid ISBN-10 nor a valid ISBN-13. + Ši reikšmė neatitinka nei ISBN-10, nei ISBN-13 formato. + + + This value is not a valid ISSN. + Ši reišmė neatitinka ISSN formato. + + + This value is not a valid currency. + Netinkamas valiutos formatas. + + + This value should be equal to {{ compared_value }}. + Ši reikšmė turi būti lygi {{ compared_value }}. + + + This value should be greater than {{ compared_value }}. + Ši reikšmė turi būti didesnė už {{ compared_value }}. + + + This value should be greater than or equal to {{ compared_value }}. + Ši reikšmė turi būti didesnė už arba lygi {{ compared_value }}. + + + This value should be identical to {{ compared_value_type }} {{ compared_value }}. + Ši reikšmė turi būti identiška {{ compared_value_type }} {{ compared_value }}. + + + This value should be less than {{ compared_value }}. + Ši reikšmė turi būti mažesnė už {{ compared_value }}. + + + This value should be less than or equal to {{ compared_value }}. + Ši reikšmė turi būti mažesnė už arba lygi {{ compared_value }}. + + + This value should not be equal to {{ compared_value }}. + Ši reikšmė neturi būti lygi {{ compared_value }}. + + + This value should not be identical to {{ compared_value_type }} {{ compared_value }}. + Še reikšmė neturi būti identiška {{ compared_value_type }} {{ compared_value }}. + From 6ddb12d1c70fec0550433845223a629da4a15a73 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Sun, 1 Dec 2013 20:02:34 +0100 Subject: [PATCH 05/31] renamed validators.ua.xlf to validators.uk.xlf ISO 639-1 code for Ukrainian is "uk" --- .../translations/{validators.ua.xlf => validators.uk.xlf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Symfony/Component/Form/Resources/translations/{validators.ua.xlf => validators.uk.xlf} (100%) diff --git a/src/Symfony/Component/Form/Resources/translations/validators.ua.xlf b/src/Symfony/Component/Form/Resources/translations/validators.uk.xlf similarity index 100% rename from src/Symfony/Component/Form/Resources/translations/validators.ua.xlf rename to src/Symfony/Component/Form/Resources/translations/validators.uk.xlf From e2ef38c80694710c7cc3b388685440c5cfd5cb15 Mon Sep 17 00:00:00 2001 From: Arturas Smorgun Date: Thu, 12 Dec 2013 17:34:17 +0100 Subject: [PATCH 06/31] Fix mistype which slipped through initial proof reading. --- .../Validator/Resources/translations/validators.lt.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf index ff2e67b2e2..e794be0d87 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf @@ -276,7 +276,7 @@ This value should not be identical to {{ compared_value_type }} {{ compared_value }}. - Še reikšmė neturi būti identiška {{ compared_value_type }} {{ compared_value }}. + Ši reikšmė neturi būti identiška {{ compared_value_type }} {{ compared_value }}. From 557dfaa2c1623e2160d75473a8a736a1d9522f6b Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Sat, 23 Nov 2013 00:07:07 +0100 Subject: [PATCH 07/31] Remove usage of deprecated _scheme in Routing Component Instead correctly use the array of schemes from the Route. Also adjusted the dumpers to dump the correct data. I extended the tests to not only test the deprecated behavior, but also the new schemes-requirement. --- .../Routing/RedirectableUrlMatcherTest.php | 22 +++++++- .../Generator/Dumper/PhpGeneratorDumper.php | 5 +- .../Routing/Generator/UrlGenerator.php | 23 ++++++-- .../Matcher/Dumper/PhpMatcherDumper.php | 18 ++++--- .../Matcher/RedirectableUrlMatcher.php | 7 +-- .../Routing/Matcher/TraceableUrlMatcher.php | 8 +-- .../Component/Routing/Matcher/UrlMatcher.php | 4 +- src/Symfony/Component/Routing/Route.php | 19 +++++++ .../Tests/Fixtures/dumper/url_matcher2.php | 10 ++-- .../Dumper/PhpGeneratorDumperTest.php | 33 ++++++++++++ .../Tests/Generator/UrlGeneratorTest.php | 54 ++++++++++++++++--- .../Matcher/RedirectableUrlMatcherTest.php | 30 ++++++++++- .../Routing/Tests/Matcher/UrlMatcherTest.php | 12 ++++- .../Component/Routing/Tests/RouteTest.php | 8 +++ 14 files changed, 219 insertions(+), 34 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php index fe8fc709a6..282f860262 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php @@ -38,7 +38,7 @@ class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase ); } - public function testSchemeRedirect() + public function testSchemeRedirectBC() { $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); @@ -57,4 +57,24 @@ class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase $matcher->match('/foo') ); } + + public function testSchemeRedirect() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https'))); + + $matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext()); + + $this->assertEquals(array( + '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', + 'path' => '/foo', + 'permanent' => true, + 'scheme' => 'https', + 'httpPort' => $context->getHttpPort(), + 'httpsPort' => $context->getHttpsPort(), + '_route' => 'foo', + ), + $matcher->match('/foo') + ); + } } diff --git a/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php index 42cd910893..4d19d2a2ec 100644 --- a/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ b/src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php @@ -92,6 +92,7 @@ EOF; $properties[] = $route->getRequirements(); $properties[] = $compiledRoute->getTokens(); $properties[] = $compiledRoute->getHostTokens(); + $properties[] = $route->getSchemes(); $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); } @@ -114,9 +115,9 @@ EOF; throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', \$name)); } - list(\$variables, \$defaults, \$requirements, \$tokens, \$hostTokens) = self::\$declaredRoutes[\$name]; + list(\$variables, \$defaults, \$requirements, \$tokens, \$hostTokens, \$requiredSchemes) = self::\$declaredRoutes[\$name]; - return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$referenceType, \$hostTokens); + return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$referenceType, \$hostTokens, \$requiredSchemes); } EOF; } diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index f224cb3f6d..59ce9e25a5 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -137,7 +137,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt // the Route has a cache of its own and is not recompiled as long as it does not get modified $compiledRoute = $route->compile(); - return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens()); + return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes()); } /** @@ -145,7 +145,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement */ - protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens) + protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array()) { $variables = array_flip($variables); $mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters); @@ -204,7 +204,24 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt $schemeAuthority = ''; if ($host = $this->context->getHost()) { $scheme = $this->context->getScheme(); - if (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme !== $req) { + + if ($requiredSchemes) { + $schemeMatched = false; + foreach ($requiredSchemes as $requiredScheme) { + if ($scheme === $requiredScheme) { + $schemeMatched = true; + + break; + } + } + + if (!$schemeMatched) { + $referenceType = self::ABSOLUTE_URL; + $scheme = current($requiredSchemes); + } + + } elseif (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme !== $req) { + // We do this for BC; to be removed if _scheme is not supported anymore $referenceType = self::ABSOLUTE_URL; $scheme = $req; } diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index dc17ffbe98..2b71b9ef5f 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -280,14 +280,15 @@ EOF; EOF; } - if ($scheme = $route->getRequirement('_scheme')) { + if ($schemes = $route->getSchemes()) { if (!$supportsRedirections) { - throw new \LogicException('The "_scheme" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); + throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); } - + $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); $code .= <<context->getScheme() !== '$scheme') { - return \$this->redirect(\$pathinfo, '$name', '$scheme'); + \$requiredSchemes = $schemes; + if (!isset(\$requiredSchemes[\$this->context->getScheme()])) { + return \$this->redirect(\$pathinfo, '$name', key(\$requiredSchemes)); } @@ -305,8 +306,11 @@ EOF; } $vars[] = "array('_route' => '$name')"; - $code .= sprintf(" return \$this->mergeDefaults(array_replace(%s), %s);\n" - , implode(', ', $vars), str_replace("\n", '', var_export($route->getDefaults(), true))); + $code .= sprintf( + " return \$this->mergeDefaults(array_replace(%s), %s);\n", + implode(', ', $vars), + str_replace("\n", '', var_export($route->getDefaults(), true)) + ); } elseif ($route->getDefaults()) { $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true))); diff --git a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php index 51e80057cd..e24a15c015 100644 --- a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php @@ -51,9 +51,10 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable protected function handleRouteRequirements($pathinfo, $name, Route $route) { // check HTTP scheme requirement - $scheme = $route->getRequirement('_scheme'); - if ($scheme && $this->context->getScheme() !== $scheme) { - return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, $scheme)); + $scheme = $this->context->getScheme(); + $schemes = $route->getSchemes(); + if ($schemes && !$route->hasScheme($scheme)) { + return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, current($schemes))); } return array(self::REQUIREMENT_MATCH, null); diff --git a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php index c09f83e86a..9062e9914e 100644 --- a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php @@ -95,9 +95,11 @@ class TraceableUrlMatcher extends UrlMatcher } // check HTTP scheme requirement - if ($scheme = $route->getRequirement('_scheme')) { - if ($this->context->getScheme() !== $scheme) { - $this->addTrace(sprintf('Scheme "%s" does not match the requirement ("%s"); the user will be redirected', $this->context->getScheme(), $scheme), self::ROUTE_ALMOST_MATCHES, $name, $route); + if ($requiredSchemes = $route->getSchemes()) { + $scheme = $this->context->getScheme(); + + if (!$route->hasScheme($scheme)) { + $this->addTrace(sprintf('Scheme "%s" does not match any of the required schemes ("%s"); the user will be redirected to first required scheme', $scheme, implode(', ', $requiredSchemes)), self::ROUTE_ALMOST_MATCHES, $name, $route); return true; } diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index db18ec4e7b..21d8110622 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -181,8 +181,8 @@ class UrlMatcher implements UrlMatcherInterface protected function handleRouteRequirements($pathinfo, $name, Route $route) { // check HTTP scheme requirement - $scheme = $route->getRequirement('_scheme'); - $status = $scheme && $scheme !== $this->context->getScheme() ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH; + $scheme = $this->context->getScheme(); + $status = $route->getSchemes() && !$route->hasScheme($scheme) ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH; return array($status, null); } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index 5bc535c683..45034027f1 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -241,6 +241,25 @@ class Route implements \Serializable return $this; } + /** + * Checks if a scheme requirement has been set. + * + * @param string $scheme + * + * @return Boolean true if the scheme requirement exists, otherwise false + */ + public function hasScheme($scheme) + { + $scheme = strtolower($scheme); + foreach ($this->schemes as $requiredScheme) { + if ($scheme === $requiredScheme) { + return true; + } + } + + return false; + } + /** * Returns the uppercased HTTP methods this route is restricted to. * So an empty array means that any method is allowed. diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index ad157909b8..a27be98d39 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -319,8 +319,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec // secure if ($pathinfo === '/secure') { - if ($this->context->getScheme() !== 'https') { - return $this->redirect($pathinfo, 'secure', 'https'); + $requiredSchemes = array ( 'https' => 0,); + if (!isset($requiredSchemes[$this->context->getScheme()])) { + return $this->redirect($pathinfo, 'secure', key($requiredSchemes)); } return array('_route' => 'secure'); @@ -328,8 +329,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec // nonsecure if ($pathinfo === '/nonsecure') { - if ($this->context->getScheme() !== 'http') { - return $this->redirect($pathinfo, 'nonsecure', 'http'); + $requiredSchemes = array ( 'http' => 0,); + if (!isset($requiredSchemes[$this->context->getScheme()])) { + return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes)); } return array('_route' => 'nonsecure'); diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php index ab5f4cdae0..78e3907fd5 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php @@ -114,4 +114,37 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase $this->assertEquals($url, '/testing'); } + + public function testDumpWithSchemeRequirement() + { + $this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https'))); + $this->routeCollection->add('Test2', new Route('/testing_bc', array(), array('_scheme' => 'https'))); // BC + + file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator'))); + include ($this->testTmpFilepath); + + $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php')); + + $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true); + $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true); + $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false); + $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false); + + $this->assertEquals($absoluteUrl, 'ftp://localhost/app.php/testing'); + $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc'); + $this->assertEquals($relativeUrl, 'ftp://localhost/app.php/testing'); + $this->assertEquals($relativeUrlBC, 'https://localhost/app.php/testing_bc'); + + $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https')); + + $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true); + $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true); + $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false); + $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false); + + $this->assertEquals($absoluteUrl, 'https://localhost/app.php/testing'); + $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc'); + $this->assertEquals($relativeUrl, '/app.php/testing'); + $this->assertEquals($relativeUrlBC, '/app.php/testing_bc'); + } } diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 5f8ef49127..dea0e7f4a9 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -248,20 +248,38 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase public function testSchemeRequirementDoesNothingIfSameCurrentScheme() { - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); // BC $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); // BC + $this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http'))); + $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); $this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); } public function testSchemeRequirementForcesAbsoluteUrl() { - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); // BC $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); // BC $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); + $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http'))); + $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); + } + + public function testSchemeRequirementCreatesUrlForFirstRequiredScheme() + { + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('Ftp', 'https'))); + $this->assertEquals('ftp://localhost/app.php/', $this->getGenerator($routes)->generate('test')); } public function testPathWithTwoStartingSlashes() @@ -447,7 +465,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertNull($generator->generate('test', array('foo' => 'baz'), false)); } - public function testGenerateNetworkPath() + public function testGenerateNetworkPathBC() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array('_scheme' => 'http'), array(), '{locale}.example.com')); @@ -465,13 +483,32 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase ); } + public function testGenerateNetworkPath() + { + $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com', array('http'))); + + $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', + array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' + ); + $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', + array('name' =>'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' + ); + $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', + array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' + ); + $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', + array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' + ); + } + public function testGenerateRelativePath() { $routes = new RouteCollection(); $routes->add('article', new Route('/{author}/{article}/')); $routes->add('comments', new Route('/{author}/{article}/comments')); $routes->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com')); - $routes->add('scheme', new Route('/{author}', array(), array('_scheme' => 'https'))); + $routes->add('schemeBC', new Route('/{author}', array(), array('_scheme' => 'https'))); // BC + $routes->add('scheme', new Route('/{author}/blog', array(), array(), array(), '', array('https'))); $routes->add('unrelated', new Route('/about')); $generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/')); @@ -491,9 +528,12 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host', array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) ); - $this->assertSame('https://example.com/app.php/bernhard', $generator->generate('scheme', + $this->assertSame('https://example.com/app.php/bernhard', $generator->generate('schemeBC', array('author' =>'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) ); + $this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme', + array('author' =>'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) + ); $this->assertSame('../../about', $generator->generate('unrelated', array(), UrlGeneratorInterface::RELATIVE_PATH) ); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php index 2ad4fc8725..5cbb605479 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php @@ -41,7 +41,7 @@ class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase $matcher->match('/foo'); } - public function testSchemeRedirect() + public function testSchemeRedirectBC() { $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); @@ -55,4 +55,32 @@ class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase ; $matcher->match('/foo'); } + + public function testSchemeRedirectRedirectsToFirstScheme() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('FTP', 'HTTPS'))); + + $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); + $matcher + ->expects($this->once()) + ->method('redirect') + ->with('/foo', 'foo', 'ftp') + ->will($this->returnValue(array('_route' => 'foo'))) + ; + $matcher->match('/foo'); + } + + public function testNoSchemaRedirectIfOnOfMultipleSchemesMatches() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https', 'http'))); + + $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); + $matcher + ->expects($this->never()) + ->method('redirect') + ; + $matcher->match('/foo'); + } } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index 8a1428f170..ce0f0ea513 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -313,13 +313,23 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException */ - public function testSchemeRequirement() + public function testSchemeRequirementBC() { $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); $matcher = new UrlMatcher($coll, new RequestContext()); $matcher->match('/foo'); } + /** + * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException + */ + public function testSchemeRequirement() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https'))); + $matcher = new UrlMatcher($coll, new RequestContext()); + $matcher->match('/foo'); + } public function testDecodeOnce() { diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index 31f1066fed..e4046fafd5 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -141,10 +141,15 @@ class RouteTest extends \PHPUnit_Framework_TestCase { $route = new Route('/'); $this->assertEquals(array(), $route->getSchemes(), 'schemes is initialized with array()'); + $this->assertFalse($route->hasScheme('http')); $route->setSchemes('hTTp'); $this->assertEquals(array('http'), $route->getSchemes(), '->setSchemes() accepts a single scheme string and lowercases it'); + $this->assertTrue($route->hasScheme('htTp')); + $this->assertFalse($route->hasScheme('httpS')); $route->setSchemes(array('HttpS', 'hTTp')); $this->assertEquals(array('https', 'http'), $route->getSchemes(), '->setSchemes() accepts an array of schemes and lowercases them'); + $this->assertTrue($route->hasScheme('htTp')); + $this->assertTrue($route->hasScheme('httpS')); } public function testSchemeIsBC() @@ -153,6 +158,9 @@ class RouteTest extends \PHPUnit_Framework_TestCase $route->setRequirement('_scheme', 'http|https'); $this->assertEquals('http|https', $route->getRequirement('_scheme')); $this->assertEquals(array('http', 'https'), $route->getSchemes()); + $this->assertTrue($route->hasScheme('https')); + $this->assertTrue($route->hasScheme('http')); + $this->assertFalse($route->hasScheme('ftp')); $route->setSchemes(array('hTTp')); $this->assertEquals('http', $route->getRequirement('_scheme')); $route->setSchemes(array()); From f727b2254ca3f02d590077d2dd5c17faa5ceb4d4 Mon Sep 17 00:00:00 2001 From: karolsojko Date: Sat, 14 Dec 2013 11:28:45 +0100 Subject: [PATCH 08/31] [Routing] Fix router matching pattern against multiple hosts --- .../Routing/Matcher/TraceableUrlMatcher.php | 2 +- .../Tests/Matcher/TraceableUrlMatcherTest.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php index c09f83e86a..571dcb1f6e 100644 --- a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php @@ -75,7 +75,7 @@ class TraceableUrlMatcher extends UrlMatcher if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { $this->addTrace(sprintf('Host "%s" does not match the requirement ("%s")', $this->context->getHost(), $route->getHost()), self::ROUTE_ALMOST_MATCHES, $name, $route); - return true; + continue; } // check HTTP method requirement diff --git a/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php index 86d8d954c0..04d012628d 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php @@ -54,6 +54,37 @@ class TraceableUrlMatcherTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array(0, 1, 2), $this->getLevels($traces)); } + public function testMatchRouteOnMultipleHosts() + { + $routes = new RouteCollection(); + $routes->add('first', new Route( + '/mypath/', + array('_controller' => 'MainBundle:Info:first'), + array(), + array(), + 'some.example.com' + )); + + $routes->add('second', new Route( + '/mypath/', + array('_controller' => 'MainBundle:Info:second'), + array(), + array(), + 'another.example.com' + )); + + $context = new RequestContext(); + $context->setHost('baz'); + + $matcher = new TraceableUrlMatcher($routes, $context); + + $traces = $matcher->getTraces('/mypath/'); + $this->assertEquals( + array(TraceableUrlMatcher::ROUTE_ALMOST_MATCHES, TraceableUrlMatcher::ROUTE_ALMOST_MATCHES), + $this->getLevels($traces) + ); + } + public function getLevels($traces) { $levels = array(); From c9c21a51ad2abf034deb8f6589b48d5a606c32d5 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 14 Dec 2013 17:08:30 +0100 Subject: [PATCH 09/31] [Validator] updated the Spanish translation of the validator strings --- .../Resources/translations/validators.es.xlf | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf index 2b57a2b7ec..30642148e6 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf @@ -242,6 +242,42 @@ This value is not a valid ISSN. Este valor no es un ISSN válido. + + This value is not a valid currency. + Este valor no es una divisa válida. + + + This value should be equal to {{ compared_value }}. + Este valor debería ser igual que {{ compared_value }}. + + + This value should be greater than {{ compared_value }}. + Este valor debería ser mayor que {{ compared_value }}. + + + This value should be greater than or equal to {{ compared_value }}. + Este valor debería ser mayor o igual que {{ compared_value }}. + + + This value should be identical to {{ compared_value_type }} {{ compared_value }}. + Este valor debería ser idéntico a {{ compared_value_type }} {{ compared_value }}. + + + This value should be less than {{ compared_value }}. + Este valor debería ser menor que {{ compared_value }}. + + + This value should be less than or equal to {{ compared_value }}. + Este valor debería ser menor o igual que {{ compared_value }}. + + + This value should not be equal to {{ compared_value }}. + Este valor debería ser distinto de {{ compared_value }}. + + + This value should not be identical to {{ compared_value_type }} {{ compared_value }}. + Este valor no debería ser idéntico a {{ compared_value_type }} {{ compared_value }}. + From a834c2fd6ce1ee79ae7812abae1e3b9ad31d8caa Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 15 Dec 2013 13:21:03 +0100 Subject: [PATCH 10/31] [BrowserKit] Add missing exception message parameter | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - --- src/Symfony/Component/BrowserKit/Cookie.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index 1e2c64ce63..bce5613cf7 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -127,7 +127,7 @@ class Cookie $parts = explode(';', $cookie); if (false === strpos($parts[0], '=')) { - throw new \InvalidArgumentException('The cookie string "%s" is not valid.'); + throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0])); } list($name, $value) = explode('=', array_shift($parts), 2); From 31c59791528d1aca876c31605d3d5b618fbda098 Mon Sep 17 00:00:00 2001 From: gondo Date: Sat, 14 Dec 2013 19:50:08 +0700 Subject: [PATCH 11/31] Update validators.cs.xlf fixed CZ translation. there is not such a word as "null" in czech --- .../Validator/Resources/translations/validators.cs.xlf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf index 22e3e9f30c..6310279cae 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf @@ -92,11 +92,11 @@ This value should not be null. - Tato hodnota nesmí být null. + Tato hodnota nesmí být prázdná. This value should be null. - Tato hodnota musí být null. + Tato hodnota musí být prázdná. This value is not valid. From 37962a6e947fa712718600fbc2c807da3e338c8f Mon Sep 17 00:00:00 2001 From: benatespina Date: Sat, 14 Dec 2013 13:59:49 +0100 Subject: [PATCH 12/31] Improved and fixed grammar mistakes. Added pluralized messages --- .../Resources/translations/validators.eu.xlf | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf index d3d83f979f..62801cce83 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf @@ -4,19 +4,19 @@ This value should be false. - Balio honek faltsua izan beharko luke (false). + Balio hau faltsua izan beharko litzateke. This value should be true. - Balio honek egiazkoa izan beharko luke (true). + Balio hau egia izan beharko litzateke. This value should be of type {{ type }}. - Balio honek {{ type }} motakoa izan beharko luke. + Balio hau {{ type }} motakoa izan beharko litzateke. This value should be blank. - Balio honek hutsik egon beharko luke. + Balio hau hutsik egon beharko litzateke. The value you selected is not a valid choice. @@ -24,15 +24,15 @@ You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Gutxienez {{ limit }} aukera hautatu behar dituzu. + Gutxienez aukera {{ limit }} hautatu behar duzu.|Gutxienez {{ limit }} aukera hautatu behar dituzu. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Gehienez {{ limit }} aukera hautatu behar dituzu. + Gehienez aukera {{ limit }} hautatu behar duzu.|Gehienez {{ limit }} aukera hautatu behar dituzu. One or more of the given values is invalid. - Emandako balio bat edo gehiago ez dira egokiak. + Emandako balioetatik gutxienez bat ez da egokia. The fields {{ fields }} were not expected. @@ -48,11 +48,11 @@ This value is not a valid datetime. - Balio hau ez da data eta ordu egoki bat. + Balio hau ez da data-ordu egoki bat. This value is not a valid email address. - Balio hau ez da helbide elektroniko egoki bat. + Balio hau ez da posta elektroniko egoki bat. The file could not be found. @@ -60,11 +60,11 @@ The file is not readable. - Fitxategia ez dago irakurgai. + Fitxategia ez da irakurgarria. The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - Fitxategia handiegia da ({{ size }} {{ suffix }}). Baimendutako tamainu handiena {{ limit }} {{ suffix }} da. + Fitxategia handiegia da ({{ size }} {{ suffix }}). Baimendutako tamaina handiena {{ limit }} {{ suffix }} da. The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. @@ -72,31 +72,31 @@ This value should be {{ limit }} or less. - Balio honek {{ limit }} edo gutxiago izan beharko luke. + Balio hau gehienez {{ limit }} izan beharko litzateke. This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Balio hau luzeegia da. {{ limit }} karaktere edo gutxiago eduki beharko lituzke. + Balio hau luzeegia da. Gehienez karaktere {{ limit }} eduki beharko luke.|Balio hau luzeegia da. Gehienez {{ limit }} karaktere eduki beharko lituzke. This value should be {{ limit }} or more. - Balio honek {{ limit }} edo handiago izan beharko luke. + Balio hau gutxienez {{ limit }} izan beharko litzateke. This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Balio hau motzegia da. {{ limit }} karaktere edo gehiago eduki beharko lituzke. + Balio hau motzegia da. Karaktere {{ limit }} gutxienez eduki beharko luke.|Balio hau motzegia da. Gutxienez {{ limit }} karaktere eduki beharko lituzke. This value should not be blank. - Balio honek ez luke hutsik egon behar. + Balio hau ez litzateke hutsik egon behar. This value should not be null. - Balio honek ez luke nulua izan behar. + Balio hau ez litzateke nulua izan behar. This value should be null. - Balio honek nulua izan beharko luke. + Balio hau nulua izan beharko litzateke. This value is not valid. @@ -108,7 +108,7 @@ This value is not a valid URL. - Balio hau ez da URL egoki bat. + Balio hau ez da baliabideen kokatzaile uniforme (URL) egoki bat. The two values should be equal. @@ -116,7 +116,7 @@ The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - Fitxategia handiegia da. Baimendutako tamainu handiena {{ limit }} {{ suffix }} da. + Fitxategia handiegia da. Baimendutako tamaina handiena {{ limit }} {{ suffix }} da. The file is too large. @@ -128,7 +128,7 @@ This value should be a valid number. - Balio honek zenbaki egoki bat izan beharko luke. + Balio hau zenbaki egoki bat izan beharko litzateke. This file is not a valid image. @@ -144,7 +144,7 @@ This value is not a valid locale. - Balio hau ez da lokalizazio egoki bat. + Balio hau ez da kokapen egoki bat. This value is not a valid country. @@ -160,7 +160,7 @@ The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. - Irudiaren zabalera haundiegia da ({{ width }}px). Onartutako gehienezko zabalera {{ max_width }}px dira. + Irudiaren zabalera handiegia da ({{ width }}px). Onartutako gehienezko zabalera {{ max_width }}px dira. The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. @@ -168,7 +168,7 @@ The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. - Irudiaren altuera haundiegia da ({{ height }}px). Onartutako gehienezko altuera {{ max_height }}px dira. + Irudiaren altuera handiegia da ({{ height }}px). Onartutako gehienezko altuera {{ max_height }}px dira. The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. @@ -176,15 +176,15 @@ This value should be the user current password. - Balio honek uneko erabiltzailearen pasahitza izan beharko luke. + Balio hau uneko erabiltzailearen pasahitza izan beharko litzateke. This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Balio honek zehazki {{ limit }} karaktere izan beharko lituzke. + Balio honek zehazki karaktere {{ limit }} izan beharko luke.|Balio honek zehazki {{ limit }} karaktere izan beharko lituzke. The file was only partially uploaded. - Fitxategia partzialki bakarrik igo da. + Fitxategiaren zati bat bakarrik igo da. No file was uploaded. @@ -204,27 +204,27 @@ This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - Bilduma honek {{ limit }} elementu edo gehiago eduki beharko lituzke. + Bilduma honek gutxienez elementu {{ limit }} eduki beharko luke.|Bilduma honek gutxienez {{ limit }} elementu eduki beharko lituzke. This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - Bilduma honek {{ limit }} elementu edo gutxiago eduki beharko lituzke. + Bilduma honek gehienez elementu {{ limit }} eduki beharko luke.|Bilduma honek gehienez {{ limit }} elementu eduki beharko lituzke. This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - Bilduma honek zehazki {{ limit }} elementu eduki beharko lituzke. + Bilduma honek zehazki elementu {{ limit }} eduki beharko luke.|Bilduma honek zehazki {{ limit }} elementu eduki beharko lituzke. Invalid card number. - Txartelaren zenbaki baliogabea. + Txartel zenbaki baliogabea. Unsupported card type or invalid card number. - Onartzen ez den txartel mota edo txartelaren zenbaki baliogabea. + Txartel mota onartezina edo txartel zenbaki baliogabea. This is not a valid International Bank Account Number (IBAN). - Hau ez da onartutako International Bank Account Number (IBAN) bat. + Hau ez da baliozko banku internazionaleko kontu zenbaki (IBAN) bat. This value is not a valid ISBN-10. @@ -244,39 +244,39 @@ This value is not a valid currency. - Balio hau ez da baliozko moneta. + Balio hau ez da baliozko moneta bat. This value should be equal to {{ compared_value }}. - Balio honek {{ compared_value }}-(r)en berdina izan behar du. + Balio hau {{ compared_value }}-(r)en berbera izan beharko litzateke. This value should be greater than {{ compared_value }}. - Balio honek {{ compared_value }} baino handiagoa izan behar du. + Balio hau {{ compared_value }} baino handiagoa izan beharko litzateke. This value should be greater than or equal to {{ compared_value }}. - Balio honek {{ compared_value }}-(r)en berdina edo handiagoa izan beharko luke. + Balio hau {{ compared_value }}-(r)en berdina edota handiagoa izan beharko litzateke. This value should be identical to {{ compared_value_type }} {{ compared_value }}. - Balio honek berbera izan behar du {{ compared_value_type }} {{ compared_value }}. + Balio hau {{ compared_value_type }} {{ compared_value }}-(r)en berbera izan beharko litzateke. This value should be less than {{ compared_value }}. - Balio honek {{ compared_value }} baino txikiago izan behar du. + Balio hau {{ compared_value }} baino txikiagoa izan beharko litzateke. This value should be less than or equal to {{ compared_value }}. - Balio honek {{ compared_value }}-(r)en berdina edo txikiago izan behar du. + Balio hau {{ compared_value }}-(r)en berdina edota txikiagoa izan beharko litzateke. This value should not be equal to {{ compared_value }}. - Balio honek {{ compared_value }}-(r)en berdina izan behar du. + Balio hau ez litzateke {{ compared_value }}-(r)en berdina izan behar. This value should not be identical to {{ compared_value_type }} {{ compared_value }}. - Balio honek ez du berbera izan behar {{ compared_value_type }} {{ compared_value }}. + Balio hau ez litzateke {{ compared_value_type }} {{ compared_value }}-(r)en berbera izan behar. From 40e58cdc9a9ce99a25f3c8c01e5e2df01f5d6551 Mon Sep 17 00:00:00 2001 From: Krzysztof Przybyszewski Date: Sun, 15 Dec 2013 18:59:25 +0100 Subject: [PATCH 13/31] fixed TableHelper when cell value has new line --- .../Component/Console/Helper/TableHelper.php | 23 +++++++++++++++++++ .../Console/Tests/Helper/TableHelperTest.php | 22 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/Symfony/Component/Console/Helper/TableHelper.php b/src/Symfony/Component/Console/Helper/TableHelper.php index c18f29598a..d08f9416f4 100644 --- a/src/Symfony/Component/Console/Helper/TableHelper.php +++ b/src/Symfony/Component/Console/Helper/TableHelper.php @@ -142,6 +142,29 @@ class TableHelper extends Helper public function addRow(array $row) { $this->rows[] = array_values($row); + + $keys = array_keys($this->rows); + $rowKey = array_pop($keys); + + foreach ($row as $key => $cellValue) { + if (strstr($cellValue, "\n")) { + + $lines = explode("\n", $cellValue); + $this->rows[$rowKey][$key] = $lines[0]; + unset($lines[0]); + + foreach ($lines as $lineKey => $line) { + + $nextRowKey = $rowKey + $lineKey + 1; + + if (isset($this->rows[$nextRowKey])) { + $this->rows[$nextRowKey][$key] = $line; + } else { + $this->rows[$nextRowKey] = array($key => $line); + } + } + } + } return $this; } diff --git a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php index 5873a7fda6..983accf8c2 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php @@ -152,6 +152,28 @@ TABLE | 80-902734-1-6 | And Then There Were None | Agatha Christie | +---------------+--------------------------+------------------+ +TABLE + ), + array( + array('ISBN', 'Title', 'Author'), + array( + array("99921-58-10-7", "Divine\nComedy", "Dante Alighieri"), + array("9971-5-0210-2", "Harry Potter\nand the Chamber of Secrets", "Rowling\nJoanne K."), + array("960-425-059-0", "The Lord of the Rings", "J. R. R.\nTolkien"), + ), + TableHelper::LAYOUT_DEFAULT, +<< Date: Sun, 15 Dec 2013 19:46:51 +0100 Subject: [PATCH 14/31] [Console] fixed CS --- .../Component/Console/Helper/TableHelper.php | 26 +++++++++---------- .../Console/Tests/Helper/TableHelperTest.php | 3 +++ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/TableHelper.php b/src/Symfony/Component/Console/Helper/TableHelper.php index d08f9416f4..c8f1ec9649 100644 --- a/src/Symfony/Component/Console/Helper/TableHelper.php +++ b/src/Symfony/Component/Console/Helper/TableHelper.php @@ -142,26 +142,26 @@ class TableHelper extends Helper public function addRow(array $row) { $this->rows[] = array_values($row); - + $keys = array_keys($this->rows); $rowKey = array_pop($keys); foreach ($row as $key => $cellValue) { - if (strstr($cellValue, "\n")) { + if (!strstr($cellValue, "\n")) { + continue; + } - $lines = explode("\n", $cellValue); - $this->rows[$rowKey][$key] = $lines[0]; - unset($lines[0]); + $lines = explode("\n", $cellValue); + $this->rows[$rowKey][$key] = $lines[0]; + unset($lines[0]); - foreach ($lines as $lineKey => $line) { + foreach ($lines as $lineKey => $line) { + $nextRowKey = $rowKey + $lineKey + 1; - $nextRowKey = $rowKey + $lineKey + 1; - - if (isset($this->rows[$nextRowKey])) { - $this->rows[$nextRowKey][$key] = $line; - } else { - $this->rows[$nextRowKey] = array($key => $line); - } + if (isset($this->rows[$nextRowKey])) { + $this->rows[$nextRowKey][$key] = $line; + } else { + $this->rows[$nextRowKey] = array($key => $line); } } } diff --git a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php index 983accf8c2..2ffd3b6b3a 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php @@ -159,6 +159,7 @@ TABLE array( array("99921-58-10-7", "Divine\nComedy", "Dante Alighieri"), array("9971-5-0210-2", "Harry Potter\nand the Chamber of Secrets", "Rowling\nJoanne K."), + array("9971-5-0210-2", "Harry Potter\nand the Chamber of Secrets", "Rowling\nJoanne K."), array("960-425-059-0", "The Lord of the Rings", "J. R. R.\nTolkien"), ), TableHelper::LAYOUT_DEFAULT, @@ -170,6 +171,8 @@ TABLE | | Comedy | | | 9971-5-0210-2 | Harry Potter | Rowling | | | and the Chamber of Secrets | Joanne K. | +| 9971-5-0210-2 | Harry Potter | Rowling | +| | and the Chamber of Secrets | Joanne K. | | 960-425-059-0 | The Lord of the Rings | J. R. R. | | | | Tolkien | +---------------+----------------------------+-----------------+ From 10e43b7be82e31eec980615594b67780db51e4d7 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 16 Dec 2013 11:23:38 +0000 Subject: [PATCH 15/31] [Filesystem] Changed the mode for a target file in copy() to be write only. Stream wrappers like S3 do not support w+. --- src/Symfony/Component/Filesystem/Filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 6e015b4bd4..36926c1aa5 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -50,7 +50,7 @@ class Filesystem if ($doCopy) { // https://bugs.php.net/bug.php?id=64634 $source = fopen($originFile, 'r'); - $target = fopen($targetFile, 'w+'); + $target = fopen($targetFile, 'w'); stream_copy_to_stream($source, $target); fclose($source); fclose($target); From 30934bb7ea41a5aa2731415afb0ffcb594441b9b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Dec 2013 15:35:01 +0100 Subject: [PATCH 16/31] updated CHANGELOG for 2.3.8 --- CHANGELOG-2.3.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index 4f872ad96e..1ea4d10300 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,39 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.8 (2013-12-16) + + * bug #9758 [Console] fixed TableHelper when cell value has new line (k-przybyszewski) + * bug #9760 [Routing] Fix router matching pattern against multiple hosts (karolsojko) + * bug #9674 [Form] rename validators.ua.xlf to validators.uk.xlf (craue) + * bug #9722 [Validator]Fixed getting wrong msg when value is an object in Exception (aitboudad) + * bug #9750 allow TraceableEventDispatcher to reuse event instance in nested events (evillemez) + * bug #9718 [validator] throw an exception if isn't an instance of ConstraintValidatorInterface. (aitboudad) + * bug #9716 Reset the box model to content-box in the web debug toolbar (stof) + * bug #9711 [FrameworkBundle] Allowed "0" as a checkbox value in php templates (jakzal) + * bug #9665 [Bridge/Doctrine] ORMQueryBuilderLoader - handled the scenario when no entity manager is passed with closure query builder (jakzal) + * bug #9656 [DoctrineBridge] normalized class names in the ORM type guesser (fabpot) + * bug #9647 use the correct class name to retrieve mapped class' metadata and reposi... (xabbuh) + * bug #9648 [Debug] ensured that a fatal PHP error is actually fatal after being handled by our error handler (fabpot) + * bug #9643 [WebProfilerBundle] Fixed js escaping in time.html.twig (hason) + * bug #9641 [Debug] Avoid notice from being "eaten" by fatal error. (fabpot) + * bug #9639 Modified guessDefaultEscapingStrategy to not escape txt templates (fabpot) + * bug #9314 [Form] Fix DateType for 32bits computers. (WedgeSama) + * bug #9443 [FrameworkBundle] Fixed the registration of validation.xml file when the form is disabled (hason) + * bug #9625 [HttpFoundation] Do not return an empty session id if the session was closed (Taluu) + * bug #9637 [Validator] Replaced inexistent interface (jakzal) + * bug #9605 Adjusting CacheClear Warmup method to namespaced kernels (rdohms) + * bug #9610 Container::camelize also takes backslashes into consideration (ondrejmirtes) + * bug #9447 [BrowserKit] fixed protocol-relative url redirection (jong99) + * bug #9535 No Entity Manager defined exception (armetiz) + * bug #9485 [Acl] Fix for issue #9433 (guilro) + * bug #9516 [AclProvider] Fix incorrect behavior when partial results returned from cache (superdav42) + * bug #9352 [Intl] make currency bundle merge fallback locales when accessing data, ... (shieldo) + * bug #9537 [FrameworkBundle] Fix mistake in translation's service definition. (phpmike) + * bug #9367 [Process] Check if the pipe array is empty before calling stream_select() (jfposton) + * bug #9211 [Form] Fixed memory leak in FormValidator (bschussek) + * bug #9469 [Propel1] re-factor Propel1 ModelChoiceList (havvg) + * 2.3.7 (2013-11-14) * bug #9499 Request::overrideGlobals() may call invalid ini value (denkiryokuhatsuden) From 189ca544d6ee1e33f5345451c4e0278d19dc6fbc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Dec 2013 15:35:57 +0100 Subject: [PATCH 17/31] update CONTRIBUTORS for 2.3.8 --- CONTRIBUTORS.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 24834c7652..a14c40aaa2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -58,8 +58,8 @@ Symfony2 is the result of the work of many people who made the code better - Bart van den Burg (burgov) - Antoine Hérault (herzult) - Toni Uebernickel (havvg) - - Michel Weimerskirch (mweimerskirch) - Christian Raue + - Michel Weimerskirch (mweimerskirch) - Arnaud Le Blanc (arnaud-lb) - marc.weistroff - Brice BERNARD (brikou) @@ -68,10 +68,10 @@ Symfony2 is the result of the work of many people who made the code better - Włodzimierz Gajda (gajdaw) - Colin Frei - excelwebzone + - Wouter De Jong (wouterj) - Kevin Bond (kbond) - Fabien Pennequin (fabienpennequin) - Jacob Dreesen (jdreesen) - - Wouter De Jong (wouterj) - Adrien Brault (adrienbrault) - Michal Piotrowski (eventhorizon) - Robert Schönthal (digitalkaoz) @@ -94,6 +94,7 @@ Symfony2 is the result of the work of many people who made the code better - Amal Raghav (kertz) - Jonathan Ingram (jonathaningram) - Artur Kotyrba + - Ait Boudad Abdellatif (aitboudad) - Pablo Godel (pgodel) - Sebastiaan Stok (sstok) - Dmitrii Chekaliuk (lazyhammer) @@ -113,7 +114,6 @@ Symfony2 is the result of the work of many people who made the code better - Guilherme Blanco (guilhermeblanco) - Martin Schuhfuß (usefulthink) - Thomas Rabaix (rande) - - Ait Boudad Abdellatif (aitboudad) - Matthieu Bontemps (mbontemps) - Pierre Minnieur (pminnieur) - fivestar @@ -141,6 +141,7 @@ Symfony2 is the result of the work of many people who made the code better - Alif Rachmawadi - Joseph Rouff (rouffj) - Félix Labrecque (woodspire) + - Christian Flothmann (xabbuh) - GordonsLondon - Jan Sorgalla (jsor) - Ray @@ -160,8 +161,8 @@ Symfony2 is the result of the work of many people who made the code better - Florian Klein (docteurklein) - Matthias Pigulla (mpdude) - Manuel Kiessling (manuelkiessling) - - Christian Flothmann (xabbuh) - Bertrand Zuchuat (garfield-fr) + - Gabor Toth (tgabi333) - Thomas Tourlourat (armetiz) - Andrey Esaulov (andremaha) - Grégoire Passault (gregwar) @@ -169,6 +170,7 @@ Symfony2 is the result of the work of many people who made the code better - Aurelijus Valeiša (aurelijus) - Gustavo Piltcher - Stepan Tanasiychuk (stfalcon) + - Luis Cordova (cordoval) - Bob den Otter (bopp) - Adrian Rudnik (kreischweide) - Francesc Rosàs (frosas) @@ -182,6 +184,7 @@ Symfony2 is the result of the work of many people who made the code better - Vitaliy Zakharov (zakharovvi) - Gyula Sallai (salla) - Michele Orselli (orso) + - Christian Gärtner (dagardner) - Tom Van Looy (tvlooy) - Peter Kruithof (pkruithof) - Felix Labrecque @@ -196,7 +199,6 @@ Symfony2 is the result of the work of many people who made the code better - Atsuhiro KUBO (iteman) - sun (sun) - Lars Strojny - - Gabor Toth (tgabi333) - Costin Bereveanu (schniper) - realmfoo - Tamas Szijarto @@ -209,7 +211,6 @@ Symfony2 is the result of the work of many people who made the code better - Kai - Xavier HAUSHERR - Albert Jessurum (ajessu) - - Luis Cordova (cordoval) - Laszlo Korte - Tiago Ribeiro (fixe) - Alessandro Desantis @@ -235,7 +236,6 @@ Symfony2 is the result of the work of many people who made the code better - Olivier Dolbeau (odolbeau) - alquerci - vagrant - - Christian Gärtner (dagardner) - Asier Illarramendi (doup) - Christoph Mewes (xrstf) - Vitaliy Tverdokhlib (vitaliytv) @@ -276,6 +276,7 @@ Symfony2 is the result of the work of many people who made the code better - sasezaki - Denis Gorbachev (starfall) - Steven Surowiec + - giulio de donato (liuggio) - Marek Kalnik (marekkalnik) - Chris Smith - Anthon Pang @@ -406,7 +407,6 @@ Symfony2 is the result of the work of many people who made the code better - Timothée Barray (tyx) - Christian Morgan - Alexander Miehe (engerim) - - giulio de donato (liuggio) - Titouan Galopin (tgalopin) - Don Pinkster - Maksim Muruev @@ -419,6 +419,7 @@ Symfony2 is the result of the work of many people who made the code better - Arno Geurts - Adán Lobato (adanlobato) - Maks + - Gábor Tóth - Daniel Cestari - Magnus Nordlander (magnusnordlander) - Mikhail Yurasov (mym) @@ -575,6 +576,7 @@ Symfony2 is the result of the work of many people who made the code better - Rick Prent - Martin Eckhardt - Michael Dowling (mtdowling) + - Nicolas Grekas (nicolas-grekas) - BilgeXA - Robert Queck - mlively @@ -746,6 +748,7 @@ Symfony2 is the result of the work of many people who made the code better - Yorkie Chadwick (yorkie76) - Yanick Witschi - Ondrej Mirtes + - Youpie - srsbiz - Nicolas A. Bérard-Nault - Gladhon @@ -791,7 +794,6 @@ Symfony2 is the result of the work of many people who made the code better - Kaipi Yann - Sam Williams - James Michael DuPont - - Gábor Tóth - Tammy D - Ondrej Slinták - vlechemin @@ -800,8 +802,10 @@ Symfony2 is the result of the work of many people who made the code better - mieszko4 - datibbaw - Norbert Orzechowicz + - Markus Staab - Pierre-Louis LAUNAY - djama + - Eduardo Conceição - Jon Cave - Sébastien HOUZE - Abdulkadir N. A. From b0b421908d569e5024372ded65857707c409e0f7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Dec 2013 15:36:05 +0100 Subject: [PATCH 18/31] updated VERSION for 2.3.8 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 5e375c2dcf..7bbb3f1bf8 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.8-DEV'; + const VERSION = '2.3.8'; const VERSION_ID = '20308'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; const RELEASE_VERSION = '8'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From eccd938479f22cd16f2cad44586da4345eebfedb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Dec 2013 16:24:53 +0100 Subject: [PATCH 19/31] bumped Symfony version to 2.3.9 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 7bbb3f1bf8..15a596774d 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.8'; - const VERSION_ID = '20308'; + const VERSION = '2.3.9-DEV'; + const VERSION_ID = '20309'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; - const RELEASE_VERSION = '8'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '9'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 06985eb1230829311c170cb28c8609d47f86c6ad Mon Sep 17 00:00:00 2001 From: Wouter J Date: Sun, 10 Nov 2013 20:01:46 +0100 Subject: [PATCH 20/31] Do normalization on tag options --- .../Loader/XmlFileLoader.php | 4 ++++ .../Tests/Fixtures/xml/services10.xml | 16 +++++++++++++ .../Tests/Loader/XmlFileLoaderTest.php | 23 +++++++++++++++++++ .../DependencyInjection/services10.xml | 9 ++++++++ 4 files changed, 52 insertions(+) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services10.xml create mode 100644 src/Symfony/Component/DependencyInjection/services10.xml diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 9f25ab7683..b633ea101a 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -187,6 +187,10 @@ class XmlFileLoader extends FileLoader continue; } + if (false !== strpos($name, '-') && false === strpos($name, '_') && !array_key_exists($normalizedName = str_replace('-', '_', $name), $parameters)) { + $parameters[$normalizedName] = SimpleXMLElement::phpize($value); + } + // keep not normalized key for BC too $parameters[$name] = SimpleXMLElement::phpize($value); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services10.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services10.xml new file mode 100644 index 0000000000..a4da1bf74c --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services10.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index d8138f9475..faa8d70bd6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -198,6 +198,29 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); } + public function testParsesTags() + { + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('services10.xml'); + + $services = $container->findTaggedServiceIds('foo_tag'); + $this->assertCount(1, $services); + + foreach ($services as $id => $tagAttributes) { + foreach ($tagAttributes as $attributes) { + $this->assertArrayHasKey('other_option', $attributes); + $this->assertEquals('lorem', $attributes['other_option']); + $this->assertArrayHasKey('other-option', $attributes, 'unnormalized tag attributes should not be removed'); + + $this->assertEquals('ciz', $attributes['some_option'], 'no overriding should be done when normalizing'); + $this->assertEquals('cat', $attributes['some-option']); + + $this->assertArrayNotHasKey('an_other_option', $attributes, 'normalization should not be done when an underscore is already found'); + } + } + } + public function testConvertDomElementToArray() { $doc = new \DOMDocument("1.0"); diff --git a/src/Symfony/Component/DependencyInjection/services10.xml b/src/Symfony/Component/DependencyInjection/services10.xml new file mode 100644 index 0000000000..824d8b5d75 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/services10.xml @@ -0,0 +1,9 @@ + + + + + + + From 57ee5193d043f0a83241d71f5821f9a6a374dfdf Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Fri, 6 Dec 2013 12:57:11 +0100 Subject: [PATCH 21/31] BinaryFileResponse should also return 416 or 200 on some range-requets --- .../HttpFoundation/BinaryFileResponse.php | 19 +++--- .../Tests/BinaryFileResponseTest.php | 67 ++++++++++++++++++- 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 602b9fd655..d5dae23362 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -216,15 +216,18 @@ class BinaryFileResponse extends Response $start = (int) $start; } - $start = max($start, 0); - $end = min($end, $fileSize - 1); + if ($start <= $end) { + if ($start < 0 || $end > $fileSize - 1) { + $this->setStatusCode(self::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE); + } elseif ($start !== 0 || $end !== $fileSize - 1) { + $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; + $this->offset = $start; - $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; - $this->offset = $start; - - $this->setStatusCode(206); - $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); - $this->headers->set('Content-Length', $end - $start + 1); + $this->setStatusCode(self::HTTP_PARTIAL_CONTENT); + $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); + $this->headers->set('Content-Length', $end - $start + 1); + } + } } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index c3d324fa9f..75863168d1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -84,12 +84,73 @@ class BinaryFileResponseTest extends ResponseTestCase return array( array('bytes=1-4', 1, 4, 'bytes 1-4/35'), array('bytes=-5', 30, 5, 'bytes 30-34/35'), - array('bytes=-35', 0, 35, 'bytes 0-34/35'), - array('bytes=-40', 0, 35, 'bytes 0-34/35'), array('bytes=30-', 30, 5, 'bytes 30-34/35'), array('bytes=30-30', 30, 1, 'bytes 30-30/35'), array('bytes=30-34', 30, 5, 'bytes 30-34/35'), - array('bytes=30-40', 30, 5, 'bytes 30-34/35') + ); + } + + /** + * @dataProvider provideFullFileRanges + */ + public function testFullFileRequests($requestRange) + { + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag(); + + // prepare a request for a range of the testing file + $request = Request::create('/'); + $request->headers->set('Range', $requestRange); + + $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); + $data = fread($file, 35); + fclose($file); + + $this->expectOutputString($data); + $response = clone $response; + $response->prepare($request); + $response->sendContent(); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('binary', $response->headers->get('Content-Transfer-Encoding')); + } + + public function provideFullFileRanges() + { + return array( + array('bytes=0-'), + array('bytes=0-34'), + array('bytes=-35'), + // Syntactical invalid range-request should also return the full resource + array('bytes=20-10'), + array('bytes=50-40'), + ); + } + + /** + * @dataProvider provideInvalidRanges + */ + public function testInvalidRequests($requestRange) + { + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag(); + + // prepare a request for a range of the testing file + $request = Request::create('/'); + $request->headers->set('Range', $requestRange); + + $response = clone $response; + $response->prepare($request); + $response->sendContent(); + + $this->assertEquals(416, $response->getStatusCode()); + $this->assertEquals('binary', $response->headers->get('Content-Transfer-Encoding')); + #$this->assertEquals('', $response->headers->get('Content-Range')); + } + + public function provideInvalidRanges() + { + return array( + array('bytes=-40'), + array('bytes=30-40') ); } From 0bbde05d8d7f642fa660ea9ed6c3b816fe0c583e Mon Sep 17 00:00:00 2001 From: artem kolesnikov Date: Mon, 16 Dec 2013 23:03:11 +0200 Subject: [PATCH 22/31] Fixed issue in BaseDateTimeTransformer when invalid timezone cause Transformation filed exception (closes #9403). --- .../BaseDateTimeTransformer.php | 15 +++++++ .../BaseDateTimeTransformerTest.php | 41 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php index e4e8932ee9..9c1b92d741 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; +use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\Form\Exception\UnexpectedTypeException; abstract class BaseDateTimeTransformer implements DataTransformerInterface @@ -35,6 +36,7 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface * @param string $outputTimezone The name of the output timezone * * @throws UnexpectedTypeException if a timezone is not a string + * @throws InvalidArgumentException if a timezone is not valid */ public function __construct($inputTimezone = null, $outputTimezone = null) { @@ -48,5 +50,18 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface $this->inputTimezone = $inputTimezone ?: date_default_timezone_get(); $this->outputTimezone = $outputTimezone ?: date_default_timezone_get(); + + // Check if input and output timezones are valid + try { + new \DateTimeZone($this->inputTimezone); + } catch (\Exception $e) { + throw new InvalidArgumentException(sprintf('Input timezone is invalid: %s.', $this->inputTimezone), $e->getCode(), $e); + } + + try { + new \DateTimeZone($this->outputTimezone); + } catch (\Exception $e) { + throw new InvalidArgumentException(sprintf('Output timezone is invalid: %s.', $this->outputTimezone), $e->getCode(), $e); + } } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php new file mode 100644 index 0000000000..8f2d16bb1b --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; + +class BaseDateTimeTransformerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException + * @expectedExceptionMessage this_timezone_does_not_exist + */ + public function testConstructFailsIfInputTimezoneIsInvalid() + { + $this->getMock( + 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer', + array(), + array('this_timezone_does_not_exist') + ); + } + + /** + * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException + * @expectedExceptionMessage that_timezone_does_not_exist + */ + public function testConstructFailsIfOutputTimezoneIsInvalid() + { + $this->getMock( + 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer', + array(), + array(null, 'that_timezone_does_not_exist') + ); + } +} From 2e0bf0e2e17ac572bc935eedb8edfa6a38682301 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Wed, 4 Dec 2013 17:06:34 -0500 Subject: [PATCH 23/31] fix #7243 allow 0 as arraynode name --- .../Component/Config/Definition/ArrayNode.php | 2 +- .../Config/Tests/Definition/ArrayNodeTest.php | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index cf9ba08df8..e6ad51e4cc 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -210,7 +210,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface public function addChild(NodeInterface $node) { $name = $node->getName(); - if (empty($name)) { + if (!strlen($name)) { throw new \InvalidArgumentException('Child nodes must be named.'); } if (isset($this->children[$name])) { diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 34a2aece5e..831786233e 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Config\Tests\Definition; use Symfony\Component\Config\Definition\ArrayNode; +use Symfony\Component\Config\Definition\ScalarNode; +use Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy; class ArrayNodeTest extends \PHPUnit_Framework_TestCase { @@ -79,4 +81,52 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase ) ); } + + /** + * @dataProvider getZeroNamedNodeExamplesData + */ + public function testNodeNameCanBeZero($denormalized, $normalized) + { + $zeroNode = new ArrayNode(0); + $zeroNode->addChild(new ScalarNode('name')); + $fiveNode = new ArrayNode(5); + $fiveNode->addChild(new ScalarNode(0)); + $fiveNode->addChild(new ScalarNode('new_key')); + $rootNode = new ArrayNode('root'); + $rootNode->addChild($zeroNode); + $rootNode->addChild($fiveNode); + $rootNode->addChild(new ScalarNode('string_key')); + $r = new \ReflectionMethod($rootNode, 'normalizeValue'); + $r->setAccessible(true); + + $this->assertSame($normalized, $r->invoke($rootNode, $denormalized)); + } + + public function getZeroNamedNodeExamplesData() + { + return array( + array( + array( + 0 => array( + 'name' => 'something', + ), + 5 => array( + 0 => 'this won\'t work too', + 'new_key' => 'some other value', + ), + 'string_key' => 'just value', + ), + array( + 0 => array ( + 'name' => 'something', + ), + 5 => array ( + 0 => 'this won\'t work too', + 'new_key' => 'some other value', + ), + 'string_key' => 'just value', + ), + ), + ); + } } From bee06e9c5828b2eea98f09e39f672381c0a482df Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Wed, 4 Dec 2013 13:10:25 -0500 Subject: [PATCH 24/31] fix 5528 let ArrayNode::normalizeValue respect order of value array provided --- .../Component/Config/Definition/ArrayNode.php | 6 ++-- .../Config/Tests/Definition/ArrayNodeTest.php | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index e6ad51e4cc..d906fa3171 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -303,9 +303,9 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface $value = $this->remapXml($value); $normalized = array(); - foreach ($this->children as $name => $child) { - if (array_key_exists($name, $value)) { - $normalized[$name] = $child->normalize($value[$name]); + foreach ($value as $name => $val) { + if (isset($this->children[$name])) { + $normalized[$name] = $this->children[$name]->normalize($val); unset($value[$name]); } } diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 831786233e..39bc627a56 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -129,4 +129,33 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase ), ); } + + /** + * @dataProvider getPreNormalizedNormalizedOrderedData + */ + public function testChildrenOrderIsMaintainedOnNormalizeValue($prenormalized, $normalized) + { + $scalar1 = new ScalarNode('1'); + $scalar2 = new ScalarNode('2'); + $scalar3 = new ScalarNode('3'); + $node = new ArrayNode('foo'); + $node->addChild($scalar1); + $node->addChild($scalar3); + $node->addChild($scalar2); + + $r = new \ReflectionMethod($node, 'normalizeValue'); + $r->setAccessible(true); + + $this->assertSame($normalized, $r->invoke($node, $prenormalized)); + } + + public function getPreNormalizedNormalizedOrderedData() + { + return array( + array( + array('2' => 'two', '1' => 'one', '3' => 'three'), + array('2' => 'two', '1' => 'one', '3' => 'three'), + ), + ); + } } From faf2c8e97e3e668cd36ca30000abb00fd0c5c031 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 17 Dec 2013 09:02:48 +0100 Subject: [PATCH 25/31] [HttpFoundation] fixed constants that do exist in 2.3 (only in 2.4) --- src/Symfony/Component/HttpFoundation/BinaryFileResponse.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index d5dae23362..ddcb657ee2 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -218,12 +218,12 @@ class BinaryFileResponse extends Response if ($start <= $end) { if ($start < 0 || $end > $fileSize - 1) { - $this->setStatusCode(self::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE); + $this->setStatusCode(416); } elseif ($start !== 0 || $end !== $fileSize - 1) { $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; $this->offset = $start; - $this->setStatusCode(self::HTTP_PARTIAL_CONTENT); + $this->setStatusCode(206); $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); $this->headers->set('Content-Length', $end - $start + 1); } From 3132b0446ce060f3455bc2a309bf9babcb4459b5 Mon Sep 17 00:00:00 2001 From: Jerzy Zawadzki Date: Sat, 14 Dec 2013 14:38:37 +0100 Subject: [PATCH 26/31] [BrowserKit] fixes #8311 CookieJar is totally ignorant of RFC 6265 edge cases --- .../Component/BrowserKit/CookieJar.php | 20 +++++++++++++++- .../BrowserKit/Tests/CookieJarTest.php | 24 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/BrowserKit/CookieJar.php b/src/Symfony/Component/BrowserKit/CookieJar.php index 6288fbc116..4ecfddbf4a 100644 --- a/src/Symfony/Component/BrowserKit/CookieJar.php +++ b/src/Symfony/Component/BrowserKit/CookieJar.php @@ -55,7 +55,25 @@ class CookieJar $this->flushExpiredCookies(); if (!empty($domain)) { - return isset($this->cookieJar[$domain][$path][$name]) ? $this->cookieJar[$domain][$path][$name] : null; + foreach ($this->cookieJar as $cookieDomain => $pathCookies) { + if ($cookieDomain) { + $cookieDomain = '.'.ltrim($cookieDomain, '.'); + if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) { + continue; + } + } + + foreach ($pathCookies as $cookiePath => $namedCookies) { + if ($cookiePath != substr($path, 0, strlen($cookiePath))) { + continue; + } + if (isset($namedCookies[$name])) { + return $namedCookies[$name]; + } + } + } + + return null; } // avoid relying on this behavior that is mainly here for BC reasons diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index 77c5ca49bb..843e49709a 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -196,6 +196,30 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://bar.example.com/')); } + public function testCookieGetWithSubdomain() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/', '.example.com')); + $cookieJar->set($cookie2 = new Cookie('foo1', 'bar', null, '/', 'test.example.com')); + + $this->assertEquals($cookie1, $cookieJar->get('foo','/','foo.example.com')); + $this->assertEquals($cookie1, $cookieJar->get('foo','/','example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1','/','test.example.com')); + } + + public function testCookieGetWithSubdirectory() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/test', '.example.com')); + $cookieJar->set($cookie2 = new Cookie('foo1', 'bar1', null, '/', '.example.com')); + + $this->assertNull($cookieJar->get('foo','/','.example.com')); + $this->assertNull($cookieJar->get('foo','/bar','.example.com')); + $this->assertEquals($cookie1, $cookieJar->get('foo','/test','example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1','/','example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1','/bar','example.com')); + } + public function testCookieWithWildcardDomain() { $cookieJar = new CookieJar(); From eb86af961d8872cd8cc8874c179a69a56e240bbd Mon Sep 17 00:00:00 2001 From: Matthieu Auger Date: Thu, 19 Dec 2013 23:14:26 +0100 Subject: [PATCH 27/31] fix #9356 [Security] Logger should manipulate the user reloaded from provider --- .../Component/Security/Http/Firewall/ContextListener.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 81ccbdc0dd..60ab3dfdfb 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -156,10 +156,11 @@ class ContextListener implements ListenerInterface foreach ($this->userProviders as $provider) { try { - $token->setUser($provider->refreshUser($user)); + $refreshedUser = $provider->refreshUser($user); + $token->setUser($refreshedUser); if (null !== $this->logger) { - $this->logger->debug(sprintf('Username "%s" was reloaded from user provider.', $user->getUsername())); + $this->logger->debug(sprintf('Username "%s" was reloaded from user provider.', $refreshedUser->getUsername())); } return $token; @@ -167,7 +168,7 @@ class ContextListener implements ListenerInterface // let's try the next user provider } catch (UsernameNotFoundException $notFound) { if (null !== $this->logger) { - $this->logger->warning(sprintf('Username "%s" could not be found.', $user->getUsername())); + $this->logger->warning(sprintf('Username "%s" could not be found.', $notFound->getUsername())); } return null; From c6f210b5adcf30f41c998a183811c78a80de328d Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Fri, 20 Dec 2013 22:29:30 +0100 Subject: [PATCH 28/31] [DependencyInjection] Fixed support for backslashes in service ids. This change is for consistency with camelize() which is used in ProxyDumper and PhpDumper. --- src/Symfony/Component/DependencyInjection/Container.php | 6 +++--- .../Component/DependencyInjection/Tests/ContainerTest.php | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index fff5e401ca..5becc3cf73 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -214,7 +214,7 @@ class Container implements IntrospectableContainerInterface $this->services[$id] = $service; - if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_')).'Service')) { + if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')) { $this->$method(); } @@ -243,7 +243,7 @@ class Container implements IntrospectableContainerInterface return isset($this->services[$id]) || array_key_exists($id, $this->services) || isset($this->aliases[$id]) - || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service') + || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service') ; } @@ -291,7 +291,7 @@ class Container implements IntrospectableContainerInterface if (isset($this->methodMap[$id])) { $method = $this->methodMap[$id]; - } elseif (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) { + } elseif (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')) { // $method is set to the right value, proceed } else { if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index f2d0760192..e145c7a10c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -188,6 +188,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); $this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); $this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); + $this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); $sc->set('bar', $bar = new \stdClass()); $this->assertEquals($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); @@ -259,6 +260,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined'); $this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined'); $this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined'); + $this->assertTrue($sc->has('foo\\baz'), '->has() returns true if a get*Method() is defined'); } /** From 47a822de07bc2e058d602a70de1faafad695b8ad Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Fri, 20 Dec 2013 09:57:17 -0500 Subject: [PATCH 29/31] add memcache, memcached, and mongodb extensions to run skipped tests --- .travis.yml | 5 +++++ src/Symfony/Component/Intl/Util/SvnRepository.php | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b725715a41..76fd27aef3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,15 @@ php: - 5.4 - 5.5 +services: mongodb + before_script: - sudo apt-get install parallel - echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + - echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install script: diff --git a/src/Symfony/Component/Intl/Util/SvnRepository.php b/src/Symfony/Component/Intl/Util/SvnRepository.php index fb44e3c6c6..3fb3acb4fd 100644 --- a/src/Symfony/Component/Intl/Util/SvnRepository.php +++ b/src/Symfony/Component/Intl/Util/SvnRepository.php @@ -137,5 +137,4 @@ class SvnRepository return $this->svnInfo; } - } From 408d992a3f2d2bc45572514709972f5155f36595 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 23 Dec 2013 10:20:48 +0100 Subject: [PATCH 30/31] [DependencyInjection] fixed typo --- src/Symfony/Component/DependencyInjection/Container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 5becc3cf73..ecf35ee4a0 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -271,7 +271,7 @@ class Container implements IntrospectableContainerInterface // Attempt to retrieve the service by checking first aliases then // available services. Service IDs are case insensitive, however since // this method can be called thousands of times during a request, avoid - // calling strotolower() unless necessary. + // calling strtolower() unless necessary. foreach (array(false, true) as $strtolower) { if ($strtolower) { $id = strtolower($id); From 2d64dfc872384ef16c4a1ac271276289acc1593c Mon Sep 17 00:00:00 2001 From: David de Boer Date: Tue, 17 Dec 2013 21:46:42 +0100 Subject: [PATCH 31/31] Fix parent serialization of user object --- .../Authentication/Token/AbstractToken.php | 9 +++- .../Token/AbstractTokenTest.php | 41 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index 1d65819a43..b9947330e0 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -146,7 +146,14 @@ abstract class AbstractToken implements TokenInterface */ public function serialize() { - return serialize(array($this->user, $this->authenticated, $this->roles, $this->attributes)); + return serialize( + array( + is_object($this->user) ? clone $this->user : $this->user, + $this->authenticated, + $this->roles, + $this->attributes + ) + ); } /** diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php index 783c27e1bb..5683b782cb 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php @@ -11,7 +11,9 @@ namespace Symfony\Component\Security\Tests\Core\Authentication\Token; +use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; use Symfony\Component\Security\Core\Role\Role; +use Symfony\Component\Security\Core\Role\SwitchUserRole; class TestUser { @@ -28,6 +30,31 @@ class TestUser } } +class ConcreteToken extends AbstractToken +{ + private $credentials = 'credentials_value'; + + public function __construct($user, array $roles = array()) + { + parent::__construct($roles); + + $this->setUser($user); + } + + public function serialize() + { + return serialize(array($this->credentials, parent::serialize())); + } + + public function unserialize($serialized) + { + list($this->credentials, $parentStr) = unserialize($serialized); + parent::unserialize($parentStr); + } + + public function getCredentials() {} +} + class AbstractTokenTest extends \PHPUnit_Framework_TestCase { public function testGetUsername() @@ -71,6 +98,20 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase $this->assertEquals($token->getAttributes(), $uToken->getAttributes()); } + public function testSerializeParent() + { + $user = new TestUser('fabien'); + $token = new ConcreteToken($user, array('ROLE_FOO')); + + $parentToken = new ConcreteToken($user, array(new SwitchUserRole('ROLE_PREVIOUS', $token))); + $uToken = unserialize(serialize($parentToken)); + + $this->assertEquals( + current($parentToken->getRoles())->getSource()->getUser(), + current($uToken->getRoles())->getSource()->getUser() + ); + } + /** * @covers Symfony\Component\Security\Core\Authentication\Token\AbstractToken::__construct */