From 6c743657c344e585b30a22ad585ce1e4e0b93c26 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Tue, 22 Dec 2015 10:35:56 +0100 Subject: [PATCH] Handle repository with deleted parent. Should fix #1025 --- core/src/core/classes/class.ConfService.php | 8 ++++++++ .../access.ajxp_conf/class.ajxp_confAccessDriver.php | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/src/core/classes/class.ConfService.php b/core/src/core/classes/class.ConfService.php index c4481e60f5..df542e152d 100644 --- a/core/src/core/classes/class.ConfService.php +++ b/core/src/core/classes/class.ConfService.php @@ -1118,10 +1118,18 @@ public function deleteRepositoryInst($repoId) { AJXP_Controller::applyHook("workspace.before_delete", array($repoId)); $confStorage = self::getConfStorageImpl(); + $shares = $confStorage->listRepositoriesWithCriteria(array("parent_uuid" => $repoId)); + $toDelete = array(); + foreach($shares as $share){ + $toDelete[] = $share->getId(); + } $res = $confStorage->deleteRepository($repoId); if ($res == -1) { return $res; } + foreach($toDelete as $deleteId){ + $this->deleteRepositoryInst($deleteId); + } AJXP_Controller::applyHook("workspace.after_delete", array($repoId)); AJXP_Logger::info(__CLASS__,"Delete Repository", array("repo_id"=>$repoId)); $this->invalidateLoadedRepositories(); diff --git a/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php b/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php index 1aa0885691..b6065a7c83 100644 --- a/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php +++ b/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php @@ -670,8 +670,14 @@ public function switchAction($action, $httpVars, $fileVars) continue; } $meta = array(); - if($repositoryObject->getOption("META_SOURCES") != null){ - $meta = array_keys($repositoryObject->getOption("META_SOURCES")); + try{ + if($repositoryObject->getOption("META_SOURCES") != null){ + $meta = array_keys($repositoryObject->getOption("META_SOURCES")); + } + }catch(Exception $e){ + if(isSet($sharedRepos[$repositoryId])) unset($sharedRepos[$repositoryId]); + $this->logError("Invalid Share", "Repository $repositoryId has no more parent. Should be deleted."); + continue; } $repoDetailed[$repositoryId] = array( "label" => SystemTextEncoding::toUTF8($repositoryObject->getDisplay()),