From d5a88dcd4db2a3877fe5f93b79ed2ddc10157167 Mon Sep 17 00:00:00 2001 From: Greg Hecquet Date: Wed, 9 Mar 2016 11:26:33 +0100 Subject: [PATCH] Fix to inbox and CacheService --- .../classes/class.AJXP_MetaStreamWrapper.php | 31 +++++++++++-------- core/src/core/classes/class.CacheService.php | 29 +++++++++++++---- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/core/src/core/classes/class.AJXP_MetaStreamWrapper.php b/core/src/core/classes/class.AJXP_MetaStreamWrapper.php index 7ecb8927dd..7d4504a425 100644 --- a/core/src/core/classes/class.AJXP_MetaStreamWrapper.php +++ b/core/src/core/classes/class.AJXP_MetaStreamWrapper.php @@ -111,18 +111,25 @@ protected static function translateScheme($url, $crtInstance = null){ $newScheme = self::getNextScheme($url, $context); $repository = ConfService::getRepositoryById(parse_url($url, PHP_URL_HOST)); if($currentScheme == "pydio" && $repository->hasContentFilter()){ - $baseDir = $repository->getContentFilter()->getBaseDir(); - if($crtInstance != null){ - $crtInstance->currentUniquePath = $repository->getContentFilter()->getUniquePath(); - } - if(!empty($baseDir) || $baseDir != "/"){ - $crtPath = parse_url($url, PHP_URL_PATH); - $crtBase = basename($crtPath); - if(!empty($crtPath) && $crtPath != "/" && $crtBase != $repository->getContentFilter()->getUniquePath() && $crtBase != ".ajxp_meta"){ - throw new Exception("Cannot find file ".$crtBase); + + $contentFilter = $repository->getContentFilter(); + + if ($contentFilter instanceof ContentFilter) { + $baseDir = $contentFilter->getBaseDir(); + + if ($crtInstance != null) { + $crtInstance->currentUniquePath = $contentFilter->getUniquePath(); + } + + if (!empty($baseDir) || $baseDir != "/") { + $crtPath = parse_url($url, PHP_URL_PATH); + $crtBase = basename($crtPath); + if (!empty($crtPath) && $crtPath != "/" && $crtBase != $contentFilter->getUniquePath() && $crtBase != ".ajxp_meta") { + throw new Exception("Cannot find file " . $crtBase); + } + // Prepend baseDir in path + $url = str_replace($currentScheme . "://" . $repository->getId() . $crtPath, $currentScheme . "://" . $repository->getId() . rtrim($baseDir . $crtPath, "/"), $url); } - // Prepend baseDir in path - $url = str_replace($currentScheme."://".$repository->getId().$crtPath, $currentScheme."://".$repository->getId().rtrim($baseDir.$crtPath, "/"), $url); } } @@ -133,7 +140,6 @@ protected static function translateScheme($url, $crtInstance = null){ return $newUrl; } - // TODO - problem here protected static function findWrapperClassName($scheme, $context = "core"){ $metaWrappers = self::getMetaWrappers($context); @@ -173,7 +179,6 @@ protected static function actualRepositoryWrapperData($repositoryId){ } } - /** * Return the final ajxp.XX wrapper class name. * @param $repositoryId diff --git a/core/src/core/classes/class.CacheService.php b/core/src/core/classes/class.CacheService.php index 5be9dad038..fb0d92ca60 100644 --- a/core/src/core/classes/class.CacheService.php +++ b/core/src/core/classes/class.CacheService.php @@ -27,9 +27,11 @@ */ class CacheService { - + /** + * @param $id + * @return bool + */ public static function contains($id) { - //var_dump('Cotnains' . $id); $cacheDriver = ConfService::getCacheDriverImpl(); if ($cacheDriver) { @@ -39,16 +41,26 @@ public static function contains($id) { return false; } + /** + * @param $id + * @param $object + * @param int $timelimit + * @return bool + */ public static function save($id, $object, $timelimit = 0 ) { $cacheDriver = ConfService::getCacheDriverImpl(); if ($cacheDriver) { - return $cacheDriver->save($id, $object, $timelimit = 0); + return $cacheDriver->save($id, $object, $timelimit); } return false; } + /** + * @param $id + * @return bool|mixed + */ public static function fetch($id) { $cacheDriver = ConfService::getCacheDriverImpl(); @@ -60,8 +72,11 @@ public static function fetch($id) { return false; } + /** + * @param $id + * @return bool + */ public static function delete($id) { - //var_dump('Delete' . $id); $cacheDriver = ConfService::getCacheDriverImpl(); if ($cacheDriver) { @@ -71,8 +86,10 @@ public static function delete($id) { return false; } + /** + * @return bool + */ public static function deleteAll() { - //var_dump('Delete ALL' . $id); $cacheDriver = ConfService::getCacheDriverImpl(); if ($cacheDriver) { @@ -81,4 +98,4 @@ public static function deleteAll() { return false; } -} +} \ No newline at end of file