mirror of
https://github.com/friendica/friendica
synced 2025-04-27 23:10:12 +00:00
added spaces + some curly braces + some usage of dbm::is_result()
Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
parent
701e761c68
commit
f4a33ed3f0
9 changed files with 114 additions and 84 deletions
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("include/dba.php");
|
require_once "include/dba.php";
|
||||||
|
|
||||||
if (! function_exists('get_browser_language')) {
|
if (! function_exists('get_browser_language')) {
|
||||||
/**
|
/**
|
||||||
|
@ -63,8 +63,9 @@ function push_lang($language) {
|
||||||
|
|
||||||
$a->langsave = $lang;
|
$a->langsave = $lang;
|
||||||
|
|
||||||
if($language === $lang)
|
if ($language === $lang) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($a->strings) && count($a->strings)) {
|
if (isset($a->strings) && count($a->strings)) {
|
||||||
$a->stringsave = $a->strings;
|
$a->stringsave = $a->strings;
|
||||||
|
@ -77,13 +78,15 @@ function push_lang($language) {
|
||||||
function pop_lang() {
|
function pop_lang() {
|
||||||
global $lang, $a;
|
global $lang, $a;
|
||||||
|
|
||||||
if($lang === $a->langsave)
|
if ($lang === $a->langsave) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($a->stringsave))
|
if (isset($a->stringsave)) {
|
||||||
$a->strings = $a->stringsave;
|
$a->strings = $a->stringsave;
|
||||||
else
|
} else {
|
||||||
$a->strings = array();
|
$a->strings = array();
|
||||||
|
}
|
||||||
|
|
||||||
$lang = $a->langsave;
|
$lang = $a->langsave;
|
||||||
}
|
}
|
||||||
|
|
|
@ -525,12 +525,14 @@ function service_class_fetch($uid,$property) {
|
||||||
|
|
||||||
function upgrade_link($bbcode = false) {
|
function upgrade_link($bbcode = false) {
|
||||||
$l = get_config('service_class','upgrade_link');
|
$l = get_config('service_class','upgrade_link');
|
||||||
if(! $l)
|
if (! $l) {
|
||||||
return '';
|
return '';
|
||||||
if($bbcode)
|
}
|
||||||
|
if ($bbcode) {
|
||||||
$t = sprintf('[url=%s]' . t('Click here to upgrade.') . '[/url]', $l);
|
$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);
|
$t = sprintf('<a href="%s">' . t('Click here to upgrade.') . '</div>', $l);
|
||||||
|
}
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,13 +559,15 @@ function upgrade_bool_message($bbcode = false) {
|
||||||
*/
|
*/
|
||||||
function theme_include($file, $root = '') {
|
function theme_include($file, $root = '') {
|
||||||
// Make sure $root ends with a slash / if it's not blank
|
// 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 . '/';
|
$root = $root . '/';
|
||||||
|
}
|
||||||
$theme_info = $a->theme_info;
|
$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'];
|
$parent = $theme_info['extends'];
|
||||||
else
|
} else {
|
||||||
$parent = 'NOPATH';
|
$parent = 'NOPATH';
|
||||||
|
}
|
||||||
$theme = current_theme();
|
$theme = current_theme();
|
||||||
$thname = $theme;
|
$thname = $theme;
|
||||||
$ext = substr($file,strrpos($file,'.')+1);
|
$ext = substr($file,strrpos($file,'.')+1);
|
||||||
|
@ -574,10 +578,11 @@ function theme_include($file, $root = '') {
|
||||||
);
|
);
|
||||||
foreach ($paths as $p) {
|
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)
|
// 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;
|
continue;
|
||||||
if(file_exists($p))
|
} elseif (file_exists($p)) {
|
||||||
return $p;
|
return $p;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,8 +378,9 @@ function poller_kill_stale_workers() {
|
||||||
// Kill long running processes
|
// Kill long running processes
|
||||||
|
|
||||||
// Check if the priority is in a valid range
|
// 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;
|
$pid["priority"] = PRIORITY_MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
// Define the maximum durations
|
// Define the maximum durations
|
||||||
$max_duration_defaults = array(PRIORITY_CRITICAL => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 360);
|
$max_duration_defaults = array(PRIORITY_CRITICAL => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 360);
|
||||||
|
|
|
@ -30,9 +30,10 @@ function handle_pubsubhubbub($id) {
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
|
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
|
||||||
if (!$r)
|
if (!dbm::is_result($r)) {
|
||||||
return;
|
return;
|
||||||
else
|
}
|
||||||
|
|
||||||
$rr = $r[0];
|
$rr = $r[0];
|
||||||
|
|
||||||
/// @todo Check server status with poco_check_server()
|
/// @todo Check server status with poco_check_server()
|
||||||
|
|
|
@ -29,10 +29,29 @@ function queue_run(&$argv, &$argc){
|
||||||
// Handling the pubsubhubbub requests
|
// Handling the pubsubhubbub requests
|
||||||
proc_run(PRIORITY_HIGH,'include/pubsubpublish.php');
|
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`
|
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
|
||||||
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
||||||
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
||||||
if ($r) {
|
if (dbm::is_result($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
|
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
|
||||||
logger('Expired queue data: ' . $rr['content'], LOGGER_DATA);
|
logger('Expired queue data: ' . $rr['content'], LOGGER_DATA);
|
||||||
|
|
|
@ -49,12 +49,14 @@ function was_recently_delayed($cid) {
|
||||||
function add_to_queue($cid,$network,$msg,$batch = false) {
|
function add_to_queue($cid,$network,$msg,$batch = false) {
|
||||||
|
|
||||||
$max_queue = get_config('system','max_contact_queue');
|
$max_queue = get_config('system','max_contact_queue');
|
||||||
if($max_queue < 1)
|
if ($max_queue < 1) {
|
||||||
$max_queue = 500;
|
$max_queue = 500;
|
||||||
|
}
|
||||||
|
|
||||||
$batch_queue = get_config('system','max_batch_queue');
|
$batch_queue = get_config('system','max_batch_queue');
|
||||||
if($batch_queue < 1)
|
if ($batch_queue < 1) {
|
||||||
$batch_queue = 1000;
|
$batch_queue = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
$r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
||||||
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
|
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)) {
|
if ($batch && ($r[0]['total'] > $batch_queue)) {
|
||||||
logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
|
logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
|
||||||
return;
|
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');
|
logger('add_to_queue: too many queued items for contact ' . $cid . ' - discarding message');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue