Permalink
Browse files

Use call_user_func_array instead of call_user_func to pass params by …

…reference.

Use closures instead of string-based callable whenever possible to avoid namespace issues.
Fix ws-server imports.
Disable preProcess call in ajxp_conf (not necessary anyway).
  • Loading branch information...
1 parent 3bb0b66 commit 52ea16e0879b4a010cfb82c5a671944e57c7a454 @cdujeu cdujeu committed May 11, 2016
@@ -73,16 +73,16 @@ protected function nextCallable(&$request, &$response){
if($this->middleWares->valid()){
$callable = $this->middleWares->current();
$this->middleWares->next();
- $response = call_user_func($callable, $request, $response, function($req, $res){
+ $response = call_user_func_array($callable, array(&$request, &$response, function($req, $res){
return $this->nextCallable($req, $res);
- });
+ }));
}
return $response;
}
public function formatDetectionMiddleware(ServerRequestInterface $request, ResponseInterface $response, $next = null){
if($next !== null){
- $response = call_user_func($next, $request, $response);
+ $response = call_user_func_array($next, array(&$request, &$response));
}
if($response !== false && $response->getBody() && $response->getBody() instanceof SerializableResponseStream){
// For the moment, use XML by default
@@ -106,7 +106,7 @@ public function formatDetectionMiddleware(ServerRequestInterface $request, Respo
public function simpleEmitterMiddleware($request, $response, $next = null){
try{
if($next !== null){
- $response = call_user_func($next, $request, $response);
+ $response = call_user_func_array($next, array(&$request, &$response));
}
if($response !== false && ($response->getBody()->getSize() || $response instanceof \Zend\Diactoros\Response\EmptyResponse)) {
$emitter = new \Zend\Diactoros\Response\SapiEmitter();
@@ -200,7 +200,7 @@ protected function getEditableParameters($withLabel = false){
public function listAllActions($action, $httpVars, $fileVars)
{
- parent::accessPreprocess($action, $httpVars, $fileVars);
+ //parent::accessPreprocess($action, $httpVars, $fileVars);
$loggedUser = AuthService::getLoggedUser();
if(AuthService::usersEnabled() && !$loggedUser->isAdmin()) return ;
switch ($action) {
@@ -453,7 +453,7 @@ protected function renderNode($path, $data, $messages){
public function switchAction($action, $httpVars, $fileVars)
{
- parent::accessPreprocess($action, $httpVars, $fileVars);
+ //parent::accessPreprocess($action, $httpVars, $fileVars);
$loggedUser = AuthService::getLoggedUser();
if(AuthService::usersEnabled() && !$loggedUser->isAdmin()) return ;
if (AuthService::usersEnabled()) {
@@ -114,7 +114,10 @@ protected static function initPath($path, $streamType, $storeOpenContext = false
mkdir($tmpDir);
$tmpFileName = $tmpDir.DIRECTORY_SEPARATOR.basename($localPath);
AJXP_Logger::debug(__CLASS__,__FUNCTION__,"Tmp file $tmpFileName");
- register_shutdown_function(array("fsAccessWrapper", "removeTmpFile"), $tmpDir, $tmpFileName);
+ register_shutdown_function(function () use($tmpDir, $tmpFileName){
+ if(is_file($tmpFileName)) unlink($tmpFileName);
+ if(is_dir($tmpDir)) rmdir($tmpDir);
+ });
$crtZip = new PclZip(Utils::securePath($resolvedPath.$repoObject->resolveVirtualRoots($zipPath)));
$content = $crtZip->listContent();
if(is_array($content)){
@@ -71,7 +71,9 @@ public static function getRealFSReference($path, $persistent = false)
self::copyFileInStream($path, $tmpHandle);
fclose($tmpHandle);
if (!$persistent) {
- register_shutdown_function(array("Pydio\Core\Utils\Utils", "silentUnlink"), $tmpFile);
+ register_shutdown_function(function() use($tmpFile){
+ Utils::silentUnlink($tmpFile);
+ });
}
return $tmpFile;
}
@@ -169,7 +169,9 @@ public function stream_open($path, $mode, $options, &$opened_path)
throw new \Exception($e->getMessage()." - imap errors : ".print_r(imap_errors(), true), $e->getCode());
}
self::$currentStream = $this->ih;
- register_shutdown_function(array("imapAccessWrapper", "closeStreamFunc"));
+ register_shutdown_function(function(){
+ imapAccessWrapper::closeStreamFunc();
+ });
}
if ($this->ih) {
if (! empty ( $this->path )) {
@@ -59,7 +59,9 @@ public static function getRealFSReference($path, $persistent = FALSE)
self::copyFileInStream($path, $tmpHandle);
fclose($tmpHandle);
if (!$persistent) {
- register_shutdown_function(array("Pydio\Core\Utils\Utils", "silentUnlink"), $tmpFile);
+ register_shutdown_function(function() use($tmpFile){
+ Utils::silentUnlink($tmpFile);
+ });
}
return $tmpFile;
}
@@ -172,7 +172,9 @@ public static function getRealFSReference($path, $persistent = false)
self::copyFileInStream($path, $tmpHandle);
fclose($tmpHandle);
if (!$persistent) {
- register_shutdown_function(array("Pydio\Core\Utils\Utils", "silentUnlink"), $tmpFile);
+ register_shutdown_function(function() use($tmpFile){
+ Utils::silentUnlink($tmpFile);
+ });
}
return $tmpFile;
}
@@ -233,7 +233,9 @@ public static function getRealFSReference($path, $persistent = false)
self::copyFileInStream($path, $tmpHandle);
fclose($tmpHandle);
if (!$persistent) {
- register_shutdown_function(array("Pydio\Core\Utils\Utils", "silentUnlink"), $tmpFile);
+ register_shutdown_function(function() use($tmpFile){
+ Utils::silentUnlink($tmpFile);
+ });
}
return $tmpFile;
}
@@ -27,6 +27,7 @@
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
use Pydio\Core\PluginFramework\PluginsService;
+use Pydio\Core\Utils\Utils;
use Pydio\Metastore\Core\MetaStoreProvider;
@@ -443,7 +444,10 @@ public function getRealFile()
$this->realFilePointer = AJXP_MetaStreamWrapper::getRealFSReference($this->_url, true);
$isRemote = AJXP_MetaStreamWrapper::wrapperIsRemote($this->_url);
if ($isRemote) {
- register_shutdown_function(array("Pydio\Core\Utils\Utils", "silentUnlink"), $this->realFilePointer);
+ register_shutdown_function(function(){
+ Utils::silentUnlink($this->realFilePointer);
+ });
+
}
}
return $this->realFilePointer;
@@ -659,7 +659,9 @@ public static function getRealFSReference($path, $persistent = false)
fclose($tmpHandle);
if (!$persistent) {
- register_shutdown_function(array("\Pydio\Core\Utils\Utils", "silentUnlink"), $tmpFile);
+ register_shutdown_function(function() use($tmpFile){
+ Utils::silentUnlink($tmpFile);
+ });
}
return $tmpFile;
}
@@ -2,7 +2,7 @@
<?php
// Run from command prompt > php demo.php
require_once("vendor/phpws/websocket.server.php");
-require_once("../../core/classes/class.HttpClient.php");
+require_once("../../core/src/lib/HttpClient.php");
/**
* This demo resource handler will respond to all messages sent to /echo/ on the socketserver below
*
@@ -104,7 +104,6 @@ public function onConnect(IWebSocketConnection $user)
*/
$c = WebSocketFunctions::cookie_parse($h["Cookie"]);
- require_once(AJXP_BIN_FOLDER."/lib/HttpClient.php");
$client = new HttpClient($this->host);
$client->cookies = $c;
$client->get("/{$this->path}/?get_action=ws_authenticate&key=".self::$ADMIN_KEY);

0 comments on commit 52ea16e

Please sign in to comment.