diff --git a/CHANGELOG-2.1.md b/CHANGELOG-2.1.md index cf59cb7070..03074c23db 100644 --- a/CHANGELOG-2.1.md +++ b/CHANGELOG-2.1.md @@ -7,7 +7,7 @@ in 2.1 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.1.0...v2.1.1 -* 2.1.4 (2012-12-29) +* 2.1.4 (2012-11-29) * e5536f0: replaced magic strings by proper constants * 6a3ba52: fixed the logic in Request::isSecure() (if the information comes from a source that we trust, don't check other ones) diff --git a/README.md b/README.md index 7766b38da6..f50ccefeb3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ README ====== -[![Build Status](https://secure.travis-ci.org/symfony/symfony.png?branch=master)](http://travis-ci.org/symfony/symfony) - What is Symfony2? ----------------- diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 5ac205a1d7..0cdfe03cd0 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -77,16 +77,16 @@ abstract class DoctrineType extends AbstractType // A second parameter ($key) is passed, so we cannot use // spl_object_hash() directly (which strictly requires // one parameter) - array_walk_recursive($choiceHashes, function ($value) { - return spl_object_hash($value); + array_walk_recursive($choiceHashes, function (&$value) { + $value = spl_object_hash($value); }); } $preferredChoiceHashes = $options['preferred_choices']; if (is_array($preferredChoiceHashes)) { - array_walk_recursive($preferredChoiceHashes, function ($value) { - return spl_object_hash($value); + array_walk_recursive($preferredChoiceHashes, function (&$value) { + $value = spl_object_hash($value); }); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index cb69d8b6ae..02312de64b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -86,4 +86,4 @@ class DoctrineOrmTypeGuesserTest extends \PHPUnit_Framework_TestCase return new DoctrineOrmTypeGuesser($registry); } -} \ No newline at end of file +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index e73dd11be0..8c3ee842d5 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -104,7 +104,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase { $this->setMaxRunningTime(1); - for ($i = 0; $i < 20; ++$i) { + for ($i = 0; $i < 40; ++$i) { $form = $this->factory->create('entity', null, array( 'class' => self::ENTITY_CLASS, )); @@ -114,11 +114,14 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase } } + /** + * @group benchmark + */ public function testCollapsedEntityFieldWithQueryBuilder() { $this->setMaxRunningTime(1); - for ($i = 0; $i < 20; ++$i) { + for ($i = 0; $i < 40; ++$i) { $form = $this->factory->create('entity', null, array( 'class' => self::ENTITY_CLASS, 'query_builder' => function (EntityRepository $repo) { @@ -130,4 +133,42 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $form->createView(); } } + + /** + * @group benchmark + */ + public function testCollapsedEntityFieldWithChoices() + { + $choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult(); + $this->setMaxRunningTime(1); + + for ($i = 0; $i < 40; ++$i) { + $form = $this->factory->create('entity', null, array( + 'class' => self::ENTITY_CLASS, + 'choices' => $choices, + )); + + // force loading of the choice list + $form->createView(); + } + } + + /** + * @group benchmark + */ + public function testCollapsedEntityFieldWithPreferredChoices() + { + $choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult(); + $this->setMaxRunningTime(1); + + for ($i = 0; $i < 40; ++$i) { + $form = $this->factory->create('entity', null, array( + 'class' => self::ENTITY_CLASS, + 'preferred_choices' => $choices, + )); + + // force loading of the choice list + $form->createView(); + } + } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index ffe0a37b99..c4ca0eecdf 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Tests\Logger; - class DbalLoggerTest extends \PHPUnit_Framework_TestCase { /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index 3e7fff9c8e..87900a1242 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -78,7 +78,7 @@ class Controller extends ContainerAware * @param string $view The view name * @param array $parameters An array of parameters to pass to the view * - * @return string The renderer view + * @return string The rendered view */ public function renderView($view, array $parameters = array()) { diff --git a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php index 1db01def30..2216c47f27 100755 --- a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php @@ -23,7 +23,7 @@ class EnumNodeDefinition extends ScalarNodeDefinition } $this->values = $values; - + return $this; } @@ -40,4 +40,4 @@ class EnumNodeDefinition extends ScalarNodeDefinition return new EnumNode($this->name, $this->parent, $this->values); } -} \ No newline at end of file +} diff --git a/src/Symfony/Component/Config/Loader/Loader.php b/src/Symfony/Component/Config/Loader/Loader.php index b9c174f94d..9acfb7b0c0 100644 --- a/src/Symfony/Component/Config/Loader/Loader.php +++ b/src/Symfony/Component/Config/Loader/Loader.php @@ -47,10 +47,12 @@ abstract class Loader implements LoaderInterface * * @param mixed $resource A Resource * @param string $type The resource type + * + * @return mixed */ public function import($resource, $type = null) { - $this->resolve($resource)->load($resource, $type); + return $this->resolve($resource)->load($resource, $type); } /** diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index 5b14e19777..8ce5a8b68e 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -55,6 +55,15 @@ class LoaderTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderLoadException', $e, '->resolve() throws a FileLoaderLoadException if the resource cannot be loaded'); } } + + public function testImport() + { + $loader = $this->getMock('Symfony\Component\Config\Loader\Loader', array('supports', 'load')); + $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); + $loader->expects($this->once())->method('load')->will($this->returnValue('yes')); + + $this->assertEquals('yes', $loader->import('foo')); + } } class ProjectLoader1 extends Loader diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 14527c1351..7e2833580c 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -242,7 +242,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->assertRegExp('/Did you mean this/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); } - $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 5f3b809ce9..33187a7d26 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Component\Console\Tests\Formatter; use Symfony\Component\Console\Formatter\OutputFormatter; diff --git a/src/Symfony/Component/CssSelector/Node/FunctionNode.php b/src/Symfony/Component/CssSelector/Node/FunctionNode.php index b392b27d07..d645c20aa1 100644 --- a/src/Symfony/Component/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -209,7 +209,6 @@ class FunctionNode implements NodeInterface $xpath->addCondition(sprintf('contains(string(.), %s)', XPathExpr::xpathLiteral($expr))); // FIXME: Currently case insensitive matching doesn't seem to be happening - return $xpath; } @@ -264,7 +263,6 @@ class FunctionNode implements NodeInterface if (false === strpos($s, 'n')) { // Just a b - return array(0, intval((string) $s)); } diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 23c58721fe..cb03996d32 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -360,7 +360,7 @@ class Filesystem if ($copyOnWindows) { if (is_link($file) || is_file($file)) { $this->copy($file, $target, isset($options['override']) ? $options['override'] : false); - } else if (is_dir($file)) { + } elseif (is_dir($file)) { $this->mkdir($target); } else { throw new IOException(sprintf('Unable to guess "%s" file type.', $file)); @@ -368,9 +368,9 @@ class Filesystem } else { if (is_link($file)) { $this->symlink($file, $target); - } else if (is_dir($file)) { + } elseif (is_dir($file)) { $this->mkdir($target); - } else if (is_file($file)) { + } elseif (is_file($file)) { $this->copy($file, $target, isset($options['override']) ? $options['override'] : false); } else { throw new IOException(sprintf('Unable to guess "%s" file type.', $file)); diff --git a/src/Symfony/Component/Finder/SplFileInfo.php b/src/Symfony/Component/Finder/SplFileInfo.php index ee3d8ecf43..e9d4f7b72f 100644 --- a/src/Symfony/Component/Finder/SplFileInfo.php +++ b/src/Symfony/Component/Finder/SplFileInfo.php @@ -62,10 +62,14 @@ class SplFileInfo extends \SplFileInfo */ public function getContents() { - $file = new \SplFileObject($this->getRealpath(), 'rb'); - ob_start(); - $file->fpassthru(); + $level = error_reporting(0); + $content = file_get_contents($this->getRealpath()); + error_reporting($level); + if (false === $content) { + $error = error_get_last(); + throw new \RuntimeException($error['message']); + } - return ob_get_clean(); + return $content; } } diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php index fcccfdd0bd..4fbca4b451 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php @@ -261,7 +261,7 @@ class ChoiceList implements ChoiceListInterface { // Add choices to the nested buckets foreach ($choices as $group => $choice) { - if (!isset($labels[$group])) { + if (!array_key_exists($group, $labels)) { throw new \InvalidArgumentException('The structures of the choices and labels array do not match.'); } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php index 4062759913..7131ff6519 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php @@ -53,7 +53,6 @@ class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer return null; } - $dateTime = new \DateTime($rfc3339); if ($this->outputTimezone !== $this->inputTimezone) { diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 52a681f269..c659a77f04 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -180,6 +180,10 @@ class DateType extends AbstractType ); }; + $format = function (Options $options) { + return $options['widget'] === 'single_text' ? DateType::HTML5_FORMAT : DateType::DEFAULT_FORMAT; + }; + // BC until Symfony 2.3 $modelTimezone = function (Options $options) { return $options['data_timezone']; @@ -196,7 +200,7 @@ class DateType extends AbstractType 'days' => range(1, 31), 'widget' => 'choice', 'input' => 'datetime', - 'format' => self::HTML5_FORMAT, + 'format' => $format, 'model_timezone' => $modelTimezone, 'view_timezone' => $viewTimezone, // Deprecated timezone options diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php index 675eff313f..58368c7c3d 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -46,7 +46,7 @@ class FileType extends AbstractType { $resolver->setDefaults(array( 'compound' => false, - 'data_class' => 'Symfony\Component\HttpFoundation\File\File' + 'data_class' => 'Symfony\Component\HttpFoundation\File\File' )); } diff --git a/src/Symfony/Component/Form/Guess/Guess.php b/src/Symfony/Component/Form/Guess/Guess.php index 84407925a7..f24407dd73 100644 --- a/src/Symfony/Component/Form/Guess/Guess.php +++ b/src/Symfony/Component/Form/Guess/Guess.php @@ -90,7 +90,7 @@ abstract class Guess */ public function __construct($confidence) { - if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence && + if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence && self::MEDIUM_CONFIDENCE !== $confidence && self::LOW_CONFIDENCE !== $confidence) { throw new \InvalidArgumentException('The confidence should be one of the constants defined in Guess.'); } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 527d73a7f5..1f296a81df 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -809,14 +809,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase [@id="name_date"] [ ./select - [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] - /following-sibling::select [@id="name_date_month"] [./option[@value="2"][@selected="selected"]] /following-sibling::select [@id="name_date_day"] [./option[@value="3"][@selected="selected"]] + /following-sibling::select + [@id="name_date_year"] + [./option[@value="2011"][@selected="selected"]] ] /following-sibling::div [@id="name_time"] @@ -849,14 +849,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase [@id="name_date"] [ ./select - [@id="name_date_year"] - [./option[@value=""][.="[trans]Change&Me[/trans]"]] - /following-sibling::select [@id="name_date_month"] [./option[@value=""][.="[trans]Change&Me[/trans]"]] /following-sibling::select [@id="name_date_day"] [./option[@value=""][.="[trans]Change&Me[/trans]"]] + /following-sibling::select + [@id="name_date_year"] + [./option[@value=""][.="[trans]Change&Me[/trans]"]] ] /following-sibling::div [@id="name_time"] @@ -889,14 +889,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase [@id="name_date"] [ ./select - [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] - /following-sibling::select [@id="name_date_month"] [./option[@value="2"][@selected="selected"]] /following-sibling::select [@id="name_date_day"] [./option[@value="3"][@selected="selected"]] + /following-sibling::select + [@id="name_date_year"] + [./option[@value="2011"][@selected="selected"]] ] /following-sibling::div [@id="name_time"] @@ -928,14 +928,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase [@id="name_date"] [ ./select - [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] - /following-sibling::select [@id="name_date_month"] [./option[@value="2"][@selected="selected"]] /following-sibling::select [@id="name_date_day"] [./option[@value="3"][@selected="selected"]] + /following-sibling::select + [@id="name_date_year"] + [./option[@value="2011"][@selected="selected"]] ] /following-sibling::div [@id="name_time"] @@ -1031,14 +1031,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase '/div [ ./select - [@id="name_year"] - [./option[@value="2011"][@selected="selected"]] - /following-sibling::select [@id="name_month"] [./option[@value="2"][@selected="selected"]] /following-sibling::select [@id="name_day"] [./option[@value="3"][@selected="selected"]] + /following-sibling::select + [@id="name_year"] + [./option[@value="2011"][@selected="selected"]] ] [count(./select)=3] ' @@ -1058,14 +1058,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase '/div [ ./select - [@id="name_year"] - [./option[@value=""][.="[trans]Change&Me[/trans]"]] - /following-sibling::select [@id="name_month"] [./option[@value=""][.="[trans]Change&Me[/trans]"]] /following-sibling::select [@id="name_day"] [./option[@value=""][.="[trans]Change&Me[/trans]"]] + /following-sibling::select + [@id="name_year"] + [./option[@value=""][.="[trans]Change&Me[/trans]"]] ] [count(./select)=3] ' @@ -1085,14 +1085,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase '/div [ ./select - [@id="name_year"] - [./option[@value=""][.="[trans]Change&Me[/trans]"]] - /following-sibling::select [@id="name_month"] [./option[@value="1"]] /following-sibling::select [@id="name_day"] [./option[@value="1"]] + /following-sibling::select + [@id="name_year"] + [./option[@value=""][.="[trans]Change&Me[/trans]"]] ] [count(./select)=3] ' @@ -1110,10 +1110,6 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase '/div [ ./input - [@id="name_year"] - [@type="text"] - [@value="2011"] - /following-sibling::input [@id="name_month"] [@type="text"] [@value="2"] @@ -1121,6 +1117,10 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase [@id="name_day"] [@type="text"] [@value="3"] + /following-sibling::input + [@id="name_year"] + [@type="text"] + [@value="2011"] ] [count(./input)=3] ' @@ -1164,14 +1164,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase '/div [ ./select - [@id="name_year"] - [./option[@value="2000"][@selected="selected"]] - /following-sibling::select [@id="name_month"] [./option[@value="2"][@selected="selected"]] /following-sibling::select [@id="name_day"] [./option[@value="3"][@selected="selected"]] + /following-sibling::select + [@id="name_year"] + [./option[@value="2000"][@selected="selected"]] ] [count(./select)=3] ' @@ -1190,10 +1190,6 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase '/div [ ./select - [@id="name_year"] - [./option[@value=""][.="[trans][/trans]"]] - [./option[@value="1950"][@selected="selected"]] - /following-sibling::select [@id="name_month"] [./option[@value=""][.="[trans][/trans]"]] [./option[@value="1"][@selected="selected"]] @@ -1201,6 +1197,10 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase [@id="name_day"] [./option[@value=""][.="[trans][/trans]"]] [./option[@value="1"][@selected="selected"]] + /following-sibling::select + [@id="name_year"] + [./option[@value=""][.="[trans][/trans]"]] + [./option[@value="1950"][@selected="selected"]] ] [count(./select)=3] ' diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php index 86533e8af8..63eae9bf7f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php @@ -184,4 +184,17 @@ class ChoiceListTest extends \PHPUnit_Framework_TestCase array('A') ); } + + public function testLabelsContainingNull() + { + $this->list = new ChoiceList( + array($this->obj1, $this->obj2), + array('A', null) + ); + + $this->assertEquals( + array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', null)), + $this->list->getRemainingViews() + ); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php index 9683aa1e20..e9596b3efb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php @@ -18,4 +18,3 @@ abstract class DateTimeTestCase extends LocalizedTestCase self::assertEquals($expected->format('c'), $actual->format('c')); } } - diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index 13b9d06207..fdff501668 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -510,18 +510,18 @@ class DateTypeTest extends LocalizedTestCase $form = $this->factory->create('date'); $view = $form->createView(); - $this->assertSame('{{ year }}-{{ month }}-{{ day }}', $view->vars['date_pattern']); + $this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->vars['date_pattern']); } public function testPassDatePatternToViewDifferentFormat() { $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, + 'format' => \IntlDateFormatter::LONG, )); $view = $form->createView(); - $this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->vars['date_pattern']); + $this->assertSame('{{ day }}. {{ month }} {{ year }}', $view->vars['date_pattern']); } public function testPassDatePatternToViewDifferentPattern() diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index b3d9608cc3..e192f07108 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -227,7 +227,6 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase { // The mapping must be deterministic! If a child has the property path "[street]", // "data[street]" should be mapped, but "data.street" should not! - return array( // mapping target, child name, its property path, grand child name, its property path, violation path array(self::LEVEL_0, 'address', 'address', 'street', 'street', ''), @@ -1260,7 +1259,6 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase // 1) the error actually maps to an existing child and // 2) the property path of that child (relative to the form providing // the mapping) matches the left side of the mapping - return array( // mapping target, map from, map to, child name, its property path, grand child name, its property path, violation path array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index f26899d007..2360e55bb4 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -317,7 +317,7 @@ class HeaderBag implements \IteratorAggregate, \Countable $cacheControl = array(); preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER); foreach ($matches as $match) { - $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true); + $cacheControl[strtolower($match[1])] = isset($match[3]) ? $match[3] : (isset($match[2]) ? $match[2] : true); } return $cacheControl; diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 492675c03e..95bd4218f6 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1007,7 +1007,7 @@ class Request // trim and remove port number from host // host is lowercase as per RFC 952/2181 - $host = strtolower(trim(preg_replace('/:\d+$/', '', $host))); + $host = strtolower(preg_replace('/:\d+$/', '', trim($host))); // as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user) // check that it does not contain forbidden characters (see RFC 952 and RFC 2181) diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index 536cc7b075..49b92f0e2c 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -150,4 +150,3 @@ class RequestMatcher implements RequestMatcherInterface return true; } } - diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index ac56f9b2df..f24c491057 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -245,6 +245,12 @@ class Response $this->setProtocolVersion('1.1'); } + // Check if we need to send extra expire info headers + if ('1.0' == $this->getProtocolVersion() && 'no-cache' == $this->headers->get('Cache-Control')) { + $this->headers->set('pragma', 'no-cache'); + $this->headers->set('expires', -1); + } + return $this; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php index 20d3603038..b1bfefbf87 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php @@ -168,6 +168,13 @@ class HeaderBagTest extends \PHPUnit_Framework_TestCase $this->assertEquals('max-age=10, public, s-maxage=100', $bag->get('cache-control')); } + public function testCacheControlDirectiveParsingQuotedZero() + { + $bag = new HeaderBag(array('cache-control' => 'max-age="0"')); + $this->assertTrue($bag->hasCacheControlDirective('max-age')); + $this->assertEquals(0, $bag->getCacheControlDirective('max-age')); + } + public function testCacheControlDirectiveOverrideWithReplace() { $bag = new HeaderBag(array('cache-control' => 'private, max-age=100')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index c14dc4b83d..4fc93c33ef 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -351,6 +351,23 @@ class ResponseTest extends \PHPUnit_Framework_TestCase $this->assertEquals('', $response->getContent()); } + public function testPrepareSetsPragmaOnHttp10Only() + { + $request = Request::create('/', 'GET'); + $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0'); + + $response = new Response('foo'); + $response->prepare($request); + $this->assertEquals('no-cache', $response->headers->get('pragma')); + $this->assertEquals('-1', $response->headers->get('expires')); + + $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1'); + $response = new Response('foo'); + $response->prepare($request); + $this->assertFalse($response->headers->has('pragma')); + $this->assertFalse($response->headers->has('expires')); + } + public function testSetCache() { $response = new Response(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index 9f58f2d583..de2c4939f0 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -54,6 +54,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase public function savePathDataProvider() { $base = sys_get_temp_dir(); + return array( array("$base/foo", "$base/foo", "$base/foo"), array("5;$base/foo", "5;$base/foo", "$base/foo"), diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php index b2d148d4c3..b63b84c0fb 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php @@ -40,7 +40,7 @@ class MongoDbProfilerStorageTestDataCollector extends DataCollector public function collect(Request $request, Response $response, \Exception $exception = null) { } - + public function getName() { return 'test_data_collector'; @@ -126,4 +126,3 @@ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest } } } - diff --git a/src/Symfony/Component/Locale/Resources/data/build-data.php b/src/Symfony/Component/Locale/Resources/data/build-data.php index 8f27830a43..0382cb8d35 100644 --- a/src/Symfony/Component/Locale/Resources/data/build-data.php +++ b/src/Symfony/Component/Locale/Resources/data/build-data.php @@ -125,7 +125,8 @@ function get_data($index, $dataDir, $locale = 'en', $constraint = null) return $data; } -function icu_version() { +function icu_version() +{ exec('icu-config --version', $output, $result); if ($result !== 0 || !isset($output[0])) { @@ -135,13 +136,15 @@ function icu_version() { return $output[0]; } -function normalize_icu_version($version) { +function normalize_icu_version($version) +{ preg_match('/^(?P[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches); return $matches['version']; } -function download_icu_data($version) { +function download_icu_data($version) +{ $icu = parse_ini_file(__DIR__.'/icu.ini'); if (!isset($icu[$version])) { @@ -624,4 +627,4 @@ create_stub_datafile($defaultLocale, $stubRegionDir, $countries); // Clean up clear_directory($currDir); -rmdir($currDir); \ No newline at end of file +rmdir($currDir); diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 66ccc91189..e0c4b1e7e8 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Process\Process; */ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase { - protected abstract function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()); + abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()); /** * @expectedException Symfony\Component\Process\Exception\InvalidArgumentException @@ -282,7 +282,6 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Windows does not support POSIX signals'); } - $process = $this->getProcess('php -r "while (true) {}"'); $process->start(); $process->stop(); diff --git a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php index dc7cbe549b..dd7a7d5547 100644 --- a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php +++ b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php @@ -58,7 +58,6 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle return $this->httpUtils->createRedirectResponse($request, $this->determineTargetUrl($request)); } - /** * Get the provider key. * diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index b1ba24b83f..fddd3c7275 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -75,6 +75,7 @@ class ContextListener implements ListenerInterface if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) { $this->context->setToken(null); + return; } diff --git a/src/Symfony/Component/Security/Http/HttpUtils.php b/src/Symfony/Component/Security/Http/HttpUtils.php index 1c87e770a1..76cfc6af09 100644 --- a/src/Symfony/Component/Security/Http/HttpUtils.php +++ b/src/Symfony/Component/Security/Http/HttpUtils.php @@ -106,7 +106,7 @@ class HttpUtils } } - return $path === $request->getPathInfo(); + return $path === rawurldecode($request->getPathInfo()); } /** diff --git a/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php b/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php index a30051fdd0..fc1b754db9 100644 --- a/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php @@ -97,6 +97,11 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase $this->assertTrue($utils->checkRequestPath($this->getRequest(), '/')); $this->assertFalse($utils->checkRequestPath($this->getRequest(), '/foo')); + $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo%20bar'), '/foo bar')); + // Plus must not decoded to space + $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo+bar'), '/foo+bar')); + // Checking unicode + $this->assertTrue($utils->checkRequestPath($this->getRequest(urlencode('/вход')), '/вход')); $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); $urlMatcher diff --git a/src/Symfony/Component/Validator/Constraints/Regex.php b/src/Symfony/Component/Validator/Constraints/Regex.php index f26186cb13..fb5dcc1a73 100644 --- a/src/Symfony/Component/Validator/Constraints/Regex.php +++ b/src/Symfony/Component/Validator/Constraints/Regex.php @@ -62,7 +62,7 @@ class Regex extends Constraint * Convert the htmlPattern to a suitable format for HTML5 pattern. * Example: /^[a-z]+$/ would be converted to [a-z]+ * However, if options are specified, it cannot be converted - * + * * Pattern is also ignored if match=false since the pattern should * then be reversed before application. * @@ -78,7 +78,7 @@ class Regex extends Constraint if (!$this->match) { return null; } - + if (preg_match('/^(.)(\^?)(.*?)(\$?)\1$/', $this->pattern, $matches)) { $delimiter = $matches[1]; $start = empty($matches[2]) ? '.*' : ''; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 1cc0609f5a..43c886ae46 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -162,7 +162,7 @@ class RegexValidatorTest extends \PHPUnit_Framework_TestCase 'pattern' => '/[a-z]+/', )); $this->assertEquals('.*[a-z]+.*', $constraint->getHtmlPattern()); - + // Dropped because of match=false $constraint = new Regex(array( 'pattern' => '/[a-z]+/', @@ -170,5 +170,4 @@ class RegexValidatorTest extends \PHPUnit_Framework_TestCase )); $this->assertNull($constraint->getHtmlPattern()); } - }