]> git.mxchange.org Git - friendica.git/blobdiff - include/onepoll.php
Merge pull request #2112 from rabuzarus/2811_group_side
[friendica.git] / include / onepoll.php
index 90d018524d13aae89bf653dc3cdfb81b9a3f04f2..6ff7eae422e35063b1746d334cccc836a8fbeb76 100644 (file)
@@ -18,10 +18,10 @@ function onepoll_run(&$argv, &$argc){
        }
 
        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);
+               @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);
        };
 
 
@@ -53,6 +53,9 @@ function onepoll_run(&$argv, &$argc){
        if(($argc > 1) && (intval($argv[1])))
                $contact_id = intval($argv[1]);
 
+       if(($argc > 2) && ($argv[2] == "force"))
+               $force = true;
+
        if(! $contact_id) {
                logger('onepoll: no contact');
                return;
@@ -165,8 +168,18 @@ function onepoll_run(&$argv, &$argc){
        );
 
        // Update the contact entry
-       if(($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN))
-               update_contact($contact["id"]);
+       if(($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
+               if (!poco_reachable($contact['url'])) {
+                       logger("Skipping probably dead contact ".$contact['url']);
+                       return;
+               }
+
+               if (!update_contact($contact["id"])) {
+                       mark_for_death($contact);
+                       return;
+               } else
+                       unmark_for_death($contact);
+       }
 
        if($contact['network'] === NETWORK_DFRN) {
 
@@ -357,7 +370,7 @@ function onepoll_run(&$argv, &$argc){
                                );
                                logger("Mail: Connected to " . $mailconf[0]['user']);
                        } else
-                               logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors()));
+                               logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors(), true));
                }
                if($mbox) {
 
@@ -595,8 +608,10 @@ function onepoll_run(&$argv, &$argc){
                        return;
                }
 
-               consume_feed($xml,$importer,$contact,$hub,1,1);
 
+               logger("Consume feed of contact ".$contact['id']);
+
+               consume_feed($xml,$importer,$contact,$hub,1,1);
 
                // do it twice. Ensures that children of parents which may be later in the stream aren't tossed
 
@@ -609,6 +624,11 @@ function onepoll_run(&$argv, &$argc){
                if(($contact['network'] === NETWORK_OSTATUS ||  $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify']))
                        $hub_update = true;
 
+               if ($force)
+                       $hub_update = true;
+
+               logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
+
                if((strlen($hub)) && ($hub_update) && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED) ) {
                        logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
                        $hubs = explode(',', $hub);
@@ -659,6 +679,6 @@ function onepoll_run(&$argv, &$argc){
 }
 
 if (array_search(__file__,get_included_files())===0){
-  onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
+       onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
+       killme();
 }