Permalink
Browse files

Hunting down global references

  • Loading branch information...
1 parent b9d5e69 commit 89b823ce8797d74b74a224ee467c8932e464eba9 @cdujeu cdujeu committed Jun 9, 2016
Showing with 104 additions and 133 deletions.
  1. +1 −1 core/src/core/src/pydio/Core/Http/Cli/AuthCliMiddleware.php
  2. +1 −1 core/src/core/src/pydio/Core/Http/Dav/AuthBackendBasic.php
  3. +0 −1 core/src/core/src/pydio/Core/Http/Dav/AuthBackendDigest.php
  4. +6 −1 core/src/core/src/pydio/Core/Http/Dav/Node.php
  5. +2 −1 core/src/core/src/pydio/Core/Http/Middleware/AuthMiddleware.php
  6. +2 −2 core/src/core/src/pydio/Core/PluginFramework/Plugin.php
  7. +11 −2 core/src/core/src/pydio/Core/PluginFramework/PluginsService.php
  8. +6 −40 core/src/core/src/pydio/Core/Services/ConfService.php
  9. +0 −1 core/src/plugins/access.dropbox/class.dropboxAccessDriver.php
  10. +6 −5 core/src/plugins/access.fs/class.fsAccessDriver.php
  11. +0 −1 core/src/plugins/access.ftp/class.ftpAccessDriver.php
  12. +0 −1 core/src/plugins/access.imap/class.imapAccessDriver.php
  13. +4 −6 core/src/plugins/access.inbox/class.inboxAccessDriver.php
  14. +5 −5 core/src/plugins/access.inbox/class.inboxAccessWrapper.php
  15. +0 −1 core/src/plugins/access.s3/class.s3AccessDriver.php
  16. +0 −1 core/src/plugins/access.sftp/class.sftpAccessDriver.php
  17. +2 −3 core/src/plugins/access.sftp_psl/class.sftpPSLAccessDriver.php
  18. +3 −3 core/src/plugins/access.smb/class.smbAccessDriver.php
  19. +0 −1 core/src/plugins/access.swift/class.swiftAccessDriver.php
  20. +0 −1 core/src/plugins/access.webdav/src/Driver.php
  21. +2 −1 core/src/plugins/action.share/src/Store/ShareStore.php
  22. +30 −36 core/src/plugins/core.access/src/AJXP_MetaStreamWrapper.php
  23. +8 −5 core/src/plugins/core.access/src/AbstractAccessDriver.php
  24. +3 −2 core/src/plugins/core.access/src/Model/AJXP_Node.php
  25. +2 −3 core/src/plugins/core.log/class.AJXP_Logger.php
  26. +2 −1 core/src/plugins/core.ocs/src/OCSPlugin.php
  27. +5 −5 core/src/plugins/editor.eml/class.EmlParser.php
  28. +1 −1 core/src/plugins/uploader.jumploader/class.JumploaderProcessor.php
  29. +2 −1 core/src/plugins/uploader.plupload/class.PluploadProcessor.php
