diff --git a/boot.php b/boot.php index cad4094c7d..1e59ba3b54 100644 --- a/boot.php +++ b/boot.php @@ -386,6 +386,17 @@ define ( 'GRAVITY_LIKE', 3); define ( 'GRAVITY_COMMENT', 6); /* @}*/ +/** + * @name Priority + * + * Process priority for the worker + * @{ + */ +define('PRIORITY_HIGH', 1); +define('PRIORITY_MEDIUM', 2); +define('PRIORITY_LOW', 3); +/* @}*/ + // Normally this constant is defined - but not if "pcntl" isn't installed if (!defined("SIGTERM")) @@ -1241,13 +1252,34 @@ class App { logger("killed stale process"); // Calling a new instance if ($task != "") - proc_run('php', $task); + proc_run(PRIORITY_MEDIUM, $task); } return true; } } return false; } + + function proc_run($args) { + + // Add the php path if it is a php call + if (count($args) && $args[0] === 'php') + $args[0] = ((x($this->config,'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'); + + // add baseurl to args. cli scripts can't construct it + $args[] = $this->get_baseurl(); + + for($x = 0; $x < count($args); $x ++) + $args[$x] = escapeshellarg($args[$x]); + + $cmdline = implode($args," "); + + if(get_config('system','proc_windows')) + proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo,dirname(__FILE__))); + else + proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__))); + + } } /** @@ -1363,7 +1395,7 @@ function check_db() { $build = DB_UPDATE_VERSION; } if($build != DB_UPDATE_VERSION) - proc_run('php', 'include/dbupdate.php'); + proc_run(PRIORITY_HIGH, 'include/dbupdate.php'); } @@ -1736,10 +1768,11 @@ function get_max_import_size() { * @brief Wrap calls to proc_close(proc_open()) and call hook * so plugins can take part in process :) * - * @param string $cmd program to run + * @param (string|integer) $cmd program to run or priority * * next args are passed as $cmd command line * e.g.: proc_run("ls","-la","/tmp"); + * or: proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); * * @note $cmd and string args are surrounded with "" * @@ -1753,7 +1786,7 @@ function proc_run($cmd){ $args = func_get_args(); $newargs = array(); - if(! count($args)) + if (!count($args)) return; // expand any arrays @@ -1763,8 +1796,7 @@ function proc_run($cmd){ foreach($arg as $n) { $newargs[] = $n; } - } - else + } else $newargs[] = $arg; } @@ -1773,81 +1805,55 @@ function proc_run($cmd){ $arr = array('args' => $args, 'run_cmd' => true); call_hooks("proc_run", $arr); - if(! $arr['run_cmd']) + if (!$arr['run_cmd'] OR !count($args)) return; - if(count($args) && $args[0] === 'php') { - - if (get_config("system", "worker")) { - $argv = $args; - array_shift($argv); - - $parameters = json_encode($argv); - $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'", - dbesc($parameters)); - - $funcname = str_replace(".php", "", basename($argv[0]))."_run"; - - // Define the processes that have priority over any other process - /// @todo Better check for priority processes - $high_priority = array("delivery_run", "notifier_run", "pubsubpublish_run"); - $low_priority = array("queue_run", "gprobe_run", "discover_poco_run"); - - if (in_array($funcname, $high_priority)) - $priority = 1; - elseif (in_array($funcname, $low_priority)) - $priority = 3; - else - $priority = 2; - - if (!$found) - // quickfix for the delivery problems, 2106-07-28 - /// @todo find better solution - //q("INSERT INTO `workerqueue` (`function`, `parameter`, `created`, `priority`) - // VALUES ('%s', '%s', '%s', %d)", - // dbesc($funcname), - q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`) - VALUES ('%s', '%s', %d)", - dbesc($parameters), - dbesc(datetime_convert()), - intval($priority)); - - // Should we quit and wait for the poller to be called as a cronjob? - if (get_config("system", "worker_dont_fork")) - return; - - // Checking number of workers - $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); - - // Get number of allowed number of worker threads - $queues = intval(get_config("system", "worker_queues")); - - if ($queues == 0) - $queues = 4; - - // If there are already enough workers running, don't fork another one - if ($workers[0]["workers"] >= $queues) - return; - - // Now call the poller to execute the jobs that we just added to the queue - $args = array("php", "include/poller.php", "no_cron"); - } - - $args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); + if (!get_config("system", "worker") OR + (($args[0] != 'php') AND !is_int($args[0]))) { + $a->proc_run($args); + return; } - // add baseurl to args. cli scripts can't construct it - $args[] = $a->get_baseurl(); - - for($x = 0; $x < count($args); $x ++) - $args[$x] = escapeshellarg($args[$x]); - - $cmdline = implode($args," "); - - if(get_config('system','proc_windows')) - proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo,dirname(__FILE__))); + if (is_int($args[0])) + $priority = $args[0]; else - proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__))); + $priority = PRIORITY_MEDIUM; + + $argv = $args; + array_shift($argv); + + $parameters = json_encode($argv); + $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'", + dbesc($parameters)); + + if (!$found) + q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`) + VALUES ('%s', '%s', %d)", + dbesc($parameters), + dbesc(datetime_convert()), + intval($priority)); + + // Should we quit and wait for the poller to be called as a cronjob? + if (get_config("system", "worker_dont_fork")) + return; + + // Checking number of workers + $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); + + // Get number of allowed number of worker threads + $queues = intval(get_config("system", "worker_queues")); + + if ($queues == 0) + $queues = 4; + + // If there are already enough workers running, don't fork another one + if ($workers[0]["workers"] >= $queues) + return; + + // Now call the poller to execute the jobs that we just added to the queue + $args = array("php", "include/poller.php", "no_cron"); + + $a->proc_run($args); } function current_theme(){ diff --git a/include/Contact.php b/include/Contact.php index 10005d3e3c..e466d7f908 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -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)) { diff --git a/include/cron.php b/include/cron.php index c1e4338d6f..c54fef8a9c 100644 --- a/include/cron.php +++ b/include/cron.php @@ -70,15 +70,15 @@ 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 @@ -126,11 +126,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 @@ -272,7 +272,7 @@ function cron_run(&$argv, &$argc){ 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); diff --git a/include/follow.php b/include/follow.php index 2461bf0356..08e74e02f3 100644 --- a/include/follow.php +++ b/include/follow.php @@ -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 diff --git a/include/identity.php b/include/identity.php index 4dffe72559..9b75ebccdb 100644 --- a/include/identity.php +++ b/include/identity.php @@ -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); } diff --git a/include/items.php b/include/items.php index 1d2a775c49..754d5b0882 100644 --- a/include/items.php +++ b/include/items.php @@ -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; diff --git a/include/like.php b/include/like.php index 9ceff2303a..118ec81ca1 100644 --- a/include/like.php +++ b/include/like.php @@ -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; } diff --git a/include/message.php b/include/message.php index 0f4b53c626..51f3ad805a 100644 --- a/include/message.php +++ b/include/message.php @@ -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; diff --git a/include/notifier.php b/include/notifier.php index 446824a26a..cfe4e18412 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -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); diff --git a/include/poller.php b/include/poller.php index ec6653b488..b54757b00b 100644 --- a/include/poller.php +++ b/include/poller.php @@ -275,6 +275,13 @@ function poller_too_much_workers() { 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); diff --git a/include/queue.php b/include/queue.php index 878c149731..9779a0733d 100644 --- a/include/queue.php +++ b/include/queue.php @@ -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); } diff --git a/include/socgraph.php b/include/socgraph.php index cb2fd97b39..89897aaa7c 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -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"] != "")) diff --git a/include/uimport.php b/include/uimport.php index bd271e91a8..937a16710a 100644 --- a/include/uimport.php +++ b/include/uimport.php @@ -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"); diff --git a/mod/admin.php b/mod/admin.php index 547c37fb6c..d49673fc0f 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -549,7 +549,7 @@ function admin_page_site_post(&$a) { $users = q("SELECT `uid` FROM `user` WHERE `account_removed` = 0 AND `account_expired` = 0"); foreach ($users as $user) { - proc_run('php', 'include/notifier.php', 'relocate', $user['uid']); + proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $user['uid']); } info("Relocation started. Could take a while to complete."); diff --git a/mod/contacts.php b/mod/contacts.php index f9e9f6b735..ba8ad45c39 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -237,7 +237,7 @@ function _contact_update($contact_id) { intval($contact_id)); } else // 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"); } function _contact_update_profile($contact_id) { diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 25694a67f3..51cd59c62f 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -487,7 +487,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $i = item_store($arr); if($i) - proc_run('php',"include/notifier.php","activity","$i"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); } } } @@ -784,7 +784,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $i = item_store($arr); if($i) - proc_run('php',"include/notifier.php","activity","$i"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); } } diff --git a/mod/dirfind.php b/mod/dirfind.php index 0638fe14fa..52e1617554 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -156,7 +156,7 @@ function dirfind_content(&$a, $prefix = "") { } // Add found profiles from the global directory to the local directory - proc_run('php','include/discover_poco.php', "dirsearch", urlencode($search)); + proc_run(PRIORITY_LOW, 'include/discover_poco.php', "dirsearch", urlencode($search)); } else { $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); diff --git a/mod/events.php b/mod/events.php index 878bf841d2..636cf6c579 100644 --- a/mod/events.php +++ b/mod/events.php @@ -177,7 +177,7 @@ function events_post(&$a) { $item_id = event_store($datarray); if(! $cid) - proc_run('php',"include/notifier.php","event","$item_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id); goaway($_SESSION['return_url']); } diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 6b1cbd7533..ad407d5f32 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -57,7 +57,7 @@ function fsuggest_post(&$a) { intval($fsuggest_id), intval(local_user()) ); - proc_run('php', 'include/notifier.php', 'suggest' , $fsuggest_id); + proc_run(PRIORITY_HIGH, 'include/notifier.php', 'suggest', $fsuggest_id); } info( t('Friend suggestion sent.') . EOL); diff --git a/mod/item.php b/mod/item.php index 6f5f8fc1ea..9a9b5895bd 100644 --- a/mod/item.php +++ b/mod/item.php @@ -783,7 +783,7 @@ function item_post(&$a) { // update filetags in pconfig file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); - proc_run('php', "include/notifier.php", 'edit_post', "$post_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", 'edit_post', $post_id); if((x($_REQUEST,'return')) && strlen($return_path)) { logger('return: ' . $return_path); goaway($a->get_baseurl() . "/" . $return_path ); @@ -1032,7 +1032,7 @@ function item_post(&$a) { // Currently the only realistic fixes are to use a reliable server - which precludes shared hosting, // or cut back on plugins which do remote deliveries. - proc_run('php', "include/notifier.php", $notify_type, "$post_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $post_id); logger('post_complete'); diff --git a/mod/mood.php b/mod/mood.php index 5e6ca0fcfc..f804af0c00 100644 --- a/mod/mood.php +++ b/mod/mood.php @@ -95,13 +95,13 @@ function mood_init(&$a) { intval($uid), intval($item_id) ); - proc_run('php',"include/notifier.php","tag","$item_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id); } 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; } diff --git a/mod/photos.php b/mod/photos.php index 4ac4e1a0ee..ec71cc09d8 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -306,7 +306,7 @@ function photos_post(&$a) { // send the notification upstream/downstream as the case may be if($rr['visible']) - proc_run('php',"include/notifier.php","drop","$drop_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); } } } @@ -376,7 +376,7 @@ function photos_post(&$a) { $drop_id = intval($i[0]['id']); if($i[0]['visible']) - proc_run('php',"include/notifier.php","drop","$drop_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); } } @@ -719,7 +719,7 @@ function photos_post(&$a) { $item_id = item_store($arr); if($item_id) { - proc_run('php',"include/notifier.php","tag","$item_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id); } } @@ -935,7 +935,7 @@ function photos_post(&$a) { $item_id = item_store($arr); if($visible) - proc_run('php', "include/notifier.php", 'wall-new', $item_id); + proc_run(PRIORITY_HIGH, "include/notifier.php", 'wall-new', $item_id); call_hooks('photo_post_end',intval($item_id)); diff --git a/mod/poke.php b/mod/poke.php index 4a643435be..435da4dcd4 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -131,13 +131,13 @@ function poke_init(&$a) { // intval($uid), // intval($item_id) //); - proc_run('php',"include/notifier.php","tag","$item_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id); } 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; } diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 4e8d279a97..11e671afc5 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -125,7 +125,7 @@ function profile_photo_post(&$a) { // Update global directory in background $url = $a->get_baseurl() . '/profile/' . $a->user['nickname']; if($url && strlen(get_config('system','directory'))) - proc_run('php',"include/directory.php","$url"); + proc_run(PRIORITY_LOW, "include/directory.php", $url); require_once('include/profile_update.php'); profile_change(); @@ -224,7 +224,7 @@ function profile_photo_content(&$a) { // Update global directory in background $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory'))) - proc_run('php',"include/directory.php","$url"); + proc_run(PRIORITY_LOW, "include/directory.php", $url); goaway($a->get_baseurl() . '/profiles'); return; // NOTREACHED diff --git a/mod/profiles.php b/mod/profiles.php index c3bd068b0b..d770e75c3a 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -496,7 +496,7 @@ function profiles_post(&$a) { // Update global directory in background $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory'))) - proc_run('php',"include/directory.php","$url"); + proc_run(PRIORITY_LOW, "include/directory.php", $url); require_once('include/profile_update.php'); profile_change(); @@ -587,9 +587,8 @@ function profile_activity($changed, $value) { $arr['deny_gid'] = $a->user['deny_gid']; $i = item_store($arr); - if($i) { - proc_run('php',"include/notifier.php","activity","$i"); - } + if($i) + proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); } diff --git a/mod/register.php b/mod/register.php index 4c4fcc2af1..6fc5887ef5 100644 --- a/mod/register.php +++ b/mod/register.php @@ -64,7 +64,7 @@ function register_post(&$a) { if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) { $url = $a->get_baseurl() . '/profile/' . $user['nickname']; - proc_run('php',"include/directory.php","$url"); + proc_run(PRIORITY_LOW, "include/directory.php", $url); } $using_invites = get_config('system','invitation_only'); diff --git a/mod/regmod.php b/mod/regmod.php index 5a90db1f90..bbe733003a 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -37,7 +37,7 @@ function user_allow($hash) { if(count($r) && $r[0]['net-publish']) { $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; if($url && strlen(get_config('system','directory'))) - proc_run('php',"include/directory.php","$url"); + proc_run(PRIORITY_LOW, "include/directory.php", $url); } push_lang($register[0]['language']); diff --git a/mod/settings.php b/mod/settings.php index 89406b7072..e2d3f4d367 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -352,7 +352,7 @@ function settings_post(&$a) { check_form_security_token_redirectOnErr('/settings', 'settings'); if (x($_POST,'resend_relocate')) { - proc_run('php', 'include/notifier.php', 'relocate', local_user()); + proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', local_user()); info(t("Relocate message has been send to your contacts")); goaway('settings'); } @@ -614,7 +614,7 @@ function settings_post(&$a) { // Update global directory in background $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory'))) - proc_run('php',"include/directory.php","$url"); + proc_run(PRIORITY_LOW, "include/directory.php", $url); } require_once('include/profile_update.php'); diff --git a/mod/tagger.php b/mod/tagger.php index 26166a3cc0..e0ef1ceb02 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -211,7 +211,7 @@ EOT; call_hooks('post_local_end', $arr); - proc_run('php',"include/notifier.php","tag","$post_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $post_id); killme(); diff --git a/mod/videos.php b/mod/videos.php index bf8d696b60..e5a0887bb9 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -167,7 +167,7 @@ function videos_post(&$a) { $drop_id = intval($i[0]['id']); if($i[0]['visible']) - proc_run('php',"include/notifier.php","drop","$drop_id"); + proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); } } diff --git a/update.php b/update.php index 41f238e913..a150fe39fa 100644 --- a/update.php +++ b/update.php @@ -1595,7 +1595,7 @@ function update_1169() { if (!$r) return UPDATE_FAILED; - proc_run('php',"include/threadupdate.php"); + proc_run(PRIORITY_LOW, "include/threadupdate.php"); return UPDATE_SUCCESS; } @@ -1636,7 +1636,7 @@ function update_1178() { set_config('system','community_page_style', CP_NO_COMMUNITY_PAGE); // Update the central item storage with uid=0 - proc_run('php',"include/threadupdate.php"); + proc_run(PRIORITY_LOW, "include/threadupdate.php"); return UPDATE_SUCCESS; } @@ -1644,7 +1644,7 @@ function update_1178() { function update_1180() { // Fill the new fields in the term table. - proc_run('php',"include/tagupdate.php"); + proc_run(PRIORITY_LOW, "include/tagupdate.php"); return UPDATE_SUCCESS; }