diff --git a/.travis.yml b/.travis.yml index 8cfcb5cdc5..7ca571e707 100644 --- a/.travis.yml +++ b/.travis.yml @@ -123,23 +123,6 @@ before_install: } export -f tpecl - install_apcu_dev () { - local ref=$1 - local INI=$2 - - wget https://github.com/krakjoe/apcu/archive/${ref}.zip - unzip ${ref}.zip - cd apcu-${ref} - phpize - ./configure - make - mv modules/apcu.so $(php -r "echo ini_get('extension_dir');") - echo 'extension = apcu.so' >> $INI - cd .. - rm -rf apcu-${ref} ${ref}.zip - } - export -f install_apcu_dev - - | # Install sigchild-enabled PHP to test the Process component on the lowest PHP matrix line if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then @@ -176,7 +159,7 @@ before_install: tfold ext.memcached tpecl memcached-3.1.5 memcached.so $INI tfold ext.apcu install_apcu_dev 9c36db45100d4d27ec33072f4be90f1f5a0108b7 $INI else - tfold ext.apcu tpecl apcu-5.1.18 apcu.so $INI + tfold ext.apcu tpecl apcu-5.1.19 apcu.so $INI tfold ext.mongodb tpecl mongodb-1.6.16 mongodb.so $INI tfold ext.zookeeper tpecl zookeeper-0.7.2 zookeeper.so $INI tfold ext.amqp tpecl amqp-1.10.2 amqp.so $INI diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 1829cdbcdb..c4e5b025c3 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -95,19 +95,10 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE $associationMapping = $metadata->getAssociationMapping($property); if (isset($associationMapping['indexBy'])) { - $indexProperty = $associationMapping['indexBy']; + $indexColumn = $associationMapping['indexBy']; /** @var ClassMetadataInfo $subMetadata */ $subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']); - $typeOfField = $subMetadata->getTypeOfField($indexProperty); - - if (null === $typeOfField) { - $associationMapping = $subMetadata->getAssociationMapping($indexProperty); - - /** @var ClassMetadataInfo $subMetadata */ - $indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($indexProperty); - $subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']); - $typeOfField = $subMetadata->getTypeOfField($indexProperty); - } + $typeOfField = $subMetadata->getTypeOfField($subMetadata->getFieldForColumn($indexColumn)); if (!$collectionKeyType = $this->getPhpType($typeOfField)) { return null; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 8d106ca53d..ca9ab318d3 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -60,13 +60,6 @@ class EntityTypeTest extends BaseTypeTest protected static $supportedFeatureSetVersion = 404; - public static function setUpBeforeClass(): void - { - if (\PHP_VERSION_ID >= 80000) { - self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); - } - } - protected function setUp(): void { $this->em = DoctrineTestHelper::createTestEntityManager(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php index 81264fad27..568efce33d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php @@ -42,7 +42,7 @@ class DoctrineDummy public $bar; /** - * @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid") + * @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid_column") */ protected $indexedBar; diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php index 5730cf81dd..e480ca9d77 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php @@ -30,7 +30,7 @@ class DoctrineRelation public $id; /** - * @Column(type="guid") + * @Column(type="guid", name="rguid_column") */ protected $rguid; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php index 75faf9012a..6e406b06b7 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php @@ -13,13 +13,6 @@ use Symfony\Component\Security\Core\Exception\TokenNotFoundException; */ class DoctrineTokenProviderTest extends TestCase { - public static function setUpBeforeClass(): void - { - if (\PHP_VERSION_ID >= 80000) { - self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); - } - } - public function testCreateNewToken() { $provider = $this->bootstrapProvider(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 257c6f7a93..59793406b5 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -24,13 +24,6 @@ use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; class EntityUserProviderTest extends TestCase { - public static function setUpBeforeClass(): void - { - if (\PHP_VERSION_ID >= 80000) { - self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); - } - } - public function testRefreshUserGetsUserByPrimaryKey() { $em = DoctrineTestHelper::createTestEntityManager(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 985d4601bf..e9e905c89c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -59,13 +59,6 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase protected $repositoryFactory; - public static function setUpBeforeClass(): void - { - if (\PHP_VERSION_ID >= 80000) { - self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); - } - } - protected function setUp(): void { $this->repositoryFactory = new TestRepositoryFactory(); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index 6669cd721f..d7508ec144 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -541,6 +541,6 @@ div.sf-toolbar .sf-toolbar-block a:hover { /***** Media query print: Do not print the Toolbar. *****/ @media print { .sf-toolbar { - display: none; + display: none !important; } } diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index 63374c5014..4292cd553a 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -56,7 +56,7 @@ class AbstractBrowserTest extends TestCase { $client = $this->getBrowser(); $client->xmlHttpRequest('GET', 'http://example.com/', [], [], [], null, true); - $this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest'); + $this->assertSame('XMLHttpRequest', $client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH']); $this->assertFalse($client->getServerParameter('HTTP_X_REQUESTED_WITH', false)); } @@ -65,9 +65,9 @@ class AbstractBrowserTest extends TestCase $client = $this->getBrowser(); $client->request('GET', 'https://example.com/foo', [], [], ['HTTP_HOST' => '127.0.0.1']); - $this->assertEquals('https://example.com/foo', $client->getRequest()->getUri()); + $this->assertSame('https://example.com/foo', $client->getRequest()->getUri()); $headers = $client->getRequest()->getServer(); - $this->assertEquals('127.0.0.1', $headers['HTTP_HOST']); + $this->assertSame('127.0.0.1', $headers['HTTP_HOST']); } public function testGetResponse() @@ -76,7 +76,7 @@ class AbstractBrowserTest extends TestCase $client->setNextResponse(new Response('foo')); $client->request('GET', 'http://example.com/'); - $this->assertEquals('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request'); + $this->assertSame('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request'); $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request'); } @@ -104,7 +104,7 @@ class AbstractBrowserTest extends TestCase $client = $this->getBrowser(); $client->request('POST', 'http://example.com/jsonrpc', [], [], [], $json); - $this->assertEquals($json, $client->getRequest()->getContent()); + $this->assertSame($json, $client->getRequest()->getContent()); } public function testGetCrawler() @@ -130,12 +130,12 @@ class AbstractBrowserTest extends TestCase $client = $this->getBrowser(); $client->request('GET', '/'); $headers = $client->getRequest()->getServer(); - $this->assertEquals('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); + $this->assertSame('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com'); $headers = $client->getRequest()->getServer(); - $this->assertEquals('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); + $this->assertSame('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); $client->request('GET', 'https://www.example.com'); $headers = $client->getRequest()->getServer(); @@ -144,66 +144,66 @@ class AbstractBrowserTest extends TestCase $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com:8080'); $headers = $client->getRequest()->getServer(); - $this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port'); + $this->assertSame('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port'); } public function testRequestURIConversion() { $client = $this->getBrowser(); $client->request('GET', '/foo'); - $this->assertEquals('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one'); + $this->assertSame('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com'); - $this->assertEquals('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs'); + $this->assertSame('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/'); $client->request('GET', '/foo'); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/foo'); $client->request('GET', '#'); - $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); + $this->assertSame('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); $client->request('GET', '#'); - $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); + $this->assertSame('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); $client->request('GET', '#foo'); - $this->assertEquals('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #'); + $this->assertSame('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/foo/'); $client->request('GET', 'bar'); - $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + $this->assertSame('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); - $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + $this->assertSame('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/foo/'); $client->request('GET', 'http'); - $this->assertEquals('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + $this->assertSame('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/foo'); $client->request('GET', 'http/bar'); - $this->assertEquals('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + $this->assertSame('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/'); $client->request('GET', 'http'); - $this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + $this->assertSame('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); $client = $this->getBrowser(); $client->request('GET', 'http://www.example.com/foo'); $client->request('GET', '?'); - $this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); + $this->assertSame('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); $client->request('GET', '?'); - $this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); + $this->assertSame('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); $client->request('GET', '?foo=bar'); - $this->assertEquals('http://www.example.com/foo?foo=bar', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); + $this->assertSame('http://www.example.com/foo?foo=bar', $client->getRequest()->getUri(), '->request() uses the previous request for ?'); } public function testRequestReferer() @@ -212,7 +212,7 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); $server = $client->getRequest()->getServer(); - $this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer'); + $this->assertSame('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer'); } public function testRequestRefererCanBeOverridden() @@ -221,7 +221,7 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar', [], [], ['HTTP_REFERER' => 'xyz']); $server = $client->getRequest()->getServer(); - $this->assertEquals('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden'); + $this->assertSame('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden'); } public function testRequestHistory() @@ -230,8 +230,8 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); - $this->assertEquals('http://www.example.com/foo/bar', $client->getHistory()->current()->getUri(), '->request() updates the History'); - $this->assertEquals('http://www.example.com/foo/foobar', $client->getHistory()->back()->getUri(), '->request() updates the History'); + $this->assertSame('http://www.example.com/foo/bar', $client->getHistory()->current()->getUri(), '->request() updates the History'); + $this->assertSame('http://www.example.com/foo/foobar', $client->getHistory()->back()->getUri(), '->request() updates the History'); } public function testRequestCookies() @@ -239,10 +239,10 @@ class AbstractBrowserTest extends TestCase $client = $this->getBrowser(); $client->setNextResponse(new Response('foo', 200, ['Set-Cookie' => 'foo=bar'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); + $this->assertSame(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); $client->request('GET', 'bar'); - $this->assertEquals(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); + $this->assertSame(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); } public function testRequestSecureCookies() @@ -262,7 +262,7 @@ class AbstractBrowserTest extends TestCase $client->click($crawler->filter('a')->link()); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links'); } public function testClickLink() @@ -272,7 +272,7 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $client->clickLink('foo'); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links'); } public function testClickLinkNotFound() @@ -297,7 +297,7 @@ class AbstractBrowserTest extends TestCase $client->click($crawler->filter('input')->form()); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms'); } public function testSubmit() @@ -308,7 +308,7 @@ class AbstractBrowserTest extends TestCase $client->submit($crawler->filter('input')->form()); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); } public function testSubmitForm() @@ -324,11 +324,11 @@ class AbstractBrowserTest extends TestCase 'HTTP_USER_AGENT' => 'Symfony User Agent', ]); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submitForm() submit forms'); - $this->assertEquals('PUT', $client->getRequest()->getMethod(), '->submitForm() allows to change the method'); - $this->assertEquals('new username', $client->getRequest()->getParameters()['username'], '->submitForm() allows to override the form values'); - $this->assertEquals('new password', $client->getRequest()->getParameters()['password'], '->submitForm() allows to override the form values'); - $this->assertEquals('Symfony User Agent', $client->getRequest()->getServer()['HTTP_USER_AGENT'], '->submitForm() allows to change the $_SERVER parameters'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->submitForm() submit forms'); + $this->assertSame('PUT', $client->getRequest()->getMethod(), '->submitForm() allows to change the method'); + $this->assertSame('new username', $client->getRequest()->getParameters()['username'], '->submitForm() allows to override the form values'); + $this->assertSame('new password', $client->getRequest()->getParameters()['password'], '->submitForm() allows to override the form values'); + $this->assertSame('Symfony User Agent', $client->getRequest()->getServer()['HTTP_USER_AGENT'], '->submitForm() allows to change the $_SERVER parameters'); } public function testSubmitFormNotFound() @@ -356,19 +356,19 @@ class AbstractBrowserTest extends TestCase $server = $client->getRequest()->getServer(); $this->assertArrayHasKey('PHP_AUTH_USER', $server); - $this->assertEquals('foo', $server['PHP_AUTH_USER']); + $this->assertSame('foo', $server['PHP_AUTH_USER']); $this->assertArrayHasKey('PHP_AUTH_PW', $server); - $this->assertEquals('bar', $server['PHP_AUTH_PW']); + $this->assertSame('bar', $server['PHP_AUTH_PW']); $client->submit($crawler->filter('input')->form()); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); $server = $client->getRequest()->getServer(); $this->assertArrayHasKey('PHP_AUTH_USER', $server); - $this->assertEquals('foo', $server['PHP_AUTH_USER']); + $this->assertSame('foo', $server['PHP_AUTH_USER']); $this->assertArrayHasKey('PHP_AUTH_PW', $server); - $this->assertEquals('bar', $server['PHP_AUTH_PW']); + $this->assertSame('bar', $server['PHP_AUTH_PW']); } public function testSubmitPassthrewHeaders() @@ -382,7 +382,7 @@ class AbstractBrowserTest extends TestCase $server = $client->getRequest()->getServer(); $this->assertArrayHasKey('Accept-Language', $server); - $this->assertEquals('de', $server['Accept-Language']); + $this->assertSame('de', $server['Accept-Language']); } public function testFollowRedirect() @@ -402,19 +402,19 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $client->followRedirect(); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client = $this->getBrowser(); $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true'); $client = $this->getBrowser(); $client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x'); + $this->assertSame('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x'); $client = $this->getBrowser(); $client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected'])); @@ -434,12 +434,12 @@ class AbstractBrowserTest extends TestCase $client = $this->getBrowser(); $client->setNextResponse(new Response('', 302, ['Location' => '/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client = $this->getBrowser(); $client->setNextResponse(new Response('', 302, ['Location' => '/redirected:1234'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls'); + $this->assertSame('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls'); } public function testFollowRedirectWithMaxRedirects() @@ -448,7 +448,7 @@ class AbstractBrowserTest extends TestCase $client->setMaxRedirects(1); $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected2'])); try { @@ -460,25 +460,25 @@ class AbstractBrowserTest extends TestCase $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client->setNextResponse(new Response('', 302, ['Location' => '/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs'); $client = $this->getBrowser(); $client->setNextResponse(new Response('', 302, ['Location' => '//www.example.org/'])); $client->request('GET', 'https://www.example.com/'); - $this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs'); + $this->assertSame('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs'); $client = $this->getBrowser(); $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('POST', 'http://www.example.com/foo/foobar', ['name' => 'bar']); - $this->assertEquals('GET', $client->getRequest()->getMethod(), '->followRedirect() uses a GET for 302'); - $this->assertEquals([], $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method'); + $this->assertSame('GET', $client->getRequest()->getMethod(), '->followRedirect() uses a GET for 302'); + $this->assertSame([], $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method'); } public function testFollowRedirectWithCookies() @@ -490,9 +490,9 @@ class AbstractBrowserTest extends TestCase 'Set-Cookie' => 'foo=bar', ])); $client->request('GET', 'http://www.example.com/'); - $this->assertEquals([], $client->getRequest()->getCookies()); + $this->assertSame([], $client->getRequest()->getCookies()); $client->followRedirect(); - $this->assertEquals(['foo' => 'bar'], $client->getRequest()->getCookies()); + $this->assertSame(['foo' => 'bar'], $client->getRequest()->getCookies()); } public function testFollowRedirectWithHeaders() @@ -551,9 +551,9 @@ class AbstractBrowserTest extends TestCase public function testGetMaxRedirects() { $client = $this->getBrowser(); - $this->assertEquals(-1, $client->getMaxRedirects(), '->getMaxRedirects() returns default value'); + $this->assertSame(-1, $client->getMaxRedirects(), '->getMaxRedirects() returns default value'); $client->setMaxRedirects(3); - $this->assertEquals(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value'); + $this->assertSame(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value'); } public function testFollowRedirectWithPostMethod() @@ -568,12 +568,12 @@ class AbstractBrowserTest extends TestCase $client->setNextResponse(new Response('', 307, ['Location' => 'http://www.example.com/redirected'])); $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->followRedirect() keeps parameters with POST method'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->followRedirect() keeps files with POST method'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method'); - $this->assertEquals($content, $client->getRequest()->getContent(), '->followRedirect() keeps content with POST method'); - $this->assertEquals('POST', $client->getRequest()->getMethod(), '->followRedirect() keeps request method'); + $this->assertSame($content, $client->getRequest()->getContent(), '->followRedirect() keeps content with POST method'); + $this->assertSame('POST', $client->getRequest()->getMethod(), '->followRedirect() keeps request method'); } public function testFollowRedirectDropPostMethod() @@ -589,12 +589,12 @@ class AbstractBrowserTest extends TestCase $client->setNextResponse(new Response('', $code, ['Location' => 'http://www.example.com/redirected'])); $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method on response code: '.$code.'.'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method on response code: '.$code.'.'); $this->assertEmpty($client->getRequest()->getParameters(), '->followRedirect() drops parameters with POST method on response code: '.$code.'.'); $this->assertEmpty($client->getRequest()->getFiles(), '->followRedirect() drops files with POST method on response code: '.$code.'.'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method on response code: '.$code.'.'); $this->assertEmpty($client->getRequest()->getContent(), '->followRedirect() drops content with POST method on response code: '.$code.'.'); - $this->assertEquals('GET', $client->getRequest()->getMethod(), '->followRedirect() drops request method to GET on response code: '.$code.'.'); + $this->assertSame('GET', $client->getRequest()->getMethod(), '->followRedirect() drops request method to GET on response code: '.$code.'.'); } } @@ -607,7 +607,7 @@ class AbstractBrowserTest extends TestCase $client->followMetaRefresh($followMetaRefresh); $client->setNextResponse(new Response($content)); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals($expectedEndingUrl, $client->getRequest()->getUri()); + $this->assertSame($expectedEndingUrl, $client->getRequest()->getUri()); } public function getTestsForMetaRefresh() @@ -644,11 +644,11 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo'); $client->back(); - $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->back() goes back in the history'); + $this->assertSame('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->back() goes back in the history'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->back() keeps parameters'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->back() keeps files'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->back() keeps $_SERVER'); - $this->assertEquals($content, $client->getRequest()->getContent(), '->back() keeps content'); + $this->assertSame($content, $client->getRequest()->getContent(), '->back() keeps content'); } public function testForward() @@ -665,11 +665,11 @@ class AbstractBrowserTest extends TestCase $client->back(); $client->forward(); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->forward() goes forward in the history'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->forward() goes forward in the history'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->forward() keeps parameters'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->forward() keeps files'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->forward() keeps $_SERVER'); - $this->assertEquals($content, $client->getRequest()->getContent(), '->forward() keeps content'); + $this->assertSame($content, $client->getRequest()->getContent(), '->forward() keeps content'); } public function testBackAndFrowardWithRedirects() @@ -680,15 +680,15 @@ class AbstractBrowserTest extends TestCase $client->setNextResponse(new Response('', 301, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/bar'); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), 'client followed redirect'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), 'client followed redirect'); $client->back(); - $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->back() goes back in the history skipping redirects'); + $this->assertSame('http://www.example.com/foo', $client->getRequest()->getUri(), '->back() goes back in the history skipping redirects'); $client->forward(); - $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->forward() goes forward in the history skipping redirects'); + $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->forward() goes forward in the history skipping redirects'); } public function testReload() @@ -703,11 +703,11 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $client->reload(); - $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->reload() reloads the current page'); + $this->assertSame('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->reload() reloads the current page'); $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->reload() keeps parameters'); $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->reload() keeps files'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->reload() keeps $_SERVER'); - $this->assertEquals($content, $client->getRequest()->getContent(), '->reload() keeps content'); + $this->assertSame($content, $client->getRequest()->getContent(), '->reload() keeps content'); } public function testRestart() @@ -717,7 +717,7 @@ class AbstractBrowserTest extends TestCase $client->restart(); $this->assertTrue($client->getHistory()->isEmpty(), '->restart() clears the history'); - $this->assertEquals([], $client->getCookieJar()->all(), '->restart() clears the cookies'); + $this->assertSame([], $client->getCookieJar()->all(), '->restart() clears the cookies'); } /** @@ -730,7 +730,7 @@ class AbstractBrowserTest extends TestCase $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')"); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals('foobar', $client->getResponse()->getContent(), '->insulate() process the request in a forked process'); + $this->assertSame('foobar', $client->getResponse()->getContent(), '->insulate() process the request in a forked process'); $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar)"); @@ -745,31 +745,31 @@ class AbstractBrowserTest extends TestCase public function testGetServerParameter() { $client = $this->getBrowser(); - $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); - $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); - $this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue')); + $this->assertSame('', $client->getServerParameter('HTTP_HOST')); + $this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + $this->assertSame('testvalue', $client->getServerParameter('testkey', 'testvalue')); } public function testSetServerParameter() { $client = $this->getBrowser(); - $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); - $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + $this->assertSame('', $client->getServerParameter('HTTP_HOST')); + $this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $client->setServerParameter('HTTP_HOST', 'testhost'); - $this->assertEquals('testhost', $client->getServerParameter('HTTP_HOST')); + $this->assertSame('testhost', $client->getServerParameter('HTTP_HOST')); $client->setServerParameter('HTTP_USER_AGENT', 'testua'); - $this->assertEquals('testua', $client->getServerParameter('HTTP_USER_AGENT')); + $this->assertSame('testua', $client->getServerParameter('HTTP_USER_AGENT')); } public function testSetServerParameterInRequest() { $client = $this->getBrowser(); - $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); - $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + $this->assertSame('', $client->getServerParameter('HTTP_HOST')); + $this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $client->request('GET', 'https://www.example.com/https/www.example.com', [], [], [ 'HTTP_HOST' => 'testhost', @@ -778,21 +778,21 @@ class AbstractBrowserTest extends TestCase 'NEW_SERVER_KEY' => 'new-server-key-value', ]); - $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); - $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + $this->assertSame('', $client->getServerParameter('HTTP_HOST')); + $this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); - $this->assertEquals('https://www.example.com/https/www.example.com', $client->getRequest()->getUri()); + $this->assertSame('https://www.example.com/https/www.example.com', $client->getRequest()->getUri()); $server = $client->getRequest()->getServer(); $this->assertArrayHasKey('HTTP_USER_AGENT', $server); - $this->assertEquals('testua', $server['HTTP_USER_AGENT']); + $this->assertSame('testua', $server['HTTP_USER_AGENT']); $this->assertArrayHasKey('HTTP_HOST', $server); - $this->assertEquals('testhost', $server['HTTP_HOST']); + $this->assertSame('testhost', $server['HTTP_HOST']); $this->assertArrayHasKey('NEW_SERVER_KEY', $server); - $this->assertEquals('new-server-key-value', $server['NEW_SERVER_KEY']); + $this->assertSame('new-server-key-value', $server['NEW_SERVER_KEY']); $this->assertArrayHasKey('HTTPS', $server); $this->assertTrue($server['HTTPS']); @@ -806,13 +806,13 @@ class AbstractBrowserTest extends TestCase 'HTTP_HOST' => 'testhost', 'HTTPS' => true, ]); - $this->assertEquals('https://testhost/', $client->getRequest()->getUri()); + $this->assertSame('https://testhost/', $client->getRequest()->getUri()); $client->request('GET', 'https://www.example.com/', [], [], [ 'HTTP_HOST' => 'testhost', 'HTTPS' => false, ]); - $this->assertEquals('https://www.example.com/', $client->getRequest()->getUri()); + $this->assertSame('https://www.example.com/', $client->getRequest()->getUri()); } public function testInternalRequest() diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php index 54ae56375c..648e4313d8 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -35,10 +35,6 @@ class PdoDbalAdapterTest extends AdapterTestCase self::markTestSkipped('Extension pdo_sqlite required.'); } - if (\PHP_VERSION_ID >= 80000 && class_exists(Version::class)) { - self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); - } - self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 27b2577809..93b303ea2b 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -504,6 +504,9 @@ EOF; return; } $file = $r->getFileName(); + if (') : eval()\'d code' === substr($file, -17)) { + $file = substr($file, 0, strrpos($file, '(', -17)); + } if (!$file || $this->doExport($file) === $exportedFile = $this->export($file)) { return; } diff --git a/src/Symfony/Component/Form/Resources/translations/validators.en.xlf b/src/Symfony/Component/Form/Resources/translations/validators.en.xlf index 97ed83fd47..e556c40b64 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.en.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.en.xlf @@ -114,6 +114,26 @@ Please provide a valid phone number. Please provide a valid phone number. + + The checkbox has an invalid value. + The checkbox has an invalid value. + + + Please enter a valid email address. + Please enter a valid email address. + + + Please select a valid option. + Please select a valid option. + + + Please select a valid range. + Please select a valid range. + + + Please enter a valid week. + Please enter a valid week. + diff --git a/src/Symfony/Component/Form/Resources/translations/validators.nl.xlf b/src/Symfony/Component/Form/Resources/translations/validators.nl.xlf index 3d737d79c1..7aa56ebf1b 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.nl.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.nl.xlf @@ -14,6 +14,126 @@ The CSRF token is invalid. Please try to resubmit the form. De CSRF-token is ongeldig. Probeer het formulier opnieuw te versturen. + + This value is not a valid HTML5 color. + Dit is geen geldige HTML5 kleur. + + + Please enter a valid birthdate. + Vul een geldige geboortedatum in. + + + The selected choice is invalid. + Deze keuze is ongeldig. + + + The collection is invalid. + Deze collectie is ongeldig. + + + Please select a valid color. + Kies een geldige kleur. + + + Please select a valid country. + Kies een geldige landnaam. + + + Please select a valid currency. + Kies een geldige valuta. + + + Please choose a valid date interval. + Kies een geldig tijdinterval. + + + Please enter a valid date and time. + Vul een geldige datum en tijd in. + + + Please enter a valid date. + Vul een geldige datum in. + + + Please select a valid file. + Kies een geldig bestand. + + + The hidden field is invalid. + Het verborgen veld is incorrect. + + + Please enter an integer. + Vul een geldig getal in. + + + Please select a valid language. + Kies een geldige taal. + + + Please select a valid locale. + Kies een geldige locale. + + + Please enter a valid money amount. + Vul een geldig bedrag in. + + + Please enter a number. + Vul een geldig getal in. + + + The password is invalid. + Het wachtwoord is incorrect. + + + Please enter a percentage value. + Vul een geldig percentage in. + + + The values do not match. + De waardes komen niet overeen. + + + Please enter a valid time. + Vul een geldige tijd in. + + + Please select a valid timezone. + Vul een geldige tijdzone in. + + + Please enter a valid URL. + Vul een geldige URL in. + + + Please enter a valid search term. + Vul een geldige zoekterm in. + + + Please provide a valid phone number. + Vul een geldig telefoonnummer in. + + + The checkbox has an invalid value. + De checkbox heeft een incorrecte waarde. + + + Please enter a valid email address. + Vul een geldig e-mailadres in. + + + Please select a valid option. + Kies een geldige optie. + + + Please select a valid range. + Kies een geldig bereik. + + + Please enter a valid week. + Vul een geldige week in. + diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 30eff944d7..74bad652bb 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -231,33 +231,36 @@ class BinaryFileResponse extends Response $this->headers->set($type, $path); $this->maxlen = 0; } - } elseif ($request->headers->has('Range')) { + } elseif ($request->headers->has('Range') && $request->isMethod('GET')) { // Process the range headers. if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) { $range = $request->headers->get('Range'); - list($start, $end) = explode('-', substr($range, 6), 2) + [0]; + if (0 === strpos($range, 'bytes=')) { + list($start, $end) = explode('-', substr($range, 6), 2) + [0]; - $end = ('' === $end) ? $fileSize - 1 : (int) $end; + $end = ('' === $end) ? $fileSize - 1 : (int) $end; - if ('' === $start) { - $start = $fileSize - $end; - $end = $fileSize - 1; - } else { - $start = (int) $start; - } + if ('' === $start) { + $start = $fileSize - $end; + $end = $fileSize - 1; + } else { + $start = (int) $start; + } - if ($start <= $end) { - if ($start < 0 || $end > $fileSize - 1) { - $this->setStatusCode(416); - $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); - } elseif (0 !== $start || $end !== $fileSize - 1) { - $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; - $this->offset = $start; + if ($start <= $end) { + $end = min($end, $fileSize - 1); + if ($start < 0 || $start > $end) { + $this->setStatusCode(416); + $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); + } elseif ($end - $start < $fileSize - 1) { + $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(206); + $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 4f4a5606fd..2efbc2b8ae 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -149,6 +149,7 @@ class BinaryFileResponseTest extends ResponseTestCase ['bytes=30-', 30, 5, 'bytes 30-34/35'], ['bytes=30-30', 30, 1, 'bytes 30-30/35'], ['bytes=30-34', 30, 5, 'bytes 30-34/35'], + ['bytes=30-40', 30, 5, 'bytes 30-34/35'], ]; } @@ -203,9 +204,31 @@ class BinaryFileResponseTest extends ResponseTestCase // Syntactical invalid range-request should also return the full resource ['bytes=20-10'], ['bytes=50-40'], + // range units other than bytes must be ignored + ['unknown=10-20'], ]; } + public function testRangeOnPostMethod() + { + $request = Request::create('/', 'POST'); + $request->headers->set('Range', 'bytes=10-20'); + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']); + + $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->assertSame(200, $response->getStatusCode()); + $this->assertSame('35', $response->headers->get('Content-Length')); + $this->assertNull($response->headers->get('Content-Range')); + } + public function testUnpreparedResponseSendsFullFile() { $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200); @@ -242,7 +265,7 @@ class BinaryFileResponseTest extends ResponseTestCase { return [ ['bytes=-40'], - ['bytes=30-40'], + ['bytes=40-50'], ]; } diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 44bf21d741..835793ccbe 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -122,7 +122,7 @@ class PropertyAccessor implements PropertyAccessorInterface return; } catch (\TypeError $e) { - self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0, $propertyPath); + self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0, $propertyPath, $e); // It wasn't thrown in this class so rethrow it throw $e; }