Skip to content

Commit

Permalink
Merge branch '2.1'
Browse files Browse the repository at this point in the history
* 2.1:
  fixed CS
  fixed CS
  [Security] fixed path info encoding (closes #6040, closes #5695)
  [HttpFoundation] added some tests for the previous merge and removed dead code (closes #6037)
  Improved Cache-Control header when no-cache is sent
  removed unneeded comment
  Fix to allow null values in labels array
  fix date in changelog
  removed the Travis icon (as this is not stable enough -- many false positive, closes #6186)
  Revert "merged branch gajdaw/finder_splfileinfo_fpassthu (PR #4751)" (closes #6224)
  Fixed a typo
  Fixed: HeaderBag::parseCacheControl() not parsing quoted zero correctly
  [Form] Fix const inside an anonymous function
  [Config] Loader::import must return imported data
  [DoctrineBridge] Fixed caching in DoctrineType when "choices" or "preferred_choices" is passed
  [Form] Fixed the default value of "format" in DateType to DateType::DEFAULT_FORMAT if "widget" is not "single_text"
  [HttpFoundation] fixed a small regression

Conflicts:
	src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
  • Loading branch information
fabpot committed Dec 11, 2012
2 parents f25750e + 7f3be5c commit 3c010db
Show file tree
Hide file tree
Showing 41 changed files with 183 additions and 86 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG-2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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?
-----------------

Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
// 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);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ private function getGuesser(ClassMetadata $classMetadata)
return new DoctrineOrmTypeGuesser($registry);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testCollapsedEntityField()
{
$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,
));
Expand All @@ -114,11 +114,14 @@ public function testCollapsedEntityField()
}
}

/**
* @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) {
Expand All @@ -130,4 +133,42 @@ public function testCollapsedEntityFieldWithQueryBuilder()
$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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bridge\Doctrine\Tests\Logger;


class DbalLoggerTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function redirect($url, $status = 302)
* @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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function values(array $values)
}

$this->values = $values;

return $this;
}

Expand All @@ -40,4 +40,4 @@ protected function instantiateNode()

return new EnumNode($this->name, $this->parent, $this->values);
}
}
}
4 changes: 3 additions & 1 deletion src/Symfony/Component/Config/Loader/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public function setResolver(LoaderResolverInterface $resolver)
*
* @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);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public function testResolve()
$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
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Console/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ public function testFindAlternativeExceptionMessage()
$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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* file that was distributed with this source code.
*/


namespace Symfony\Component\Console\Tests\Formatter;

use Symfony\Component\Console\Formatter\OutputFormatter;
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/CssSelector/Node/FunctionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ protected function _xpath_contains($xpath, $expr)
$xpath->addCondition(sprintf('contains(string(.), %s)', XPathExpr::xpathLiteral($expr)));

// FIXME: Currently case insensitive matching doesn't seem to be happening

return $xpath;
}

Expand Down Expand Up @@ -264,7 +263,6 @@ protected function parseSeries($s)

if (false === strpos($s, 'n')) {
// Just a b

return array(0, intval((string) $s));
}

Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,17 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
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));
}
} 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));
Expand Down
12 changes: 8 additions & 4 deletions src/Symfony/Component/Finder/SplFileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ public function getRelativePathname()
*/
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected function addChoices(array &$bucketForPreferred, array &$bucketForRemai
{
// 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.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function reverseTransform($rfc3339)
return null;
}


$dateTime = new \DateTime($rfc3339);

if ($this->outputTimezone !== $this->inputTimezone) {
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
);
};

$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'];
Expand All @@ -196,7 +200,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'days' => range(1, 31),
'widget' => 'choice',
'input' => 'datetime',
'format' => self::HTML5_FORMAT,
'format' => $format,
'model_timezone' => $modelTimezone,
'view_timezone' => $viewTimezone,
// Deprecated timezone options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'compound' => false,
'data_class' => 'Symfony\Component\HttpFoundation\File\File'
'data_class' => 'Symfony\Component\HttpFoundation\File\File'
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/Guess/Guess.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function getBestGuess(array $guesses)
*/
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.');
}
Expand Down
Loading

0 comments on commit 3c010db

Please sign in to comment.