From afd4121116d30ee0f3b208374d8a7c8e256cd2a0 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Mon, 28 Jun 2010 23:36:09 +0200 Subject: [PATCH] DDC-611 - Throw an exception if trying to clear an APC Cache from the CLI since there is no access to the webserver shared memory (thanks Romain Dalmaso for reporting) --- .../ORM/Tools/Console/Command/ClearCache/MetadataCommand.php | 4 ++++ .../ORM/Tools/Console/Command/ClearCache/QueryCommand.php | 4 ++++ .../ORM/Tools/Console/Command/ClearCache/ResultCommand.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php index 711bffd2d..198f228b3 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php @@ -66,6 +66,10 @@ EOT throw new \InvalidArgumentException('No Metadata cache driver is configured on given EntityManager.'); } + if ($cacheDriver instanceof \Doctrine\Common\Cache\ApcCache) { + throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); + } + $output->write('Clearing ALL Metadata cache entries' . PHP_EOL); $cacheIds = $cacheDriver->deleteAll(); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php index b16fec3eb..d42137e20 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php @@ -66,6 +66,10 @@ EOT throw new \InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); } + if ($cacheDriver instanceof \Doctrine\Common\Cache\ApcCache) { + throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); + } + $output->write('Clearing ALL Query cache entries' . PHP_EOL); $cacheIds = $cacheDriver->deleteAll(); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php index 9bd82c36c..2354360e5 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php @@ -84,6 +84,10 @@ EOT throw new \InvalidArgumentException('No Result cache driver is configured on given EntityManager.'); } + if ($cacheDriver instanceof \Doctrine\Common\Cache\ApcCache) { + throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); + } + $outputed = false; // Removing based on --id