From 15da53ca9fb1e372f2b3e94005722c4c2678b5e8 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 10 Feb 2017 17:11:43 +0100 Subject: [PATCH 1/2] purge both http and https from http cache store --- .../Component/HttpKernel/HttpCache/Store.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index b57d4a774d..f5574614b8 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -314,6 +314,23 @@ class Store implements StoreInterface return unserialize($entries); } + /** + * Purges data for the given URL. + * + * This method purges both the HTTP and the HTTPS version of the cache entry. + * + * @param string $url A URL + * + * @return bool true if the URL exists with either HTTP or HTTPS scheme and has been purged, false otherwise + */ + public function purge($url) + { + $http = preg_replace('#^https#', 'http', $url); + $https = preg_replace('#^http#', 'https', $url); + + return $this->doPurge($http) || $this->doPurge($https); + } + /** * Purges data for the given URL. * @@ -321,10 +338,9 @@ class Store implements StoreInterface * * @return bool true if the URL exists and has been purged, false otherwise */ - public function purge($url) + private function doPurge($url) { $key = $this->getCacheKey(Request::create($url)); - if (isset($this->locks[$key])) { flock($this->locks[$key], LOCK_UN); fclose($this->locks[$key]); From bc34081d37d902dd585758819802a31f6b4ad8ab Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 18 Feb 2017 18:54:03 +0100 Subject: [PATCH 2/2] minor fix --- .../Tests/DependencyInjection/DoctrineExtensionTest.php | 2 +- .../Tests/Form/ChoiceList/GenericEntityChoiceListTest.php | 2 +- .../Tests/Form/Type/EntityTypePerformanceTest.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 6017036f76..860162a77d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -11,7 +11,7 @@ namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php index c976121f68..fa09796f69 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php @@ -11,12 +11,12 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList; +use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity; use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Form\Extension\Core\View\ChoiceView; use Doctrine\ORM\Tools\SchemaTool; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index 16bf4e11ab..f72d7d09d0 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -72,7 +72,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $ids = range(1, 300); foreach ($ids as $id) { - $name = 65 + chr($id % 57); + $name = 65 + (int) chr($id % 57); $this->em->persist(new SingleIntIdEntity($id, $name)); } @@ -90,7 +90,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( + $form = $this->factory->create('entity', null, array( 'class' => self::ENTITY_CLASS, )); @@ -108,7 +108,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( + $form = $this->factory->create('entity', null, array( 'class' => self::ENTITY_CLASS, 'choices' => $choices, )); @@ -127,7 +127,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( + $form = $this->factory->create('entity', null, array( 'class' => self::ENTITY_CLASS, 'preferred_choices' => $choices, ));