diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php index fde24922f1..431b061512 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php @@ -315,7 +315,7 @@ class Installer implements ControllerProviderInterface $appbox->get_session()->authenticate($auth); - $redirection = '/admin/?section=taskmanager¬ice=install_success'; + $redirection = '/admin/index.php?section=taskmanager¬ice=install_success'; return $app->redirect($redirection); } diff --git a/lib/Alchemy/Phrasea/Helper/Record/Edit.php b/lib/Alchemy/Phrasea/Helper/Record/Edit.php index d790a9fdb4..7f72ef5d93 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Edit.php @@ -56,7 +56,7 @@ class Edit extends RecordHelper * * @var Array */ - protected $javascript_elements; + protected $javascript_elements = array(); /** * diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 3eafd16acd..dec63c6cf3 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -545,7 +545,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $user = \User_adapter::getInstance(array_pop($users), \appbox::get_instance()); - if ($user->is_template()) + if ($user->is_template() || $user->is_special()) { return $this; } diff --git a/lib/classes/Session/Handler.class.php b/lib/classes/Session/Handler.class.php index 1d821e31d2..95945869e7 100644 --- a/lib/classes/Session/Handler.class.php +++ b/lib/classes/Session/Handler.class.php @@ -395,6 +395,7 @@ class Session_Handler foreach ($user->ACL()->get_granted_sbas() as $databox) { Session_Logger::create($databox, $browser, $this, $user); + \cache_databox::insertClient($databox); } $this->set_usr_lastconn($conn, $user->get_id()); diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 3368b570e8..c9f1158921 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -1280,6 +1280,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface if ($this->_prefs) return $this; + + $registry = \registry::get_instance(); + $sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id'; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute(array(':id' => $this->id)); @@ -1295,6 +1298,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { if (!isset($this->_prefs[$k])) { + if($k == 'start_page_query' && $registry->get('GV_defaultQuery')) + { + $v = $registry->get('GV_defaultQuery'); + } + $this->_prefs[$k] = $v; $this->update_pref($k, $v); } diff --git a/lib/classes/cache/databox.class.php b/lib/classes/cache/databox.class.php index c4f5279002..c219d071c1 100644 --- a/lib/classes/cache/databox.class.php +++ b/lib/classes/cache/databox.class.php @@ -18,142 +18,118 @@ class cache_databox { - /** - * - * @var cache_databox - */ - private static $_instance = false; - /** - * - * @var cache - */ - protected $_c_obj = false; - - /** - * - * @return cache_databox - */ - function __construct() - { - $this->_c_obj = cache_adapter::getInstance(registry::get_instance()); - - return $this; - } - - /** - * @return cache_databox - */ - public static function getInstance() - { - if (!(self::$_instance instanceof self)) - self::$_instance = new self(); - - return self::$_instance; - } - - /** - * - * @param string $type - * @param string $what - * @return boolean - */ - public function get($type, $what) - { - return $this->_c_obj->get('_databox_' . $type . '_' . $what); - } - - /** - * - * @param string $type - * @param string $what - * @param mixed content $bin - * @return boolean - */ - public function set($type, $what, $bin) - { - return $this->_c_obj->set('_databox_' . $type . '_' . $what, $bin); - } - - /** - * - * @param string $type - * @param string $what - * @return boolean - */ - public function delete($type, $what) - { - return $this->_c_obj->delete('_databox_' . $type . '_' . $what); - } - /** * * @param int $sbas_id * @return cache_databox */ - function refresh($sbas_id) + public static function refresh($sbas_id) { - $date = new DateTime('-30 seconds'); + $databox = \databox::get_instance((int) $sbas_id); - $registry = registry::get_instance(); + $date = new \DateTime('-30 seconds'); - $cache_appbox = cache_appbox::getInstance(); - $last_update = $cache_appbox->get('memcached_update'); - if ($last_update) - $last_update = new DateTime($last_update); - else - $last_update = new DateTime('-10 years'); + $appbox = \appbox::get_instance(); - if ($date <= $last_update || !$cache_appbox->is_ok()) + $registry = \registry::get_instance(); - return $this; + $cache_appbox = $appbox->get_cache(); - $connsbas = connection::getInstance($sbas_id); + $last_update = null; - if (!$connsbas) - - return $this; - - $sql = 'SELECT type, value FROM memcached - WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '"'; - - if ($rs = $connsbas->query($sql)) + try { - $cache_thumbnail = cache_thumbnail::getInstance(); - $cache_preview = cache_preview::getInstance(); - while ($row = $connsbas->fetch_assoc($rs)) - { - switch ($row['type']) - { - case 'record': - $cache_thumbnail->delete($sbas_id, $row['value'], false); - $cache_preview->delete($sbas_id, $row['value'], false); - $sql = 'DELETE FROM memcached - WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '" - AND type="record" AND value="' . $row['value'] . '"'; - $connsbas->query($sql); - break; - case 'structure': - $cache_appbox->delete('list_bases'); - $sql = 'DELETE FROM memcached - WHERE site_id="' . $connsbas->escape_string($registry->get('GV_ServerName')) . '" - AND type="structure" AND value="' . $row['value'] . '"'; - $connsbas->query($sql); - break; - } - } - $connsbas->free_result($rs); + $last_update = $cache_appbox->get('memcached_update'); + } + catch (\Exception $e) + { + } - $date = new DateTime(); - $now = phraseadate::format_mysql($date); + if ($last_update) + $last_update = new \DateTime($last_update); + else + $last_update = new \DateTime('-10 years'); + + if ($date <= $last_update || !$cache_appbox->ping()) + { + return; + } + + $connsbas = \connection::getPDOConnection($sbas_id); + + $sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id'; + $stmt = $connsbas->prepare($sql); + $stmt->execute(array(':site_id' => $registry->get('GV_ServerName'))); + $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rs as $row) + { + switch ($row['type']) + { + case 'record': + $key = 'record_' . $sbas_id . '_' . $row['value']; + $databox->delete_data_from_cache($key); + $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SUBDEFS; + $databox->delete_data_from_cache($key); + $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_GROUPING; + $databox->delete_data_from_cache($key); + $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_MIME; + $databox->delete_data_from_cache($key); + $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_ORIGINAL_NAME; + $databox->delete_data_from_cache($key); + $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SHA256; + $databox->delete_data_from_cache($key); + $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_STATUS; + $databox->delete_data_from_cache($key); + $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_TECHNICAL_DATAS; + $databox->delete_data_from_cache($key); + + $sql = 'DELETE FROM memcached + WHERE site_id = :site_id AND type="record" AND value = :value'; + + $params = array( + ':site_id' => $registry->get('GV_ServerName') + , ':value' => $row['value'] + ); + + $stmt = $connsbas->prepare($sql); + $stmt->execute($params); + $stmt->closeCursor(); + break; + case 'structure': + $cache_appbox->delete(\appbox::CACHE_LIST_BASES); + $cache_appbox->delete(\appbox::CACHE_SBAS_IDS); + + $sql = 'DELETE FROM memcached + WHERE site_id = :site_id AND type="structure" AND value = :value'; + + $params = array( + ':site_id' => $registry->get('GV_ServerName') + , ':value' => $row['value'] + ); + + $stmt = $connsbas->prepare($sql); + $stmt->execute($params); + $stmt->closeCursor(); + break; + } + } + + $date = new \DateTime(); + $now = $date->format(DATE_ISO8601); + $cache_appbox->set('memcached_update', $now); - $conn = connection::getInstance(); - $sql = 'UPDATE sitepreff - SET memcached_update="' . $conn->escape_string($now) . '"'; - $conn->query($sql); + $conn = \connection::getPDOConnection(); - return $this; + $sql = 'UPDATE sitepreff SET memcached_update = :date'; + $stmt = $conn->prepare($sql); + $stmt->execute(array(':date' => $now)); + $stmt->closeCursor(); + + return; } /** @@ -163,28 +139,57 @@ class cache_databox * @param mixed content $value * @return Void */ - function update($sbas_id, $type, $value='') + public static function update($sbas_id, $type, $value = '') { - $connbas = connection::getPDOConnection($sbas_id); + $connbas = \connection::getPDOConnection($sbas_id); - $registry = registry::get_instance(); + $registry = \registry::get_instance(); $sql = 'SELECT distinct site_id as site_id FROM clients WHERE site_id != :site_id'; + $stmt = $connbas->prepare($sql); $stmt->execute(array(':site_id' => $registry->get('GV_ServerName'))); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); $sql = 'REPLACE INTO memcached (site_id, type, value) VALUES (:site_id, :type, :value)'; + $stmt = $connbas->prepare($sql); + foreach ($rs as $row) { - $stmt->execute(array(':site_id' => $row['site_id'], ':type' => $type, ':value' => $value)); + $stmt->execute(array(':site_id' => $row['site_id'], ':type' => $type, ':value' => $value)); } + + $stmt->closeCursor(); + + return; + } + + public static function insertClient(\databox $databox) + { + $connbas = $databox->get_connection(); + + $registry = \registry::get_instance(); + + $sql = 'SELECT site_id FROM clients WHERE site_id = :site_id'; + $stmt = $connbas->prepare($sql); + $stmt->execute(array(':site_id' => $registry->get('GV_ServerName'))); + $rowCount = $stmt->rowCount(); + $stmt->closeCursor(); + + if ($rowCount > 0) + { + return; + } + + $sql = 'INSERT INTO clients (site_id) VALUES (:site_id)'; + $stmt = $connbas->prepare($sql); + $stmt->execute(array(':site_id' => $registry->get('GV_ServerName'))); $stmt->closeCursor(); return; diff --git a/lib/classes/connection.class.php b/lib/classes/connection.class.php index 016e25edcb..7318d72216 100755 --- a/lib/classes/connection.class.php +++ b/lib/classes/connection.class.php @@ -188,8 +188,10 @@ class connection public static function close_PDO_connection($name) { if (isset(self::$_PDO_instance[$name])) + { + self::$_PDO_instance[$name] = null; unset(self::$_PDO_instance[$name]); - + } return; } diff --git a/lib/classes/databox/status.class.php b/lib/classes/databox/status.class.php index 904f75ed27..fe5c0f5e9a 100644 --- a/lib/classes/databox/status.class.php +++ b/lib/classes/databox/status.class.php @@ -159,9 +159,21 @@ class databox_status $statuses = array(); $sbas_ids = $user->ACL()->get_granted_sbas(); + + $see_all = array(); foreach ($sbas_ids as $databox) { + $see_all[$databox->get_sbas_id()] = false; + + foreach($databox->get_collections() as $collection) + { + if($user->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus')) + { + $see_all[$databox->get_sbas_id()] = true; + break; + } + } try { $statuses[$databox->get_sbas_id()] = $databox->get_statusbits(); @@ -177,15 +189,15 @@ class databox_status foreach ($statuses as $sbas_id => $status) { - $see_all = false; + $see_this = isset($see_all[$sbas_id]) ? $see_all[$sbas_id] : false; if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) - $see_all = true; - + $see_this = true; + foreach ($status as $bit => $props) { - if ($props['searchable'] == 0 && !$see_all) + if ($props['searchable'] == 0 && !$see_this) continue; $set = false; diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 08a75dc068..4c609116d2 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -1361,7 +1361,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $db_field = \databox_field::get_instance($this->get_databox(), $param['meta_struct_id']); - if ($db_field->is_readonly() === false && !$force_readonly) + if ($db_field->is_readonly() === true && !$force_readonly) { continue; } @@ -1934,15 +1934,17 @@ class record_adapter implements record_Interface, cache_cacheableInterface */ public function get_data_from_cache($option = null) { + \cache_databox::refresh($this->get_sbas_id()); + $databox = $this->get_databox(); - + return $databox->get_data_from_cache($this->get_cache_key($option)); } public function set_data_to_cache($value, $option = null, $duration = 0) { $databox = $this->get_databox(); - + return $databox->set_data_to_cache($value, $this->get_cache_key($option), $duration); } @@ -1960,6 +1962,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface break; } $databox = $this->get_databox(); + + \cache_databox::update($this->get_sbas_id(), 'record', $this->get_record_id()); return $databox->delete_data_from_cache($this->get_cache_key($option)); } diff --git a/lib/classes/searchEngine/options.class.php b/lib/classes/searchEngine/options.class.php index a518fdff54..78c179d7f9 100644 --- a/lib/classes/searchEngine/options.class.php +++ b/lib/classes/searchEngine/options.class.php @@ -353,7 +353,7 @@ class searchEngine_options implements Serializable { if (!is_null($min_date) && trim($min_date) !== '') { - $this->date_min = DateTime::createFromFormat('d/m/Y h:i:s', $min_date.' 00:00:00'); + $this->date_min = DateTime::createFromFormat('d/m/Y H:i:s', $min_date.' 00:00:00'); } return $this; @@ -377,7 +377,7 @@ class searchEngine_options implements Serializable { if (!is_null($max_date) && trim($max_date) !== '') { - $this->date_max = DateTime::createFromFormat('d/m/Y h:i:s', $max_date.' 23:59:59'); + $this->date_max = DateTime::createFromFormat('d/m/Y H:i:s', $max_date.' 23:59:59'); } return $this; diff --git a/lib/classes/system/file.class.php b/lib/classes/system/file.class.php index c70fb4b0f2..dbd4369f6d 100644 --- a/lib/classes/system/file.class.php +++ b/lib/classes/system/file.class.php @@ -1051,7 +1051,6 @@ class system_file extends SplFileObject $li = $xptrdf->query('rdf:li', $bag->item(0)); if ($li->length > 0) { -// $tfields[$src] = array(); for ($ili = 0; $ili < $li->length; $ili++) { $value = $base64_encoded ? base64_decode($li->item($ili)->nodeValue) : $li->item($ili)->nodeValue; diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php index 116961b6f6..93ae9f8112 100644 --- a/lib/classes/task/Scheduler.class.php +++ b/lib/classes/task/Scheduler.class.php @@ -19,9 +19,11 @@ use Symfony\Component\Console\Output\OutputInterface; class task_Scheduler { + const TASKDELAYTOQUIT = 60; protected $output; + protected static $connection; protected function log($message) { @@ -31,12 +33,12 @@ class task_Scheduler } $registry = registry::get_instance(); - $logdir = $registry->get('GV_RootPath') . 'logs/'; + $logdir = $registry->get('GV_RootPath') . 'logs/'; logs::rotate($logdir . "scheduler.log"); $date_obj = new DateTime(); - $message = sprintf("%s %s \n", $date_obj->format(DATE_ATOM), $message); + $message = sprintf("%s %s \n", $date_obj->format(DATE_ATOM), $message); file_put_contents($logdir . "scheduler.log", $message, FILE_APPEND); @@ -61,14 +63,19 @@ class task_Scheduler $password = $connexion->get('password'); $dbname = $connexion->get('dbname'); - return new connection_pdo('appbox', $hostname, $port, $user, $password, $dbname); + if (!self::$connection) + { + self::$connection = new connection_pdo ('appbox', $hostname, $port, $user, $password, $dbname); + } + + return self::$connection; } public function run(OutputInterface $output = null, $log_tasks = true) { require_once __DIR__ . '/../../bootstrap.php'; $this->output = $output; - $appbox = appbox::get_instance(); + $appbox = appbox::get_instance(); $registry = $appbox->get_registry(); $system = system_server::get_platform(); @@ -77,7 +84,7 @@ class task_Scheduler for ($try = 0; true; $try++) { - $schedlock = fopen(($lockfile = ($lockdir . 'scheduler.lock')), 'a+'); + $schedlock = fopen(($lockfile = ($lockdir . 'scheduler.lock')), 'a+'); if (flock($schedlock, LOCK_EX | LOCK_NB) != true) { $this->log(sprintf("failed to lock '%s' (try=%s/4)", $lockfile, $try)); @@ -110,7 +117,7 @@ class task_Scheduler $sleeptime = 3; - $sql = "UPDATE sitepreff SET schedstatus='started', schedpid = :pid"; + $sql = "UPDATE sitepreff SET schedstatus='started', schedpid = :pid"; $stmt = $conn->prepare($sql); $stmt->execute(array(':pid' => getmypid())); $stmt->closeCursor(); @@ -153,14 +160,14 @@ class task_Scheduler $this->log(sprintf("Warning : abox connection lost, restarting in 10 min.")); } sleep(60 * 10); - $conn = self::get_connection(); + $conn = self::get_connection(); $connwaslost = true; } if ($connwaslost) { $this->log("abox connection restored"); - $sql = 'UPDATE task SET crashed=0'; + $sql = 'UPDATE task SET crashed=0'; $stmt = $conn->prepare($sql); $stmt->execute(); $stmt->closeCursor(); @@ -169,10 +176,10 @@ class task_Scheduler } $schedstatus = ''; - $sql = "SELECT schedstatus FROM sitepreff"; - $stmt = $conn->prepare($sql); + $sql = "SELECT schedstatus FROM sitepreff"; + $stmt = $conn->prepare($sql); $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); + $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); if ($row) @@ -182,13 +189,13 @@ class task_Scheduler if ($schedstatus == 'tostop') { - $sql = 'UPDATE sitepreff SET schedstatus = "stopping"'; + $sql = 'UPDATE sitepreff SET schedstatus = "stopping"'; $stmt = $conn->prepare($sql); $stmt->execute(); $stmt->closeCursor(); // if scheduler is stopped, stop the tasks - $sql = 'UPDATE task2 SET status="tostop" WHERE status != "stopped" and status != "manual"'; + $sql = 'UPDATE task2 SET status="tostop" WHERE status != "stopped" and status != "manual"'; $stmt = $conn->prepare($sql); $stmt->execute(); $stmt->closeCursor(); @@ -208,10 +215,10 @@ class task_Scheduler $ttask[$tkey]["todel"] = true; } - $sql = "SELECT * FROM task2"; + $sql = "SELECT * FROM task2"; $stmt = $conn->prepare($sql); $stmt->execute(); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($task_manager->get_tasks(true) as $task) @@ -232,27 +239,27 @@ class task_Scheduler case "WINDOWS": case "LINUX": $cmd = $phpcli . ' -f ' - . $registry->get('GV_RootPath') - . "bin/console task:run " - . $task->get_task_id() - . " --runner=scheduler "; + . $registry->get('GV_RootPath') + . "bin/console task:run " + . $task->get_task_id() + . " --runner=scheduler "; break; } $ttask[$tkey] = array( - "task" => $task, - "current_status" => $task->get_status(), - "process" => null, - "cmd" => $cmd, - "killat" => null, - "pipes" => null + "task" => $task, + "current_status" => $task->get_status(), + "process" => null, + "cmd" => $cmd, + "killat" => null, + "pipes" => null ); $this->log( - sprintf( - "new Task %s, status=%s" - , $ttask[$tkey]["task"]->get_task_id() - , $task->get_status() - ) + sprintf( + "new Task %s, status=%s" + , $ttask[$tkey]["task"]->get_task_id() + , $task->get_status() + ) ); } else @@ -260,17 +267,17 @@ class task_Scheduler if ($ttask[$tkey]["current_status"] != $task->get_status()) { $this->log( - sprintf( - "Task %s, oldstatus=%s, newstatus=%s" - , $ttask[$tkey]["task"]->get_task_id() - , $ttask[$tkey]["current_status"] - , $task->get_status() - ) + sprintf( + "Task %s, oldstatus=%s, newstatus=%s" + , $ttask[$tkey]["task"]->get_task_id() + , $ttask[$tkey]["current_status"] + , $task->get_status() + ) ); $ttask[$tkey]["current_status"] = $task->get_status(); } - $ttask[$tkey]["task"] = $task; + $ttask[$tkey]["task"] = $task; } $ttask[$tkey]["todel"] = false; } @@ -291,8 +298,8 @@ class task_Scheduler $runningtask = 0; $common_status = array( - task_abstract::STATUS_STARTED - , task_abstract::RETURNSTATUS_STOPPED + task_abstract::STATUS_STARTED + , task_abstract::RETURNSTATUS_STOPPED ); foreach ($ttask as $tkey => $tv) @@ -300,21 +307,21 @@ class task_Scheduler if (!in_array($ttask[$tkey]["task"]->get_status(), $common_status)) { $this->log( - sprintf( - 'task %s has status %s' - , $ttask[$tkey]["task"]->get_task_id() - , $ttask[$tkey]["task"]->get_status() - ) + sprintf( + 'task %s has status %s' + , $ttask[$tkey]["task"]->get_task_id() + , $ttask[$tkey]["task"]->get_status() + ) ); } switch ($ttask[$tkey]["task"]->get_status()) { default: $this->log( - sprintf( - 'Unknow status `%s`' - , $ttask[$tkey]["task"]->get_status() - ) + sprintf( + 'Unknow status `%s`' + , $ttask[$tkey]["task"]->get_status() + ) ); break; case task_abstract::RETURNSTATUS_TORESTART: @@ -333,31 +340,31 @@ class task_Scheduler if ($schedstatus == 'started' && !$ttask[$tkey]["process"]) { $descriptors = array( - 1 => array("pipe", "w") - , 2 => array("pipe", "w") + 1 => array("pipe", "w") + , 2 => array("pipe", "w") ); if ($log_tasks === true) { $descriptors[1] = array( - "file" - , $logdir . "task_$tkey.log" - , "a+" + "file" + , $logdir . "task_$tkey.log" + , "a+" ); $descriptors[2] = array( - "file" - , $logdir . "task_$tkey.error.log" - , "a+" + "file" + , $logdir . "task_$tkey.error.log" + , "a+" ); } $ttask[$tkey]["process"] = proc_open( - $ttask[$tkey]["cmd"] - , $descriptors - , $ttask[$tkey]["pipes"] - , $registry->get('GV_RootPath') . "bin/" - , null - , array('bypass_shell' => true) + $ttask[$tkey]["cmd"] + , $descriptors + , $ttask[$tkey]["pipes"] + , $registry->get('GV_RootPath') . "bin/" + , null + , array('bypass_shell' => true) ); if (is_resource($ttask[$tkey]["process"])) @@ -370,12 +377,12 @@ class task_Scheduler if ($ttask[$tkey]['task']->get_pid() !== null) { $this->log( - sprintf( - "Task %s '%s' started (pid=%s)" - , $ttask[$tkey]['task']->get_task_id() - , $ttask[$tkey]["cmd"] - , $ttask[$tkey]['task']->get_pid() - ) + sprintf( + "Task %s '%s' started (pid=%s)" + , $ttask[$tkey]['task']->get_task_id() + , $ttask[$tkey]["cmd"] + , $ttask[$tkey]['task']->get_pid() + ) ); $runningtask++; } @@ -389,12 +396,12 @@ class task_Scheduler $ttask[$tkey]["process"] = null; $this->log( - sprintf( - "Task %s '%s' failed to start %d times" - , $ttask[$tkey]["task"]->get_task_id() - , $ttask[$tkey]["cmd"] - , $ttask[$tkey]["task"]->get_crash_counter() - ) + sprintf( + "Task %s '%s' failed to start %d times" + , $ttask[$tkey]["task"]->get_task_id() + , $ttask[$tkey]["cmd"] + , $ttask[$tkey]["task"]->get_crash_counter() + ) ); $ttask[$tkey]["task"]->increment_crash_counter(); @@ -425,7 +432,7 @@ class task_Scheduler if ($proc_status['running']) $runningtask++; else - $crashed = true; + $crashed = true; } else { @@ -447,11 +454,11 @@ class task_Scheduler $ttask[$tkey]["process"] = null; $this->log( - sprintf( - "Task %s crashed %d times" - , $ttask[$tkey]["task"]->get_task_id() - , $ttask[$tkey]["task"]->get_crash_counter() - ) + sprintf( + "Task %s crashed %d times" + , $ttask[$tkey]["task"]->get_task_id() + , $ttask[$tkey]["task"]->get_crash_counter() + ) ); @@ -473,7 +480,7 @@ class task_Scheduler { if ($ttask[$tkey]["killat"] === NULL) $ttask[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT; - if (($dt = $ttask[$tkey]["killat"] - time()) < 0) + if (($dt = $ttask[$tkey]["killat"] - time()) < 0) { $ppid = $ttask[$tkey]['task']->get_pid(); $pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`); @@ -487,11 +494,11 @@ class task_Scheduler } $this->log( - sprintf( - "SIGKILL sent to task %s (pid=%s)" - , $ttask[$tkey]["task"]->get_task_id() - , $ttask[$tkey]["task"]->get_pid() - ) + sprintf( + "SIGKILL sent to task %s (pid=%s)" + , $ttask[$tkey]["task"]->get_task_id() + , $ttask[$tkey]["task"]->get_pid() + ) ); proc_terminate($ttask[$tkey]["process"], 9); @@ -507,11 +514,11 @@ class task_Scheduler else { $this->log( - sprintf( - "waiting task %s to quit (kill in %d seconds)" - , $ttask[$tkey]["task"]->get_task_id() - , $dt - ) + sprintf( + "waiting task %s to quit (kill in %d seconds)" + , $ttask[$tkey]["task"]->get_task_id() + , $dt + ) ); $runningtask++; } @@ -537,6 +544,7 @@ class task_Scheduler { $conn->close(); unset($conn); + self::$connection = null; $to_reopen = true; } sleep($sleeptime); @@ -546,7 +554,7 @@ class task_Scheduler } } - $sql = "UPDATE sitepreff SET schedstatus='stopped', schedpid='0'"; + $sql = "UPDATE sitepreff SET schedstatus='stopped', schedpid='0'"; $stmt = $conn->prepare($sql); $stmt->execute(); $stmt->closeCursor(); diff --git a/www/client/index.php b/www/client/index.php index ffe546b87e..f79adbb3ac 100644 --- a/www/client/index.php +++ b/www/client/index.php @@ -102,7 +102,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox); } ?> -
+