]> git.mxchange.org Git - friendica.git/blobdiff - include/pubsubpublish.php
Degrade priority step by step
[friendica.git] / include / pubsubpublish.php
index 3641bbcf74fc3d16f98ed67b13a687119e31739a..580e3ffce18038f8b86f521f28acdf2d54a80aaf 100644 (file)
@@ -1,10 +1,13 @@
 <?php
-use \Friendica\Core\Config;
+
+use Friendica\App;
+use Friendica\Core\Config;
 
 require_once('include/items.php');
 require_once('include/ostatus.php');
 
 function pubsubpublish_run(&$argv, &$argc){
+       global $a;
 
        if ($argc > 1) {
                $pubsubpublish_id = intval($argv[1]);
@@ -15,7 +18,8 @@ function pubsubpublish_run(&$argv, &$argc){
 
                foreach ($r as $rr) {
                        logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
-                       proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
+                       proc_run(array('priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true),
+                                       'include/pubsubpublish.php', (int)$rr["id"]);
                }
        }
 
@@ -28,10 +32,14 @@ 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];
+       }
+
+       $rr = $r[0];
+
+       /// @todo Check server status with poco_check_server()
+       // Before this can be done we need a way to safely detect the server url.
 
        logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);