Permalink
Browse files

Some adaptations for a worker model.

  • Loading branch information...
1 parent 8eddc19 commit 13a60f0abde1a7165daece72935420514ff2438d @cdujeu cdujeu committed May 3, 2016
@@ -270,21 +270,35 @@ public static function findActionAndApply($actionName, $httpVars, $fileVars, &$a
* @static
* @param String $currentRepositoryId
* @param String $actionName
- * @param Array $parameters
+ * @param array $parameters
* @param string $user
* @param string $statusFile
* @return null|UnixProcess
*/
public static function applyActionInBackground($currentRepositoryId, $actionName, $parameters, $user ="", $statusFile = "")
{
- $token = md5(time());
- $logDir = AJXP_CACHE_DIR."/cmd_outputs";
- if(!is_dir($logDir)) mkdir($logDir, 0755);
- $logFile = $logDir."/".$token.".out";
if (empty($user)) {
if(AuthService::usersEnabled() && AuthService::getLoggedUser() !== null) $user = AuthService::getLoggedUser()->getId();
else $user = "shared";
}
+
+ $fName = AJXP_DATA_PATH."/plugins/mq.serial/worker-queue";
+ $fData = file_get_contents($fName);
+ $data = json_decode($fData, true);
+ $data[] = array(
+ "userId" => $user,
+ "repoId" => $currentRepositoryId,
+ "actionName" => $actionName,
+ "parameters" => $parameters
+ );
+ file_put_contents($fName, json_encode($data));
+ return ;
+
+
+ $token = md5(time());
+ $logDir = AJXP_CACHE_DIR."/cmd_outputs";
+ if(!is_dir($logDir)) mkdir($logDir, 0755);
+ $logFile = $logDir."/".$token.".out";
if (AuthService::usersEnabled()) {
$cKey = ConfService::getCoreConf("AJXP_CLI_SECRET_KEY", "conf");
if(empty($cKey)){
@@ -38,8 +38,10 @@ class AJXP_XMLWriter
public static function header($docNode="tree", $attributes=array())
{
if(self::$headerSent !== false && self::$headerSent == $docNode) return ;
- header('Content-Type: text/xml; charset=UTF-8');
- header('Cache-Control: no-cache');
+ if(!ConfService::currentContextIsCommandLine()){
+ header('Content-Type: text/xml; charset=UTF-8');
+ header('Cache-Control: no-cache');
+ }
print('<?xml version="1.0" encoding="UTF-8"?>');
$attString = "";
if (count($attributes)) {
@@ -132,8 +134,10 @@ public static function renderSimpleListAsNodes($data, $rootPath, $idKey, $labelK
*/
public static function renderHeaderNode($nodeName, $nodeLabel, $isLeaf, $metaData = array())
{
- header('Content-Type: text/xml; charset=UTF-8');
- header('Cache-Control: no-cache');
+ if(!ConfService::currentContextIsCommandLine()) {
+ header('Content-Type: text/xml; charset=UTF-8');
+ header('Cache-Control: no-cache');
+ }
print('<?xml version="1.0" encoding="UTF-8"?>');
self::$headerSent = "tree";
AJXP_XMLWriter::renderNode($nodeName, $nodeLabel, $isLeaf, $metaData, false);
@@ -146,8 +150,10 @@ public static function renderHeaderNode($nodeName, $nodeLabel, $isLeaf, $metaDat
*/
public static function renderAjxpHeaderNode($ajxpNode)
{
- header('Content-Type: text/xml; charset=UTF-8');
- header('Cache-Control: no-cache');
+ if(!ConfService::currentContextIsCommandLine()) {
+ header('Content-Type: text/xml; charset=UTF-8');
+ header('Cache-Control: no-cache');
+ }
print('<?xml version="1.0" encoding="UTF-8"?>');
self::$headerSent = "tree";
self::renderAjxpNode($ajxpNode, false);
@@ -264,7 +270,6 @@ public static function catchError($code, $message, $fichier, $ligne, $context)
AJXP_XMLWriter::sendMessage(null, SystemTextEncoding::toUTF8($message), true);
}
AJXP_XMLWriter::close();
- exit(1);
}
/**
@@ -251,7 +251,9 @@ public static function refreshRememberCookie($user)
$user->invalidateCookieString(substr($current, strpos($current, ":")+1));
}
$rememberPass = $user->getCookieString();
- setcookie("AjaXplorer-remember", $user->id.":".$rememberPass, time()+3600*24*10, null, null, (isSet($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on"), true);
+ if(self::$useSession) {
+ setcookie("AjaXplorer-remember", $user->id.":".$rememberPass, time()+3600*24*10, null, null, (isSet($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on"), true);
+ }
}
/**
@@ -274,7 +276,9 @@ public static function clearRememberCookie()
if (!empty($current) && $user != null) {
$user->invalidateCookieString(substr($current, strpos($current, ":")+1));
}
- setcookie("AjaXplorer-remember", "", time()-3600, null, null, (isSet($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on"), true);
+ if(self::$useSession) {
+ setcookie("AjaXplorer-remember", "", time()-3600, null, null, (isSet($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on"), true);
+ }
}
public static function logTemporaryUser($parentUserId, $temporaryUserId)
@@ -442,7 +446,7 @@ public static function disconnect()
self::clearRememberCookie();
AJXP_Logger::info(__CLASS__, "Log Out", "");
unset($_SESSION["AJXP_USER"]);
- if(isSet(self::$currentUser)) unset(self::$currentUser);
+ //if(isSet(self::$currentUser)) unset(self::$currentUser);
if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
AJXP_Safe::clearCredentials();
}

0 comments on commit 13a60f0

Please sign in to comment.