From cc791f592a87c53a8f01458328cbaea591241046 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Mon, 17 Mar 2014 22:27:11 +0100 Subject: [PATCH] Revert the $plugin instance cloning, broke the REST api. Instead, make sure to reload node driver on original node after applying forward event. --- core/src/core/classes/class.ConfService.php | 7 +--- .../action.share/class.ShareCenter.php | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/core/src/core/classes/class.ConfService.php b/core/src/core/classes/class.ConfService.php index ec3de20508..29b027fdb4 100644 --- a/core/src/core/classes/class.ConfService.php +++ b/core/src/core/classes/class.ConfService.php @@ -1195,12 +1195,7 @@ public function loadRepositoryDriverREST(&$repository) } $accessType = $repository->getAccessType(); $pServ = AJXP_PluginsService::getInstance(); - $plugInstanceOrig = $pServ->getPluginByTypeName("access", $accessType); - if(!empty($plugInstanceOrig->repository) && $plugInstanceOrig->repository != $repository){ - $plugInstance = clone $plugInstanceOrig; - }else{ - return $plugInstanceOrig; - } + $plugInstance = $pServ->getPluginByTypeName("access", $accessType); // TRIGGER BEFORE INIT META $metaSources = $repository->getOption("META_SOURCES"); diff --git a/core/src/plugins/action.share/class.ShareCenter.php b/core/src/plugins/action.share/class.ShareCenter.php index bc546e03ea..d88a7d7ffe 100644 --- a/core/src/plugins/action.share/class.ShareCenter.php +++ b/core/src/plugins/action.share/class.ShareCenter.php @@ -641,7 +641,18 @@ public function forwardEventToShares($fromNode=null, $toNode=null, $copy = false } $this->applyForwardEvent($fromMirrors, $toMirrors, $copy, $direction); - + if(count($fromMirrors) || count($toMirrors)){ + // Make sure to switch back to correct repository in memory + if($fromNode != null) { + $fromNode->getRepository()->driverInstance = null; + $fromNode->setDriver(null); + $fromNode->getDriver(); + }else if($toNode != null){ + $toNode->getRepository()->driverInstance = null; + $toNode->setDriver(null); + $toNode->getDriver(); + } + } } public function forwardEventToSharesAction($actionName, $httpVars, $fileVars){ @@ -649,13 +660,26 @@ public function forwardEventToSharesAction($actionName, $httpVars, $fileVars){ $fromMirrors = null; $toMirrors = null; if(!empty($httpVars["from"])){ - $fromMirrors = $this->findMirrorNodesInShares(new AJXP_Node($httpVars["from"]), $httpVars["direction"]); + $fromNode = new AJXP_Node($httpVars["from"]); + $fromMirrors = $this->findMirrorNodesInShares($fromNode, $httpVars["direction"]); } if(!empty($httpVars["to"])){ - $toMirrors = $this->findMirrorNodesInShares(new AJXP_Node($httpVars["to"]), $httpVars["direction"]); + $toNode = new AJXP_Node($httpVars["to"]); + $toMirrors = $this->findMirrorNodesInShares($toNode, $httpVars["direction"]); } $this->applyForwardEvent($fromMirrors, $toMirrors, ($httpVars["copy"] === "true"), $httpVars["direction"]); - + if(count($fromMirrors) || count($toMirrors)){ + // Make sure to switch back to correct repository in memory + if($fromNode != null) { + $fromNode->getRepository()->driverInstance = null; + $fromNode->setDriver(null); + $fromNode->getDriver(); + }else if($toNode != null){ + $toNode->getRepository()->driverInstance = null; + $toNode->setDriver(null); + $toNode->getDriver(); + } + } }