Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/Resources/config/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use phpDocumentor\Reflection\DocBlockFactory;
use phpDocumentor\Reflection\Types\ContextFactory;
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
Expand Down Expand Up @@ -107,7 +108,7 @@
->decorate('api_platform.property_info')
->args([
service('.inner'),
service('cache.property_info'),
inline_service(ArrayAdapter::class),
]);

$services->set('api_platform.negotiator', Negotiator::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/symfony/symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$services->set('api_platform.cache_warmer.cache_pool_clearer', CachePoolClearerCacheWarmer::class)
->args([
service('cache.system_clearer'),
['api_platform.cache.metadata.property', 'api_platform.cache.metadata.resource', 'api_platform.cache.metadata.resource_collection', 'api_platform.cache.metadata.operation', 'api_platform.cache.route_name_resolver', 'api_platform.cache.identifiers_extractor', 'api_platform.elasticsearch.cache.metadata.document', 'cache.property_info'],
['api_platform.cache.metadata.property', 'api_platform.cache.metadata.resource', 'api_platform.cache.metadata.resource_collection', 'api_platform.cache.metadata.operation', 'api_platform.cache.route_name_resolver', 'api_platform.cache.identifiers_extractor', 'api_platform.elasticsearch.cache.metadata.document'],
])
->tag('kernel.cache_warmer', ['priority' => 64]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
use Symfony\Bundle\FrameworkBundle\Command\TranslationExtractCommand as FrameworkTranslationExtractCommand;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\ObjectMapper\ObjectMapper;
Expand Down Expand Up @@ -575,18 +577,28 @@ public function testPropertyInfoExtractorsDoNotLeakIntoFrameworkPropertyInfo():
}
}

/**
* @see https://github.com/api-platform/core/issues/8332
*/
public function testCachePoolClearerClearsPropertyInfoAndOperationMetadataCaches(): void
public function testPropertyInfoUsesInMemoryCache(): void
{
(new ApiPlatformExtension())->load(self::DEFAULT_CONFIG, $this->container);

$propertyInfoCache = $this->container->getDefinition('api_platform.property_info.cache');
$cachePool = $propertyInfoCache->getArgument(1);

$this->assertInstanceOf(Definition::class, $cachePool);
$this->assertSame(ArrayAdapter::class, $cachePool->getClass());
$this->assertContainerHasService('api_platform.metadata.property.metadata_factory.cached');
$this->assertContainerHasService('api_platform.metadata.property.name_collection_factory.cached');
}

public function testCachePoolClearerClearsOperationMetadataCache(): void
{
$this->container->setParameter('kernel.debug', true);
$config = self::DEFAULT_CONFIG;
(new ApiPlatformExtension())->load($config, $this->container);

$this->assertContainerHasService('api_platform.cache_warmer.cache_pool_clearer');
$pools = $this->container->getDefinition('api_platform.cache_warmer.cache_pool_clearer')->getArgument(1);
$this->assertContains('cache.property_info', $pools);
$this->assertNotContains('cache.property_info', $pools);
$this->assertContains('api_platform.cache.metadata.operation', $pools);
}

Expand Down
Loading