Merge develop into 0308-Notifications-restructure
Conflicts: mod/notifications.php
This commit is contained in:
+5
-5
@@ -45,10 +45,10 @@ function user_remove($uid) {
|
||||
// don't delete yet, will be done later when contacts have deleted my stuff
|
||||
// q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
|
||||
q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
|
||||
proc_run('php', "include/notifier.php", "removeme", $uid);
|
||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "removeme", $uid);
|
||||
|
||||
// Send an update to the directory
|
||||
proc_run('php', "include/directory.php", $r[0]['url']);
|
||||
proc_run(PRIORITY_LOW, "include/directory.php", $r[0]['url']);
|
||||
|
||||
if($uid == local_user()) {
|
||||
unset($_SESSION['authenticated']);
|
||||
@@ -275,7 +275,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
||||
|
||||
if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND
|
||||
in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
|
||||
proc_run('php',"include/update_gcontact.php", $profile["gid"]);
|
||||
proc_run(PRIORITY_LOW, "include/update_gcontact.php", $profile["gid"]);
|
||||
|
||||
// Show contact details of Diaspora contacts only if connected
|
||||
if (($profile["cid"] == 0) AND ($profile["network"] == NETWORK_DIASPORA)) {
|
||||
@@ -631,11 +631,11 @@ function posts_from_contact($a, $contact_id) {
|
||||
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
||||
`author-name` AS `name`, `owner-avatar` AS `photo`,
|
||||
`owner-link` AS `url`, `owner-avatar` AS `thumb`
|
||||
FROM `item` FORCE INDEX (`uid_contactid_created`)
|
||||
FROM `item` FORCE INDEX (`uid_contactid_id`)
|
||||
WHERE `item`.`uid` = %d AND `contact-id` = %d
|
||||
AND `author-link` IN ('%s', '%s')
|
||||
AND NOT `deleted` AND NOT `moderated` AND `visible`
|
||||
ORDER BY `item`.`created` DESC LIMIT %d, %d",
|
||||
ORDER BY `item`.`id` DESC LIMIT %d, %d",
|
||||
intval(local_user()),
|
||||
intval($contact_id),
|
||||
dbesc(str_replace("https://", "http://", $contact["url"])),
|
||||
|
||||
@@ -481,11 +481,11 @@ function acl_lookup(&$a, $out_type = 'json') {
|
||||
if ($type=='' || $type=='g'){
|
||||
|
||||
$r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
|
||||
FROM `group`,`group_member`
|
||||
WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d
|
||||
AND `group_member`.`gid`=`group`.`id`
|
||||
FROM `group`
|
||||
INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id` AND `group_member`.`uid` = `group`.`uid`
|
||||
WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
|
||||
$sql_extra
|
||||
GROUP BY `group`.`id`
|
||||
GROUP BY `group`.`name`
|
||||
ORDER BY `group`.`name`
|
||||
LIMIT %d,%d",
|
||||
intval(local_user()),
|
||||
|
||||
+491
-387
File diff suppressed because it is too large
Load Diff
+81
-52
@@ -70,53 +70,48 @@ function cron_run(&$argv, &$argc){
|
||||
|
||||
// run queue delivery process in the background
|
||||
|
||||
proc_run('php',"include/queue.php");
|
||||
proc_run(PRIORITY_LOW,"include/queue.php");
|
||||
|
||||
// run the process to discover global contacts in the background
|
||||
|
||||
proc_run('php',"include/discover_poco.php");
|
||||
proc_run(PRIORITY_LOW,"include/discover_poco.php");
|
||||
|
||||
// run the process to update locally stored global contacts in the background
|
||||
|
||||
proc_run('php',"include/discover_poco.php", "checkcontact");
|
||||
proc_run(PRIORITY_LOW,"include/discover_poco.php", "checkcontact");
|
||||
|
||||
// expire any expired accounts
|
||||
// Expire and remove user entries
|
||||
cron_expire_and_remove_users();
|
||||
|
||||
q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
|
||||
AND `account_expires_on` != '0000-00-00 00:00:00'
|
||||
AND `account_expires_on` < UTC_TIMESTAMP() ");
|
||||
// If the worker is active, split the jobs in several sub processes
|
||||
if (get_config("system", "worker")) {
|
||||
// Check OStatus conversations
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
|
||||
|
||||
// delete user and contact records for recently removed accounts
|
||||
// Check every conversation
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
|
||||
|
||||
$r = q("SELECT * FROM `user` WHERE `account_removed` = 1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
||||
if ($r) {
|
||||
foreach($r as $user) {
|
||||
q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid']));
|
||||
q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
|
||||
}
|
||||
// Call possible post update functions
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
|
||||
|
||||
// update nodeinfo data
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "nodeinfo");
|
||||
} else {
|
||||
// Check OStatus conversations
|
||||
// Check only conversations with mentions (for a longer time)
|
||||
ostatus::check_conversations(true);
|
||||
|
||||
// Check every conversation
|
||||
ostatus::check_conversations(false);
|
||||
|
||||
// Call possible post update functions
|
||||
// see include/post_update.php for more details
|
||||
post_update();
|
||||
|
||||
// update nodeinfo data
|
||||
nodeinfo_cron();
|
||||
}
|
||||
|
||||
$abandon_days = intval(get_config('system','account_abandon_days'));
|
||||
if($abandon_days < 1)
|
||||
$abandon_days = 0;
|
||||
|
||||
// Check OStatus conversations
|
||||
// Check only conversations with mentions (for a longer time)
|
||||
ostatus::check_conversations(true);
|
||||
|
||||
// Check every conversation
|
||||
ostatus::check_conversations(false);
|
||||
|
||||
// Call possible post update functions
|
||||
// see include/post_update.php for more details
|
||||
post_update();
|
||||
|
||||
// update nodeinfo data
|
||||
nodeinfo_cron();
|
||||
|
||||
/// @TODO Regenerate usage statistics
|
||||
// q("ANALYZE TABLE `item`");
|
||||
|
||||
// once daily run birthday_updates and then expire in background
|
||||
|
||||
$d1 = get_config('system','last_expire_day');
|
||||
@@ -126,11 +121,11 @@ function cron_run(&$argv, &$argc){
|
||||
|
||||
update_contact_birthdays();
|
||||
|
||||
proc_run('php',"include/discover_poco.php", "suggestions");
|
||||
proc_run(PRIORITY_LOW,"include/discover_poco.php", "suggestions");
|
||||
|
||||
set_config('system','last_expire_day',$d2);
|
||||
|
||||
proc_run('php','include/expire.php');
|
||||
proc_run(PRIORITY_LOW,'include/expire.php');
|
||||
}
|
||||
|
||||
// Clear cache entries
|
||||
@@ -142,28 +137,64 @@ function cron_run(&$argv, &$argc){
|
||||
// Repair entries in the database
|
||||
cron_repair_database();
|
||||
|
||||
// Poll contacts
|
||||
cron_poll_contacts($argc, $argv);
|
||||
|
||||
logger('cron: end');
|
||||
|
||||
set_config('system','last_cron', time());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Expire and remove user entries
|
||||
*/
|
||||
function cron_expire_and_remove_users() {
|
||||
// expire any expired accounts
|
||||
q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
|
||||
AND `account_expires_on` != '0000-00-00 00:00:00'
|
||||
AND `account_expires_on` < UTC_TIMESTAMP() ");
|
||||
|
||||
// delete user and contact records for recently removed accounts
|
||||
$r = q("SELECT * FROM `user` WHERE `account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
||||
if ($r) {
|
||||
foreach($r as $user) {
|
||||
q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid']));
|
||||
q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Poll contacts for unreceived messages
|
||||
*
|
||||
* @param Integer $argc Number of command line arguments
|
||||
* @param Array $argv Array of command line arguments
|
||||
*/
|
||||
function cron_poll_contacts($argc, $argv) {
|
||||
$manual_id = 0;
|
||||
$generation = 0;
|
||||
$force = false;
|
||||
$restart = false;
|
||||
|
||||
if(($argc > 1) && ($argv[1] == 'force'))
|
||||
if (($argc > 1) && ($argv[1] == 'force'))
|
||||
$force = true;
|
||||
|
||||
if(($argc > 1) && ($argv[1] == 'restart')) {
|
||||
if (($argc > 1) && ($argv[1] == 'restart')) {
|
||||
$restart = true;
|
||||
$generation = intval($argv[2]);
|
||||
if(! $generation)
|
||||
if (!$generation)
|
||||
killme();
|
||||
}
|
||||
|
||||
if(($argc > 1) && intval($argv[1])) {
|
||||
if (($argc > 1) && intval($argv[1])) {
|
||||
$manual_id = intval($argv[1]);
|
||||
$force = true;
|
||||
}
|
||||
|
||||
$interval = intval(get_config('system','poll_interval'));
|
||||
if(! $interval)
|
||||
if (!$interval)
|
||||
$interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
|
||||
|
||||
// If we are using the worker we don't need a delivery interval
|
||||
@@ -180,6 +211,10 @@ function cron_run(&$argv, &$argc){
|
||||
// and which have a polling address and ignore Diaspora since
|
||||
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
|
||||
|
||||
$abandon_days = intval(get_config('system','account_abandon_days'));
|
||||
if($abandon_days < 1)
|
||||
$abandon_days = 0;
|
||||
|
||||
$abandon_sql = (($abandon_days)
|
||||
? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days))
|
||||
: ''
|
||||
@@ -200,11 +235,11 @@ function cron_run(&$argv, &$argc){
|
||||
dbesc(NETWORK_MAIL2)
|
||||
);
|
||||
|
||||
if(! count($contacts)) {
|
||||
if (!count($contacts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($contacts as $c) {
|
||||
foreach ($contacts as $c) {
|
||||
|
||||
$res = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||
intval($c['id'])
|
||||
@@ -266,24 +301,18 @@ function cron_run(&$argv, &$argc){
|
||||
$update = true;
|
||||
break;
|
||||
}
|
||||
if(!$update)
|
||||
if (!$update)
|
||||
continue;
|
||||
}
|
||||
|
||||
logger("Polling ".$contact["network"]." ".$contact["id"]." ".$contact["nick"]." ".$contact["name"]);
|
||||
|
||||
proc_run('php','include/onepoll.php',$contact['id']);
|
||||
proc_run(PRIORITY_MEDIUM,'include/onepoll.php',$contact['id']);
|
||||
|
||||
if($interval)
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
}
|
||||
|
||||
logger('cron: end');
|
||||
|
||||
set_config('system','last_cron', time());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+18
-3
@@ -31,6 +31,17 @@ function cronhooks_run(&$argv, &$argc){
|
||||
return;
|
||||
}
|
||||
|
||||
load_hooks();
|
||||
|
||||
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||
foreach ($a->hooks["cron"] as $hook)
|
||||
if ($hook[1] == $argv[1]) {
|
||||
logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
|
||||
call_single_hook($a, $name, $hook, $data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$last = get_config('system','last_cronhook');
|
||||
|
||||
$poll_interval = intval(get_config('system','cronhook_interval'));
|
||||
@@ -47,13 +58,17 @@ function cronhooks_run(&$argv, &$argc){
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
|
||||
logger('cronhooks: start');
|
||||
|
||||
$d = datetime_convert();
|
||||
|
||||
call_hooks('cron', $d);
|
||||
if (get_config("system", "worker") AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||
foreach ($a->hooks["cron"] as $hook) {
|
||||
logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
|
||||
}
|
||||
} else
|
||||
call_hooks('cron', $d);
|
||||
|
||||
logger('cronhooks: end');
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
|
||||
$directory = dirname($_SERVER["argv"][0]);
|
||||
|
||||
if (substr($directory, 0, 1) != "/")
|
||||
$directory = $_SERVER["PWD"]."/".$directory;
|
||||
|
||||
$directory = realpath($directory."/..");
|
||||
|
||||
chdir($directory);
|
||||
}
|
||||
|
||||
require_once("boot.php");
|
||||
|
||||
|
||||
function cronjobs_run(&$argv, &$argc){
|
||||
global $a, $db;
|
||||
|
||||
if(is_null($a)) {
|
||||
$a = new App;
|
||||
}
|
||||
|
||||
if(is_null($db)) {
|
||||
@include(".htconfig.php");
|
||||
require_once("include/dba.php");
|
||||
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
};
|
||||
|
||||
|
||||
require_once('include/session.php');
|
||||
require_once('include/datetime.php');
|
||||
require_once('include/ostatus.php');
|
||||
require_once('include/post_update.php');
|
||||
require_once('mod/nodeinfo.php');
|
||||
|
||||
load_config('config');
|
||||
load_config('system');
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
// No parameter set? So return
|
||||
if ($argc <= 1)
|
||||
return;
|
||||
|
||||
// Check OStatus conversations
|
||||
// Check only conversations with mentions (for a longer time)
|
||||
if ($argv[1] == 'ostatus_mentions') {
|
||||
ostatus::check_conversations(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check every conversation
|
||||
if ($argv[1] == 'ostatus_conversations') {
|
||||
ostatus::check_conversations(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Call possible post update functions
|
||||
// see include/post_update.php for more details
|
||||
if ($argv[1] == 'post_update') {
|
||||
post_update();
|
||||
return;
|
||||
}
|
||||
|
||||
// update nodeinfo data
|
||||
if ($argv[1] == 'nodeinfo') {
|
||||
nodeinfo_cron();
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
cronjobs_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||
killme();
|
||||
}
|
||||
@@ -858,6 +858,7 @@ function db_definition() {
|
||||
"uid_title" => array("uid","title"),
|
||||
"uid_thrparent" => array("uid","thr-parent"),
|
||||
"uid_parenturi" => array("uid","parent-uri"),
|
||||
"uid_contactid_id" => array("uid","contact-id","id"),
|
||||
"uid_contactid_created" => array("uid","contact-id","created"),
|
||||
"gcontactid_uid_created" => array("gcontact-id","uid","created"),
|
||||
"authorid_created" => array("author-id","created"),
|
||||
@@ -868,7 +869,7 @@ function db_definition() {
|
||||
"uid_wall_created" => array("uid","wall","created"),
|
||||
"resource-id" => array("resource-id"),
|
||||
"uid_type" => array("uid","type"),
|
||||
"uid_starred" => array("uid","starred"),
|
||||
"uid_starred_id" => array("uid","starred", "id"),
|
||||
"contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
|
||||
"uid_wall_parent_created" => array("uid","wall","parent","created"),
|
||||
"uid_type_changed" => array("uid","type","changed"),
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ function new_contact($uid,$url,$interactive = false) {
|
||||
|
||||
// pull feed and consume it, which should subscribe to the hub.
|
||||
|
||||
proc_run('php',"include/onepoll.php","$contact_id", "force");
|
||||
proc_run(PRIORITY_MEDIUM, "include/onepoll.php", $contact_id, "force");
|
||||
|
||||
// create a follow slap
|
||||
|
||||
|
||||
@@ -818,7 +818,7 @@ function zrl_init(&$a) {
|
||||
}
|
||||
}
|
||||
|
||||
proc_run('php','include/gprobe.php',bin2hex($tmp_str));
|
||||
proc_run(PRIORITY_LOW, 'include/gprobe.php',bin2hex($tmp_str));
|
||||
$arr = array('zrl' => $tmp_str, 'url' => $a->cmd);
|
||||
call_hooks('zrl_init',$arr);
|
||||
}
|
||||
|
||||
+5
-5
@@ -917,7 +917,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
||||
check_item_notification($current_post, $uid);
|
||||
|
||||
if ($notify)
|
||||
proc_run('php', "include/notifier.php", $notify_type, $current_post);
|
||||
proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $current_post);
|
||||
|
||||
return $current_post;
|
||||
}
|
||||
@@ -1156,7 +1156,7 @@ function tag_deliver($uid,$item_id) {
|
||||
);
|
||||
update_thread($item_id);
|
||||
|
||||
proc_run('php','include/notifier.php','tgroup',$item_id);
|
||||
proc_run(PRIORITY_HIGH,'include/notifier.php', 'tgroup', $item_id);
|
||||
|
||||
}
|
||||
|
||||
@@ -1763,7 +1763,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
|
||||
drop_item($item['id'],false);
|
||||
}
|
||||
|
||||
proc_run('php',"include/notifier.php","expire","$uid");
|
||||
proc_run(PRIORITY_HIGH,"include/notifier.php", "expire", $uid);
|
||||
|
||||
}
|
||||
|
||||
@@ -1785,7 +1785,7 @@ function drop_items($items) {
|
||||
// multiple threads may have been deleted, send an expire notification
|
||||
|
||||
if($uid)
|
||||
proc_run('php',"include/notifier.php","expire","$uid");
|
||||
proc_run(PRIORITY_HIGH,"include/notifier.php", "expire", $uid);
|
||||
}
|
||||
|
||||
|
||||
@@ -1998,7 +1998,7 @@ function drop_item($id,$interactive = true) {
|
||||
|
||||
// send the notification upstream/downstream as the case may be
|
||||
|
||||
proc_run('php',"include/notifier.php","drop","$drop_id");
|
||||
proc_run(PRIORITY_HIGH,"include/notifier.php", "drop", $drop_id);
|
||||
|
||||
if(! $interactive)
|
||||
return $owner;
|
||||
|
||||
+2
-2
@@ -153,7 +153,7 @@ function do_like($item_id, $verb) {
|
||||
);
|
||||
|
||||
$like_item_id = $like_item['id'];
|
||||
proc_run('php',"include/notifier.php","like","$like_item_id");
|
||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $like_item_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ EOT;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
|
||||
proc_run('php',"include/notifier.php","like","$post_id");
|
||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
|
||||
}
|
||||
|
||||
if($post_id) {
|
||||
proc_run('php',"include/notifier.php","mail","$post_id");
|
||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
|
||||
return intval($post_id);
|
||||
} else {
|
||||
return -3;
|
||||
|
||||
@@ -16,7 +16,7 @@ require_once('include/salmon.php');
|
||||
/*
|
||||
* The notifier is typically called with:
|
||||
*
|
||||
* proc_run('php', "include/notifier.php", COMMAND, ITEM_ID);
|
||||
* proc_run(PRIORITY_HIGH, "include/notifier.php", COMMAND, ITEM_ID);
|
||||
*
|
||||
* where COMMAND is one of the following:
|
||||
*
|
||||
@@ -355,7 +355,7 @@ function notifier_run(&$argv, &$argc){
|
||||
// a delivery fork. private groups (forum_mode == 2) do not uplink
|
||||
|
||||
if((intval($parent['forum_mode']) == 1) && (! $top_level) && ($cmd !== 'uplink')) {
|
||||
proc_run('php','include/notifier.php','uplink',$item_id);
|
||||
proc_run(PRIORITY_HIGH,'include/notifier.php','uplink',$item_id);
|
||||
}
|
||||
|
||||
$conversants = array();
|
||||
@@ -538,7 +538,7 @@ function notifier_run(&$argv, &$argc){
|
||||
$this_batch[] = $contact['id'];
|
||||
|
||||
if(count($this_batch) >= $deliveries_per_process) {
|
||||
proc_run('php','include/delivery.php',$cmd,$item_id,$this_batch);
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$this_batch);
|
||||
$this_batch = array();
|
||||
if($interval)
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
@@ -548,7 +548,7 @@ function notifier_run(&$argv, &$argc){
|
||||
|
||||
// be sure to pick up any stragglers
|
||||
if(count($this_batch))
|
||||
proc_run('php','include/delivery.php',$cmd,$item_id,$this_batch);
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$this_batch);
|
||||
}
|
||||
|
||||
// send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
|
||||
@@ -619,7 +619,7 @@ function notifier_run(&$argv, &$argc){
|
||||
|
||||
if((! $mail) && (! $fsuggest) && (! $followup)) {
|
||||
logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
|
||||
proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']);
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$rr['id']);
|
||||
if($interval)
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
@@ -659,7 +659,7 @@ function notifier_run(&$argv, &$argc){
|
||||
}
|
||||
|
||||
// Handling the pubsubhubbub requests
|
||||
proc_run('php','include/pubsubpublish.php');
|
||||
proc_run(PRIORITY_HIGH,'include/pubsubpublish.php');
|
||||
}
|
||||
|
||||
logger('notifier: calling hooks', LOGGER_DEBUG);
|
||||
|
||||
+1
-1
@@ -1971,7 +1971,7 @@ class ostatus {
|
||||
OR (`item`.`network` = '%s' AND ((`thread`.`network` IN ('%s', '%s')) OR (`thritem`.`network` IN ('%s', '%s')))) AND `thread`.`mention`)
|
||||
AND ((`item`.`owner-link` IN ('%s', '%s') AND (`item`.`parent` = `item`.`id`))
|
||||
OR (`item`.`author-link` IN ('%s', '%s')))
|
||||
ORDER BY `item`.`received` DESC
|
||||
ORDER BY `item`.`id` DESC
|
||||
LIMIT 0, 300",
|
||||
intval($owner["uid"]), dbesc($check_date), dbesc(NETWORK_DFRN),
|
||||
//dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
|
||||
|
||||
+27
-23
@@ -205,37 +205,41 @@ function load_hooks() {
|
||||
* @param string $name of the hook to call
|
||||
* @param string|array &$data to transmit to the callback handler
|
||||
*/
|
||||
if(! function_exists('call_hooks')) {
|
||||
function call_hooks($name, &$data = null) {
|
||||
$stamp1 = microtime(true);
|
||||
|
||||
$a = get_app();
|
||||
|
||||
#logger($name, LOGGER_ALL);
|
||||
if (is_array($a->hooks) && array_key_exists($name, $a->hooks))
|
||||
foreach ($a->hooks[$name] as $hook)
|
||||
call_single_hook($a, $name, $hook, $data);
|
||||
}
|
||||
|
||||
if((is_array($a->hooks)) && (array_key_exists($name,$a->hooks))) {
|
||||
foreach($a->hooks[$name] as $hook) {
|
||||
// Don't run a theme's hook if the user isn't using the theme
|
||||
if(strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/'.current_theme()) === false)
|
||||
continue;
|
||||
/**
|
||||
* @brief Calls a single hook.
|
||||
*
|
||||
* @param string $name of the hook to call
|
||||
* @param array $hook Hook data
|
||||
* @param string|array &$data to transmit to the callback handler
|
||||
*/
|
||||
function call_single_hook($a, $name, $hook, &$data = null) {
|
||||
// Don't run a theme's hook if the user isn't using the theme
|
||||
if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/'.current_theme()) === false)
|
||||
return;
|
||||
|
||||
@include_once($hook[0]);
|
||||
if(function_exists($hook[1])) {
|
||||
$func = $hook[1];
|
||||
//logger($name." => ".$hook[0].":".$func."()", LOGGER_DEBUG);
|
||||
$func($a,$data);
|
||||
}
|
||||
else {
|
||||
// remove orphan hooks
|
||||
q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s'",
|
||||
dbesc($name),
|
||||
dbesc($hook[0]),
|
||||
dbesc($hook[1])
|
||||
);
|
||||
}
|
||||
}
|
||||
@include_once($hook[0]);
|
||||
if (function_exists($hook[1])) {
|
||||
$func = $hook[1];
|
||||
$func($a, $data);
|
||||
} else {
|
||||
// remove orphan hooks
|
||||
q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s'",
|
||||
dbesc($name),
|
||||
dbesc($hook[0]),
|
||||
dbesc($hook[1])
|
||||
);
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
//check if an app_menu hook exist for plugin $name.
|
||||
//Return true if the plugin is an app
|
||||
|
||||
+25
-2
@@ -46,10 +46,10 @@ function poller_run(&$argv, &$argc){
|
||||
|
||||
if(($argc <= 1) OR ($argv[1] != "no_cron")) {
|
||||
// Run the cron job that calls all other jobs
|
||||
proc_run("php","include/cron.php");
|
||||
proc_run(PRIORITY_MEDIUM, "include/cron.php");
|
||||
|
||||
// Run the cronhooks job separately from cron for being able to use a different timing
|
||||
proc_run("php","include/cronhooks.php");
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronhooks.php");
|
||||
|
||||
// Cleaning dead processes
|
||||
poller_kill_stale_workers();
|
||||
@@ -270,11 +270,34 @@ function poller_too_much_workers() {
|
||||
$slope = $maxworkers / pow($maxsysload, $exponent);
|
||||
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
|
||||
|
||||
if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($active >= $queues)) {
|
||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` = %d AND `executed` = '0000-00-00 00:00:00'",
|
||||
intval(PRIORITY_HIGH));
|
||||
$high_waiting = $s[0]["total"];
|
||||
|
||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` = %d AND `executed` != '0000-00-00 00:00:00'",
|
||||
intval(PRIORITY_HIGH));
|
||||
$high_running = $s[0]["total"];
|
||||
|
||||
/// @todo define maximum number of fastlanes
|
||||
if (($high_waiting > 0) AND ($high_running == 0)) {
|
||||
logger("There are ".$high_waiting." high priority jobs waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
|
||||
$queues = $active + 1;
|
||||
}
|
||||
}
|
||||
|
||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
|
||||
$entries = $s[0]["total"];
|
||||
|
||||
logger("Current load: ".$load." - maximum: ".$maxsysload." - current queues: ".$active."/".$entries." - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
|
||||
|
||||
// Are there fewer workers running as possible? Then fork a new one.
|
||||
if (!get_config("system", "worker_dont_fork") AND ($queues > ($active + 1)) AND ($entries > 1)) {
|
||||
logger("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG);
|
||||
$args = array("php", "include/poller.php", "no_cron");
|
||||
$a = get_app();
|
||||
$a->proc_run($args);
|
||||
}
|
||||
}
|
||||
|
||||
return($active >= $queues);
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ function queue_run(&$argv, &$argc){
|
||||
logger('queue: start');
|
||||
|
||||
// Handling the pubsubhubbub requests
|
||||
proc_run('php','include/pubsubpublish.php');
|
||||
proc_run(PRIORITY_HIGH,'include/pubsubpublish.php');
|
||||
|
||||
$interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
|
||||
|
||||
@@ -60,7 +60,7 @@ function queue_run(&$argv, &$argc){
|
||||
if($r) {
|
||||
foreach($r as $rr) {
|
||||
logger('queue: deliverq');
|
||||
proc_run('php','include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
|
||||
proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
|
||||
if($interval)
|
||||
@time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
|
||||
@@ -1507,7 +1507,7 @@ function get_gcontact_id($contact) {
|
||||
|
||||
if ($doprobing) {
|
||||
logger("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG);
|
||||
proc_run('php', 'include/gprobe.php', bin2hex($contact["url"]));
|
||||
proc_run(PRIORITY_LOW, 'include/gprobe.php', bin2hex($contact["url"]));
|
||||
}
|
||||
|
||||
if ((count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != ""))
|
||||
|
||||
+15
-6
@@ -872,7 +872,8 @@ function contact_block() {
|
||||
$micropro = Null;
|
||||
|
||||
} else {
|
||||
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact`
|
||||
// Splitting the query in two parts makes it much faster
|
||||
$r = q("SELECT `id` FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending`
|
||||
AND NOT `hidden` AND NOT `archive`
|
||||
AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d",
|
||||
@@ -882,11 +883,19 @@ function contact_block() {
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
intval($shown)
|
||||
);
|
||||
if(count($r)) {
|
||||
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
|
||||
$micropro = Array();
|
||||
foreach($r as $rr) {
|
||||
$micropro[] = micropro($rr,true,'mpfriend');
|
||||
if ($r) {
|
||||
$contacts = "";
|
||||
foreach ($r AS $contact)
|
||||
$contacts[] = $contact["id"];
|
||||
|
||||
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
|
||||
dbesc(implode(",", $contacts)));
|
||||
if(count($r)) {
|
||||
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
|
||||
$micropro = Array();
|
||||
foreach($r as $rr) {
|
||||
$micropro[] = micropro($rr,true,'mpfriend');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -287,7 +287,7 @@ function import_account(&$a, $file) {
|
||||
}
|
||||
|
||||
// send relocate messages
|
||||
proc_run('php', 'include/notifier.php', 'relocate', $newuid);
|
||||
proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid);
|
||||
|
||||
info(t("Done. You can now login with your username and password"));
|
||||
goaway($a->get_baseurl() . "/login");
|
||||
|
||||
+30
-11
@@ -27,8 +27,11 @@ class xml {
|
||||
foreach ($namespaces AS $nskey => $nsvalue)
|
||||
$key .= " xmlns".($nskey == "" ? "":":").$nskey.'="'.$nsvalue.'"';
|
||||
|
||||
$root = new SimpleXMLElement("<".$key."/>");
|
||||
self::from_array($value, $root, $remove_header, $namespaces, false);
|
||||
if (is_array($value)) {
|
||||
$root = new SimpleXMLElement("<".$key."/>");
|
||||
self::from_array($value, $root, $remove_header, $namespaces, false);
|
||||
} else
|
||||
$root = new SimpleXMLElement("<".$key.">".xmlify($value)."</".$key.">");
|
||||
|
||||
$dom = dom_import_simplexml($root)->ownerDocument;
|
||||
$dom->formatOutput = true;
|
||||
@@ -44,6 +47,20 @@ class xml {
|
||||
}
|
||||
|
||||
foreach($array as $key => $value) {
|
||||
if (!isset($element) AND isset($xml))
|
||||
$element = $xml;
|
||||
|
||||
if (is_integer($key)) {
|
||||
if (isset($element)) {
|
||||
if (is_scalar($value)) {
|
||||
$element[0] = $value;
|
||||
} else {
|
||||
/// @todo: handle nested array values
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (substr($key, 0, 11) == "@attributes") {
|
||||
if (!isset($element) OR !is_array($value))
|
||||
continue;
|
||||
@@ -55,7 +72,7 @@ class xml {
|
||||
else
|
||||
$namespace = NULL;
|
||||
|
||||
$element->addAttribute ($attr_key, $attr_value, $namespace);
|
||||
$element->addAttribute($attr_key, $attr_value, $namespace);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -64,6 +81,8 @@ class xml {
|
||||
$element_parts = explode(":", $key);
|
||||
if ((count($element_parts) > 1) AND isset($namespaces[$element_parts[0]]))
|
||||
$namespace = $namespaces[$element_parts[0]];
|
||||
elseif (isset($namespaces[""]))
|
||||
$namespace = $namespaces[""];
|
||||
else
|
||||
$namespace = NULL;
|
||||
|
||||
@@ -131,11 +150,11 @@ class xml {
|
||||
/**
|
||||
* @brief Convert an XML document to a normalised, case-corrected array
|
||||
* used by webfinger
|
||||
*
|
||||
*
|
||||
* @param object $xml_element The XML document
|
||||
* @param integer $recursion_depth recursion counter for internal use - default 0
|
||||
* @param integer $recursion_depth recursion counter for internal use - default 0
|
||||
* internal use, recursion counter
|
||||
*
|
||||
*
|
||||
* @return array | sring The array from the xml element or the string
|
||||
*/
|
||||
public static function element_to_array($xml_element, &$recursion_depth=0) {
|
||||
@@ -181,23 +200,23 @@ class xml {
|
||||
|
||||
/**
|
||||
* @brief Convert the given XML text to an array in the XML structure.
|
||||
*
|
||||
*
|
||||
* xml::to_array() will convert the given XML text to an array in the XML structure.
|
||||
* Link: http://www.bin-co.com/php/scripts/xml2array/
|
||||
* Portions significantly re-written by mike@macgirvin.com for Friendica
|
||||
* (namespaces, lowercase tags, get_attribute default changed, more...)
|
||||
*
|
||||
*
|
||||
* Examples: $array = xml::to_array(file_get_contents('feed.xml'));
|
||||
* $array = xml::to_array(file_get_contents('feed.xml', true, 1, 'attribute'));
|
||||
*
|
||||
*
|
||||
* @param object $contents The XML text
|
||||
* @param boolean $namespaces True or false include namespace information
|
||||
* in the returned array as array elements.
|
||||
* @param integer $get_attributes 1 or 0. If this is 1 the function will get the attributes as well as the tag values -
|
||||
* @param integer $get_attributes 1 or 0. If this is 1 the function will get the attributes as well as the tag values -
|
||||
* this results in a different array structure in the return value.
|
||||
* @param string $priority Can be 'tag' or 'attribute'. This will change the way the resulting
|
||||
* array sturcture. For 'tag', the tags are given more importance.
|
||||
*
|
||||
*
|
||||
* @return array The parsed XML in an array form. Use print_r() to see the resulting array structure.
|
||||
*/
|
||||
public static function to_array($contents, $namespaces = true, $get_attributes=1, $priority = 'attribute') {
|
||||
|
||||
Reference in New Issue
Block a user