@@ -54,7 +54,7 @@ class AuthCliMiddleware
public static function handleRequest(ServerRequestInterface $requestInterface, ResponseInterface $responseInterface, callable $next = null){
$driverImpl = ConfService::getAuthDriverImpl();
- PluginsService::getInstance()->setPluginUniqueActiveForType("auth", $driverImpl->getName(), $driverImpl);
+ PluginsService::getInstance(Context::emptyContext())->setPluginUniqueActiveForType("auth", $driverImpl->getName(), $driverImpl);
$options = $requestInterface->getAttribute("cli-options");
$optUser = $options["u"];
@@ -139,7 +139,7 @@ public function authenticate(Sabre\DAV\Server $server, $realm)
// NOW UPDATE CONTEXT
$this->context->setUserId($this->currentUser);
- PluginsService::getInstance($this->context);
+ //PluginsService::getInstance($this->context);
AJXP_Logger::updateContext($this->context);
TextEncoder::updateContext($this->context);
@@ -132,7 +132,6 @@ public function authenticate(Sabre\DAV\Server $server, $realm)
// NOW UPDATE CONTEXT
$this->context->setUserObject($loggedUser);
- PluginsService::getInstance($this->context);
AJXP_Logger::updateContext($this->context);
TextEncoder::updateContext($this->context);
@@ -84,7 +84,12 @@ public function updateRepository($repository){
*/
public function getAccessDriver()
{
- return $this->context->getRepository()->getDriverInstance();
+ $driver = $this->context->getRepository()->getDriverInstance();
+ if(empty($driver)){
+ $n = new AJXP_Node($this->getUrl());
+ return $n->getDriver();
+ }
+ throw new \Exception("Cannot find driver instance for current node! ".$this->path);
}
/**
@@ -28,6 +28,7 @@
use Pydio\Core\Exception\PydioException;
use Pydio\Core\Exception\RepositoryLoadException;
use Pydio\Core\Http\Server;
+use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Services\AuthService;
@@ -59,7 +60,7 @@ public static function handleRequest(\Psr\Http\Message\ServerRequestInterface &$
try{
$driverImpl = ConfService::getAuthDriverImpl();
- PluginsService::getInstance()->setPluginUniqueActiveForType("auth", $driverImpl->getName(), $driverImpl);
+ PluginsService::getInstance(Context::emptyContext())->setPluginUniqueActiveForType("auth", $driverImpl->getName(), $driverImpl);
$response = FrontendsLoader::frontendsAsAuthMiddlewares($requestInterface, $responseInterface);
if($response != null){
@@ -878,7 +878,7 @@ public function logError($prefix, $message)
* @param bool $register
* @return array|bool
*/
- public function detectStreamWrapper($register = false)
+ public function detectStreamWrapper($register = false, ContextInterface $ctx = null)
{
if (isSet($this->streamData)) {
if($this->streamData === false) return false;
@@ -905,7 +905,7 @@ public function detectStreamWrapper($register = false)
$this->streamData = $streamData;
}
if ($register) {
- $pServ = PluginsService::getInstance();
+ $pServ = PluginsService::getInstance($ctx);
$wrappers = stream_get_wrappers();
if (!in_array($streamData["protocol"], $wrappers)) {
stream_wrapper_register($streamData["protocol"], $streamData["classname"]);
@@ -827,9 +827,18 @@ public function registerWrapperClass($protocol, $wrapperClassName)
* @param $protocol
* @return string
*/
- public function getWrapperClassName($protocol)
+ public function getWrapperClassName($protocol, $register = false)
{
- return $this->registeredWrappers[$protocol];
+ if(isSet($this->registeredWrappers[$protocol])){
+ return $this->registeredWrappers[$protocol];
+ }
+ /** @var AbstractAccessDriver $access */
+ $access = $this->getActivePluginsForType("access", true);
+ $data = $access->detectStreamWrapper($register);
+ if($data !== null && $data["protocol"] == $protocol){
+ return $data["classname"];
+ }
+ return null;
}
/**
@@ -22,6 +22,7 @@
use Pydio\Access\Core\AbstractAccessDriver;
use Pydio\Access\Core\AJXP_MetaStreamWrapper;
+use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Auth\Core\AbstractAuthDriver;
use Pydio\Cache\Core\AbstractCacheDriver;
use Pydio\Conf\Core\AbstractAjxpUser;
@@ -309,7 +310,10 @@ public function detectRepositoryStreamsInst(UserInterface $user, $register = fal
$streams = array();
$currentRepos = UsersService::getRepositoriesForUser($user);
foreach ($currentRepos as $repository) {
- AJXP_MetaStreamWrapper::detectWrapperForRepository($repository,$register, $streams);
+ $ctx = new Context();
+ $ctx->setUserObject($user);
+ $ctx->setRepositoryObject($repository);
+ AJXP_MetaStreamWrapper::detectWrapperForNode(new AJXP_Node($ctx->getUrlBase()),$register, $streams);
}
return $streams;
}
@@ -401,6 +405,7 @@ public static function getDeclaredUnsecureActions()
{
return PluginsService::searchManifestsWithCache("//action[@skipSecureToken]", function($nodes){
$res = array();
+ /** @var \DOMElement $node */
foreach ($nodes as $node) {
$res[] = $node->getAttribute("name");
}
@@ -523,45 +528,6 @@ public static function getUserPersonalParameter($parameterName, $userIdOrObject,
}
-
- /**
- * @static
- * @param RepositoryInterface $repository
- * @return AbstractAccessDriver
- */
- public static function loadDriverForRepository(&$repository)
- {
- return self::getInstance()->loadRepositoryDriverInst($repository);
- }
-
- /**
- * See static method
- * @param RepositoryInterface $repository
- * @throws PydioException|\Exception
- * @return AbstractAccessDriver
- */
- private function loadRepositoryDriverInst(&$repository)
- {
- $instance = $repository->getDriverInstance();
- if (!empty($instance)) {
- return $instance;
- }
-
- /** @var AbstractAccessDriver $plugInstance */
- $accessType = $repository->getAccessType();
- $pServ = PluginsService::getInstance();
- $plugInstance = $pServ->getPluginByTypeName("access", $accessType);
-
- /*
- $ctxId = $this->getContextRepositoryId();
- if ( (!empty($ctxId) || $ctxId === 0) && $ctxId == $repository->getId()) {
- $this->configs["REPOSITORY"] = $repository;
- $this->cacheRepository($ctxId, $repository);
- }
- */
- return $plugInstance;
- }
-
/**
* Singleton method
@@ -59,7 +59,6 @@ protected function initRepository(ContextInterface $contextInterface)
$this->driverConf = array();
}
- $this->detectStreamWrapper(true);
$this->urlBase =$contextInterface->getUrlBase();
if (!Utils::searchIncludePath('HTTP/OAuth/Consumer.php')) {
@@ -99,7 +99,6 @@ protected function initRepository(ContextInterface $contextInterface)
$path = TextEncoder::toStorageEncoding($repository->getContextOption($contextInterface, "PATH"));
$recycle = $repository->getContextOption($contextInterface, "RECYCLE_BIN");
$chmod = $repository->getContextOption($contextInterface, "CHMOD_VALUE");
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
@@ -366,7 +365,7 @@ public function uploadAction(ServerRequestInterface &$request, ResponseInterface
$dir = Utils::sanitize($httpVars["dir"], AJXP_SANITIZE_DIRNAME) OR "";
/** @var ContextInterface $ctx */
$ctx = $request->getAttribute("ctx");
- if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($ctx->getRepositoryId()) == "fsAccessWrapper") {
+ if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass(new AJXP_Node($ctx->getUrlBase())) == "fsAccessWrapper") {
$dir = fsAccessWrapper::patchPathForBaseDir($dir);
}
$dir = Utils::securePath($dir);
@@ -1120,8 +1119,10 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
}else{
$dir = Utils::sanitize($httpVars["dir"], AJXP_SANITIZE_DIRNAME) OR "";
}
- if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($ctx->getRepositoryId()) == "fsAccessWrapper") {
+ $patch = false;
+ if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass(new AJXP_Node($selection->currentBaseUrl())) == "fsAccessWrapper") {
$dir = fsAccessWrapper::patchPathForBaseDir($dir);
+ $patch = true;
}
$dir = Utils::securePath($dir);
@@ -1139,7 +1140,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$startTime = microtime();
$path = $selection->nodeForPath(($dir!= ""?($dir[0]=="/"?"":"/").$dir:""))->getUrl();
$nonPatchedPath = $path;
- if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($ctx->getRepositoryId()) == "fsAccessWrapper") {
+ if ($patch) {
$nonPatchedPath = fsAccessWrapper::unPatchPathForBaseDir($path);
}
$testPath = @stat($path);
@@ -2193,7 +2194,7 @@ public function recursivePurge($dirName, $hardPurgeTime, $softPurgeTime = 0)
* @param \Pydio\Access\Core\Model\AJXP_Node $node
*/
public function setHiddenAttribute($node){
- if(AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($node->getRepositoryId()) == "fsAccessWrapper" && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){
+ if(AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($node) == "fsAccessWrapper" && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){
$realPath = AJXP_MetaStreamWrapper::getRealFSReference($node->getUrl());
@shell_exec("attrib +H " . escapeshellarg($realPath));
}
@@ -90,7 +90,6 @@ protected function initRepository(ContextInterface $contextInterface)
} else {
$this->driverConf = array();
}
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
$recycle = $contextInterface->getRepository()->getContextOption($contextInterface, "RECYCLE_BIN");
if ($recycle != "") {
@@ -58,7 +58,6 @@ protected function initRepository(ContextInterface $contextInterface)
$this->driverConf = array();
}
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
}
@@ -47,7 +47,6 @@ class inboxAccessDriver extends fsAccessDriver
*/
protected function initRepository(ContextInterface $contextInterface)
{
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
}
@@ -97,8 +96,7 @@ public static function getNodeData($nodePath){
$node = new AJXP_Node($nodeData["url"]);
$node->getRepository()->driverInstance = null;
try{
- ConfService::loadDriverForRepository($node->getRepository());
- AJXP_MetaStreamWrapper::detectWrapperForRepository($node->getRepository(), true);
+ $node->getDriver()->detectStreamWrapper(true);
if($node->getRepository()->hasContentFilter()){
$node->setLeaf(true);
}
@@ -173,12 +171,12 @@ public static function getNodes($checkStats = false, $touch = true){
$node->getRepository()->driverInstance = null;
try{
- ConfService::loadDriverForRepository($node->getRepository());
+ $node->getDriver()->detectStreamWrapper(true);
}catch (\Exception $e){
$ext = "error";
$meta["ajxp_mime"] = "error";
}
- AJXP_MetaStreamWrapper::detectWrapperForRepository($node->getRepository(), true);
+ AJXP_MetaStreamWrapper::detectWrapperForNode($node, true);
$stat = @stat($url);
if($stat === false){
$ext = "error";
@@ -230,7 +228,7 @@ public static function getNodes($checkStats = false, $touch = true){
$output[$name.$suffix.".".$ext]['stat'] = $stat;
}
}
- ConfService::loadDriverForRepository($globalContext->getRepository());
+ //ConfService::loadDriverForRepository($globalContext->getRepository());
self::$output = $output;
if ($touch) {
@@ -145,11 +145,11 @@ public static function translateURL($path){
$node->setLabel($label);
$node->getRepository()->driverInstance = null;
try{
- ConfService::loadDriverForRepository($node->getRepository());
+ $node->getDriver();
}catch (\Exception $e){
}
- AJXP_MetaStreamWrapper::detectWrapperForRepository($node->getRepository(), true);
+ AJXP_MetaStreamWrapper::detectWrapperForNode($node, true);
}
return $url;
}
@@ -173,7 +173,7 @@ public static function getRealFSReference($path, $persistent = false)
copy($realFilePointer, $tmpname);
$realFilePointer = $tmpname;
}
- ConfService::loadDriverForRepository(self::$linkNode->getRepository());
+ self::$linkNode->getDriver();
return $realFilePointer;
}else{
$tmpname = tempnam(Utils::getAjxpTmpDir(), "real-file-inbox-pointer");
@@ -200,7 +200,7 @@ public static function copyFileInStream($path, $stream)
call_user_func(array($wrapperClass, "copyFileInStream"), $url, $stream);
*/
if(self::$linkNode !== null){
- ConfService::loadDriverForRepository(self::$linkNode->getRepository());
+ self::$linkNode->getDriver();
}
}
@@ -281,7 +281,7 @@ public function stream_close()
if($this->fp !== null){
fclose($this->fp);
if(self::$linkNode !== null){
- ConfService::loadDriverForRepository(self::$linkNode->getRepository());
+ self::$linkNode->getDriver();
}
}
}
@@ -62,7 +62,6 @@ public function performChecks()
*/
protected function initRepository(ContextInterface $contextInterface)
{
- $this->detectStreamWrapper(true);
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
@@ -72,7 +72,6 @@ protected function initRepository(ContextInterface $contextInterface)
ConfService::setConf("PROBE_REAL_SIZE", false);
$path = $contextInterface->getRepository()->getContextOption($contextInterface, "PATH");
$recycle = $contextInterface->getRepository()->getContextOption($contextInterface, "RECYCLE_BIN");
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
restore_error_handler();
if (!file_exists($contextInterface->getUrlBase())) {
@@ -68,16 +68,15 @@ protected function initRepository(ContextInterface $contextInterface)
require_once($this->getBaseDir()."/SFTPPSL_StreamWrapper.php");
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
}
- public function detectStreamWrapper($register = false)
+ public function detectStreamWrapper($register = false, ContextInterface $ctx = null)
{
if ($register) {
require_once($this->getBaseDir()."/SFTPPSL_StreamWrapper.php");
}
- return parent::detectStreamWrapper($register);
+ return parent::detectStreamWrapper($register, $ctx);
}
/**
@@ -27,6 +27,7 @@
use Pydio\Access\Core\RecycleBinManager;
use Pydio\Access\Core\Model\Repository;
use Pydio\Access\Driver\StreamProvider\FS\fsAccessDriver;
+use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Exception\PydioException;
@@ -73,7 +74,6 @@ protected function initRepository(ContextInterface $contextInterface)
//$create = $this->repository->getOption("CREATE");
$recycle = $this->repository->getContextOption($contextInterface, "RECYCLE_BIN");
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
if ($recycle!= "" && !is_dir($contextInterface->getUrlBase()."/".$recycle)) {
@@ -88,12 +88,12 @@ protected function initRepository(ContextInterface $contextInterface)
}
- public function detectStreamWrapper($register = false)
+ public function detectStreamWrapper($register = false, ContextInterface $ctx = null)
{
if ($register) {
require_once($this->getBaseDir()."/smb.php");
}
- return parent::detectStreamWrapper($register);
+ return parent::detectStreamWrapper($register, $ctx);
}
/**
@@ -86,7 +86,6 @@ protected function initRepository(ContextInterface $contextInterface)
$recycle = $this->repository->getContextOption($contextInterface, "RECYCLE_BIN");
ConfService::setConf("PROBE_REAL_SIZE", false);
- $this->detectStreamWrapper(true);
$this->urlBase = $contextInterface->getUrlBase();
if ($recycle != "") {
RecycleBinManager::init($contextInterface->getUrlBase(), "/".$recycle);
Oops, something went wrong.

0 comments on commit 89b823c

Please sign in to comment.