diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig
index 01850b380c..8fdedf95e9 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig
@@ -193,7 +193,6 @@
x = request.left * ratio + space, // position
canvas = cache.get(elementId) || cache.set(elementId, document.getElementById(elementId)),
ctx = canvas.getContext("2d"),
- backingStoreRatio,
scaleRatio,
devicePixelRatio;
@@ -206,11 +205,8 @@
// For retina displays so text and boxes will be crisp
devicePixelRatio = window.devicePixelRatio == "undefined" ? 1 : window.devicePixelRatio;
- backingStoreRatio = ctx.webkitBackingStorePixelRatio == "undefined" ? 1 : ctx.webkitBackingStorePixelRatio;
scaleRatio = devicePixelRatio / 1;
- canvasHeight += gapPerEvent * drawableEvents.length;
-
canvas.width = width * scaleRatio;
canvas.height = canvasHeight * scaleRatio;
@@ -363,7 +359,7 @@
var self = this;
_requests.forEach(function(request) {
- self.drawOne(request, maxRequestTime, threshold, width);
+ self.drawOne(request, _maxRequestTime, threshold, width);
});
};
diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php
index 88890ae651..5717ffb154 100644
--- a/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php
+++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Form\Extension\Validator;
+use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Extension\Validator\Constraints\Form;
use Symfony\Component\Form\AbstractExtension;
use Symfony\Component\Validator\Constraints\Valid;
@@ -29,23 +30,19 @@ class ValidatorExtension extends AbstractExtension
/**
* @param ValidatorInterface|LegacyValidatorInterface $validator
+ *
+ * @throws UnexpectedTypeException If $validator is invalid
*/
public function __construct($validator)
{
- // since validator apiVersion 2.5
+ // 2.5 API
if ($validator instanceof ValidatorInterface) {
- $this->validator = $validator;
-
- /** @var $metadata ClassMetadata */
- $metadata = $this->validator->getMetadataFor('Symfony\Component\Form\Form');
- // until validator apiVersion 2.4
+ $metadata = $validator->getMetadataFor('Symfony\Component\Form\Form');
+ // 2.4 API
} elseif ($validator instanceof LegacyValidatorInterface) {
- $this->validator = $validator;
-
- /** @var $metadata ClassMetadata */
- $metadata = $this->validator->getMetadataFactory()->getMetadataFor('Symfony\Component\Form\Form');
+ $metadata = $validator->getMetadataFactory()->getMetadataFor('Symfony\Component\Form\Form');
} else {
- throw new \InvalidArgumentException('Validator must be instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface');
+ throw new UnexpectedTypeException($validator, 'Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface');
}
// Register the form constraints in the validator programmatically.
@@ -53,13 +50,22 @@ class ValidatorExtension extends AbstractExtension
// the DIC, where the XML file is loaded automatically. Thus the following
// code must be kept synchronized with validation.xml
+ /** @var $metadata ClassMetadata */
$metadata->addConstraint(new Form());
$metadata->addPropertyConstraint('children', new Valid());
+
+ $this->validator = $validator;
}
public function loadTypeGuesser()
{
- return new ValidatorTypeGuesser($this->validator->getMetadataFactory());
+ // 2.4 API
+ if ($this->validator instanceof LegacyValidatorInterface) {
+ return new ValidatorTypeGuesser($this->validator->getMetadataFactory());
+ }
+
+ // 2.5 API - ValidatorInterface extends MetadataFactoryInterface
+ return new ValidatorTypeGuesser($this->validator);
}
protected function loadTypeExtensions()
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php
index bc69231fe2..eca0873818 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php
@@ -15,79 +15,70 @@ use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
{
- public function testValidatorInterfaceSinceSymfony25()
+ public function test2Dot5ValidationApi()
{
- $classMetaData = $this->createClassMetaDataMock();
-
- // Mock of ValidatorInterface since apiVersion 2.5
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
+ $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')
+ ->disableOriginalConstructor()
+ ->getMock();
- $validator
- ->expects($this->once())
+ $validator->expects($this->once())
->method('getMetadataFor')
->with($this->identicalTo('Symfony\Component\Form\Form'))
- ->will($this->returnValue($classMetaData))
- ;
+ ->will($this->returnValue($metadata));
- $validatorExtension = new ValidatorExtension($validator);
- $this->assertAttributeSame($validator, 'validator', $validatorExtension);
+ // Verify that the constraints are added
+ $metadata->expects($this->once())
+ ->method('addConstraint')
+ ->with($this->isInstanceOf('Symfony\Component\Form\Extension\Validator\Constraints\Form'));
+
+ $metadata->expects($this->once())
+ ->method('addPropertyConstraint')
+ ->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid'));
+
+ $extension = new ValidatorExtension($validator);
+ $guesser = $extension->loadTypeGuesser();
+
+ $this->assertInstanceOf('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser', $guesser);
}
- public function testValidatorInterfaceUntilSymfony24()
+ public function test2Dot4ValidationApi()
{
- $classMetaData = $this->createClassMetaDataMock();
+ $factory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
+ $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
+ $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')
+ ->disableOriginalConstructor()
+ ->getMock();
- $metaDataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
+ $validator->expects($this->any())
+ ->method('getMetadataFactory')
+ ->will($this->returnValue($factory));
- $metaDataFactory
- ->expects($this->once())
+ $factory->expects($this->once())
->method('getMetadataFor')
->with($this->identicalTo('Symfony\Component\Form\Form'))
- ->will($this->returnValue($classMetaData))
- ;
+ ->will($this->returnValue($metadata));
- // Mock of ValidatorInterface until apiVersion 2.4
- $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
+ // Verify that the constraints are added
+ $metadata->expects($this->once())
+ ->method('addConstraint')
+ ->with($this->isInstanceOf('Symfony\Component\Form\Extension\Validator\Constraints\Form'));
- $validator
- ->expects($this->once())
- ->method('getMetadataFactory')
- ->will($this->returnValue($metaDataFactory))
- ;
+ $metadata->expects($this->once())
+ ->method('addPropertyConstraint')
+ ->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid'));
- $validatorExtension = new ValidatorExtension($validator);
- $this->assertAttributeSame($validator, 'validator', $validatorExtension);
+ $extension = new ValidatorExtension($validator);
+ $guesser = $extension->loadTypeGuesser();
+
+ $this->assertInstanceOf('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser', $guesser);
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testInvalidValidatorInterface()
{
new ValidatorExtension(null);
}
-
- /**
- * @return mixed
- */
- private function createClassMetaDataMock()
- {
- $classMetaData = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')
- ->disableOriginalConstructor()
- ->getMock();
-
- $classMetaData
- ->expects($this->once())
- ->method('addConstraint')
- ->with($this->isInstanceOf('Symfony\Component\Form\Extension\Validator\Constraints\Form'));
- $classMetaData
- ->expects($this->once())
- ->method('addPropertyConstraint')
- ->with(
- $this->identicalTo('children'),
- $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid')
- );
-
- return $classMetaData;
- }
}
diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php
index 5f906ddaa9..3938a701b1 100644
--- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php
+++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php
@@ -62,10 +62,9 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
$this->mongo = $mongo;
$this->options = array_merge(array(
- 'id_field' => '_id',
- 'data_field' => 'data',
- 'time_field' => 'time',
- 'expiry_field' => false,
+ 'id_field' => '_id',
+ 'data_field' => 'data',
+ 'time_field' => 'time',
), $options);
}
@@ -110,9 +109,6 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
*
* See: http://docs.mongodb.org/manual/tutorial/expire-data/
*/
- if (false !== $this->options['expiry_field']) {
- return true;
- }
$time = new \MongoDate(time() - $maxlifetime);
$this->getCollection()->remove(array(
@@ -127,27 +123,12 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
*/
public function write($sessionId, $data)
{
- $fields = array(
- $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY),
- $this->options['time_field'] => new \MongoDate(),
- );
-
- /* Note: As discussed in the gc method of this class. You can utilise
- * TTL collections in MongoDB 2.2+
- * We are setting the "expiry_field" as part of the write operation here
- * You will need to create the index on your collection that expires documents
- * at that time
- * e.g.
- * db.MySessionCollection.ensureIndex( { "expireAt": 1 }, { expireAfterSeconds: 0 } )
- */
- if (false !== $this->options['expiry_field']) {
- $expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime'));
- $fields[$this->options['expiry_field']] = $expiry;
- }
-
$this->getCollection()->update(
array($this->options['id_field'] => $sessionId),
- array('$set' => $fields),
+ array('$set' => array(
+ $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY),
+ $this->options['time_field'] => new \MongoDate(),
+ )),
array('upsert' => true, 'multiple' => false)
);
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
index d633a79b30..2feb6a83c0 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
@@ -41,7 +41,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
'data_field' => 'data',
'time_field' => 'time',
'database' => 'sf2-test',
- 'collection' => 'session-test',
+ 'collection' => 'session-test'
);
$this->storage = new MongoDbSessionHandler($this->mongo, $this->options);
@@ -100,45 +100,6 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
$that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]);
}
- public function testWriteWhenUsingExpiresField()
- {
- $this->options = array(
- 'id_field' => '_id',
- 'data_field' => 'data',
- 'time_field' => 'time',
- 'database' => 'sf2-test',
- 'collection' => 'session-test',
- 'expiry_field' => 'expiresAt'
- );
-
- $this->storage = new MongoDbSessionHandler($this->mongo, $this->options);
-
- $collection = $this->createMongoCollectionMock();
-
- $this->mongo->expects($this->once())
- ->method('selectCollection')
- ->with($this->options['database'], $this->options['collection'])
- ->will($this->returnValue($collection));
-
- $that = $this;
- $data = array();
-
- $collection->expects($this->once())
- ->method('update')
- ->will($this->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) {
- $that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria);
- $that->assertEquals(array('upsert' => true, 'multiple' => false), $options);
-
- $data = $updateData['$set'];
- }));
-
- $this->assertTrue($this->storage->write('foo', 'bar'));
-
- $this->assertEquals('bar', $data[$this->options['data_field']]->bin);
- $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]);
- $that->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]);
- }
-
public function testReplaceSessionData()
{
$collection = $this->createMongoCollectionMock();
@@ -193,36 +154,10 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
->method('remove')
->will($this->returnCallback(function ($criteria) use ($that) {
$that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']);
- $that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['time_field']]['$lt']->sec);
+ $that->assertGreaterThanOrEqual(time() - -1, $criteria[$that->options['time_field']]['$lt']->sec);
}));
- $this->assertTrue($this->storage->gc(1));
- }
-
- public function testGcWhenUsingExpiresField()
- {
- $this->options = array(
- 'id_field' => '_id',
- 'data_field' => 'data',
- 'time_field' => 'time',
- 'database' => 'sf2-test',
- 'collection' => 'session-test',
- 'expiry_field' => 'expiresAt'
- );
-
- $this->storage = new MongoDbSessionHandler($this->mongo, $this->options);
-
- $collection = $this->createMongoCollectionMock();
-
- $this->mongo->expects($this->never())
- ->method('selectCollection');
-
- $that = $this;
-
- $collection->expects($this->never())
- ->method('remove');
-
- $this->assertTrue($this->storage->gc(1));
+ $this->assertTrue($this->storage->gc(-1));
}
public function testGetConnection()
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf
index 635bd825f3..434eced760 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf
@@ -180,7 +180,7 @@
- Deze waarde moet exact {{ limit }} tekens lang zijn.
+ Deze waarde moet exact {{ limit }} teken lang zijn.|Deze waarde moet exact {{ limit }} tekens lang zijn.