Bugfix for masses of php warnings

This commit is contained in:
Michael 2017-01-21 19:50:56 +00:00
parent c74b7565a9
commit dc439c6e50
1 changed files with 95 additions and 75 deletions

View File

@ -91,8 +91,6 @@ function poller_execute($queue) {
$mypid = getmypid();
$cooldown = Config::get("system", "worker_cooldown", 0);
// Quit when in maintenance
if (Config::get('system', 'maintenance', true)) {
return false;
@ -138,8 +136,6 @@ function poller_execute($queue) {
$argv = json_decode($queue["parameter"]);
$argc = count($argv);
// Check for existance and validity of the include file
$include = $argv[0];
@ -155,6 +151,30 @@ function poller_execute($queue) {
if (function_exists($funcname)) {
poller_exec_function($queue, $funcname, $argv);
q("DELETE FROM `workerqueue` WHERE `id` = %d", intval($queue["id"]));
} else {
logger("Function ".$funcname." does not exist");
}
return true;
}
/**
* @brief Execute a function from the queue
*
* @param array $queue Workerqueue entry
* @param string $funcname name of the function
*/
function poller_exec_function($queue, $funcname, $argv) {
$a = get_app();
$mypid = getmypid();
$argc = count($argv);
logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]);
$stamp = (float)microtime(true);
@ -189,25 +209,30 @@ function poller_execute($queue) {
$duration = microtime(true)-$a->performance["start"];
if (Config::get("rendertime", "callstack")) {
if (isset($a->callstack["database"])) {
$o = "\nDatabase Read:\n";
foreach ($a->callstack["database"] AS $func => $time) {
$time = round($time, 3);
if ($time > 0)
$o .= $func.": ".$time."\n";
}
}
if (isset($a->callstack["database_write"])) {
$o .= "\nDatabase Write:\n";
foreach ($a->callstack["database_write"] AS $func => $time) {
$time = round($time, 3);
if ($time > 0)
$o .= $func.": ".$time."\n";
}
}
if (isset($a->callstack["network"])) {
$o .= "\nNetwork:\n";
foreach ($a->callstack["network"] AS $func => $time) {
$time = round($time, 3);
if ($time > 0)
$o .= $func.": ".$time."\n";
}
}
} else {
$o = '';
}
@ -222,17 +247,12 @@ function poller_execute($queue) {
LOGGER_DEBUG);
}
$cooldown = Config::get("system", "worker_cooldown", 0);
if ($cooldown > 0) {
logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds");
sleep($cooldown);
}
q("DELETE FROM `workerqueue` WHERE `id` = %d", intval($queue["id"]));
} else {
logger("Function ".$funcname." does not exist");
}
return true;
}
/**