Permalink
Browse files

Fix remotehttpDeletion for cache CLI.

  • Loading branch information...
1 parent 202f34d commit 184da9123469c67333decca5fe3c7cb5f891ae36 @cdujeu cdujeu committed Sep 23, 2016
@@ -76,4 +76,14 @@ public function setNamespace($namespace) {
$cache->setNamespace($namespace);
}
}
+
+ /**
+ * @return bool
+ */
+ public function oneProviderRequiresHttpDeletion(){
+ foreach($this->cacheProviders as $provider){
+ if($provider instanceof PydioApcuCache) return true;
+ }
+ return false;
+ }
}
@@ -30,9 +30,10 @@
use Pydio\Cache\Doctrine\Ext\PydioApcuCache;
+use Pydio\Cache\Doctrine\Ext\PydioChainCache;
+use Pydio\Core\Exception\PydioException;
use Pydio\Core\PluginFramework\Plugin;
use Pydio\Cache\Doctrine\Ext\PatternClearableCache;
-use Pydio\Core\Services\ConfService;
use GuzzleHttp\Client;
use Pydio\Core\Utils\ApplicationState;
use Pydio\Log\Core\Logger;
@@ -367,19 +368,27 @@ protected function getTimestampKey($id){
* @return bool
*/
protected function requiresHttpForwarding($cacheDriver){
- if(!empty($cacheDriver) && $cacheDriver instanceof PydioApcuCache && ApplicationState::sapiIsCli()){
+ if(empty($cacheDriver) || !ApplicationState::sapiIsCli()){
+ return false;
+ }
+ if(($cacheDriver instanceof PydioChainCache && $cacheDriver->oneProviderRequiresHttpDeletion()) || $cacheDriver instanceof PydioApcuCache){
return true;
}
return false;
}
/**
* @return Client
+ * @throws PydioException
*/
protected function getHttpClient(){
if(!isSet($this->httpClient)){
+ $baseUrl = ApplicationState::detectServerURL(true);
+ if(empty($baseUrl)){
+ throw new PydioException("Server URL does not seem to be configured, CLI cannot trigger cache deletion commands");
+ }
$this->httpClient = new Client([
- 'base_url' => ApplicationState::detectServerURL(true)
+ 'base_url' => $baseUrl
]);
}
return $this->httpClient;
@@ -388,7 +397,6 @@ protected function getHttpClient(){
public function __destruct()
{
if(count($this->httpDeletion)){
- Logger::debug("CacheDriver::CLI", "Sending cache clear to http", $this->httpDeletion);
$this->getHttpClient()->post('/?get_action=clear_cache_key', [
'body' => [
'data' => json_encode($this->httpDeletion)

0 comments on commit 184da91

Please sign in to comment.