added spaces + some curly braces + some usage of dbm::is_result()

Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-04-04 19:48:13 +02:00 committed by Roland Häder
parent 701e761c68
commit f4a33ed3f0
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
9 changed files with 114 additions and 84 deletions

View file

@ -12,7 +12,7 @@
use Friendica\Core\Config;
require_once("include/dba.php");
require_once "include/dba.php";
if (! function_exists('get_browser_language')) {
/**
@ -63,8 +63,9 @@ function push_lang($language) {
$a->langsave = $lang;
if($language === $lang)
if ($language === $lang) {
return;
}
if (isset($a->strings) && count($a->strings)) {
$a->stringsave = $a->strings;
@ -77,13 +78,15 @@ function push_lang($language) {
function pop_lang() {
global $lang, $a;
if($lang === $a->langsave)
if ($lang === $a->langsave) {
return;
}
if(isset($a->stringsave))
if (isset($a->stringsave)) {
$a->strings = $a->stringsave;
else
} else {
$a->strings = array();
}
$lang = $a->langsave;
}

View file

@ -525,12 +525,14 @@ function service_class_fetch($uid,$property) {
function upgrade_link($bbcode = false) {
$l = get_config('service_class','upgrade_link');
if(! $l)
if (! $l) {
return '';
if($bbcode)
}
if ($bbcode) {
$t = sprintf('[url=%s]' . t('Click here to upgrade.') . '[/url]', $l);
else
} else {
$t = sprintf('<a href="%s">' . t('Click here to upgrade.') . '</div>', $l);
}
return $t;
}
@ -557,13 +559,15 @@ function upgrade_bool_message($bbcode = false) {
*/
function theme_include($file, $root = '') {
// Make sure $root ends with a slash / if it's not blank
if($root !== '' && $root[strlen($root)-1] !== '/')
if ($root !== '' && $root[strlen($root)-1] !== '/') {
$root = $root . '/';
}
$theme_info = $a->theme_info;
if(is_array($theme_info) AND array_key_exists('extends',$theme_info))
if (is_array($theme_info) AND array_key_exists('extends',$theme_info)) {
$parent = $theme_info['extends'];
else
} else {
$parent = 'NOPATH';
}
$theme = current_theme();
$thname = $theme;
$ext = substr($file,strrpos($file,'.')+1);
@ -574,10 +578,11 @@ function theme_include($file, $root = '') {
);
foreach ($paths as $p) {
// strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php)
if(strpos($p,'NOPATH') !== false)
if (strpos($p,'NOPATH') !== false) {
continue;
if(file_exists($p))
} elseif (file_exists($p)) {
return $p;
}
}
return '';
}

View file

@ -378,8 +378,9 @@ function poller_kill_stale_workers() {
// Kill long running processes
// Check if the priority is in a valid range
if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE)))
if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE))) {
$pid["priority"] = PRIORITY_MEDIUM;
}
// Define the maximum durations
$max_duration_defaults = array(PRIORITY_CRITICAL => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 360);

View file

@ -30,9 +30,10 @@ function handle_pubsubhubbub($id) {
global $a;
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
if (!$r)
if (!dbm::is_result($r)) {
return;
else
}
$rr = $r[0];
/// @todo Check server status with poco_check_server()

View file

@ -29,10 +29,29 @@ function queue_run(&$argv, &$argc){
// Handling the pubsubhubbub requests
proc_run(PRIORITY_HIGH,'include/pubsubpublish.php');
$interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
// If we are using the worker we don't need a delivery interval
/// @TODO To much get_config() here
if (get_config("system", "worker")) {
$interval = false;
}
$r = q("select * from deliverq where 1");
if ($r) {
foreach ($r as $rr) {
logger('queue: deliverq');
proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
if ($interval) {
time_sleep_until(microtime(true) + (float) $interval);
}
}
}
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
if ($r) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
logger('Expired queue data: ' . $rr['content'], LOGGER_DATA);

View file

@ -49,12 +49,14 @@ function was_recently_delayed($cid) {
function add_to_queue($cid,$network,$msg,$batch = false) {
$max_queue = get_config('system','max_contact_queue');
if($max_queue < 1)
if ($max_queue < 1) {
$max_queue = 500;
}
$batch_queue = get_config('system','max_batch_queue');
if($batch_queue < 1)
if ($batch_queue < 1) {
$batch_queue = 1000;
}
$r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
@ -64,8 +66,7 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
if ($batch && ($r[0]['total'] > $batch_queue)) {
logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
return;
}
elseif((! $batch) && ($r[0]['total'] > $max_queue)) {
} elseif ((! $batch) && ($r[0]['total'] > $max_queue)) {
logger('add_to_queue: too many queued items for contact ' . $cid . ' - discarding message');
return;
}