diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index fa5f6d15e9a..a8ad0d2712d 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -333,7 +333,7 @@ public function setResultCache(CacheItemPoolInterface $cache): void */ public function getQueryCacheImpl() { - Deprecation::triggerIfCalledFromOutside( + Deprecation::trigger( 'doctrine/orm', 'https://github.com/doctrine/orm/pull/9002', 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getQueryCache() instead.', diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php index 2b2910410da..c1fae28c994 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php @@ -63,27 +63,34 @@ protected function execute(InputInterface $input, OutputInterface $output) { $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); - $em = $this->getEntityManager($input); - $cache = $em->getConfiguration()->getQueryCache(); - $cacheDriver = $em->getConfiguration()->getQueryCacheImpl(); + $em = $this->getEntityManager($input); + $cache = $em->getConfiguration()->getQueryCache(); - if (! $cacheDriver) { - throw new InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); - } - - if ($cacheDriver instanceof ApcCache || $cache instanceof ApcuAdapter) { + if ($cache instanceof ApcuAdapter) { throw new LogicException('Cannot clear APCu Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); } - if ($cacheDriver instanceof XcacheCache) { - throw new LogicException('Cannot clear XCache Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); - } + if (! $cache) { + $cacheDriver = $em->getConfiguration()->getQueryCacheImpl(); + + if (! $cacheDriver) { + throw new InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); + } + + if ($cacheDriver instanceof ApcCache) { + throw new LogicException('Cannot clear APCu Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); + } - if (! ($cacheDriver instanceof ClearableCache)) { - throw new LogicException(sprintf( - 'Can only clear cache when ClearableCache interface is implemented, %s does not implement.', - get_debug_type($cacheDriver) - )); + if ($cacheDriver instanceof XcacheCache) { + throw new LogicException('Cannot clear XCache Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); + } + + if (! ($cacheDriver instanceof ClearableCache)) { + throw new LogicException(sprintf( + 'Can only clear cache when ClearableCache interface is implemented, %s does not implement.', + get_debug_type($cacheDriver) + )); + } } $ui->comment('Clearing all Query cache entries');