]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/OnePoll.php
Hotfix missing use dba
[friendica.git] / src / Worker / OnePoll.php
index 41cbffc2e37875f805bc3fe3b5ba0295b1f81347..356fce4337ff2a708c0c28185a0051b8cae39f4c 100644 (file)
@@ -1,22 +1,26 @@
 <?php
+/**
+ * @file src/Worker/OnePoll.php
+ */
 namespace Friendica\Worker;
 
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
+use Friendica\Object\Contact;
+use Friendica\Protocol\PortableContact;
 use dba;
 
 require_once 'include/follow.php';
 
-Class OnePoll {
+Class OnePoll
+{
        public static function execute($contact_id = 0, $command = '') {
                global $a;
 
                require_once 'include/datetime.php';
                require_once 'include/items.php';
-               require_once 'include/Contact.php';
                require_once 'include/email.php';
-               require_once 'include/socgraph.php';
                require_once 'include/queue_fn.php';
 
                logger('onepoll: start');
@@ -72,7 +76,7 @@ Class OnePoll {
                        );
                        if (DBM::is_result($r)) {
                                if (!$r[0]['total']) {
-                                       poco_load($contact['id'], $importer_uid, 0, $contact['poco']);
+                                       PortableContact::loadWorker($contact['id'], $importer_uid, 0, $contact['poco']);
                                }
                        }
                }
@@ -80,8 +84,8 @@ Class OnePoll {
                /// @TODO Check why we don't poll the Diaspora feed at the moment (some guid problem in the items?)
                /// @TODO Check whether this is possible with Redmatrix
                if ($contact["network"] == NETWORK_DIASPORA) {
-                       if (poco_do_update($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
-                               $last_updated = poco_last_updated($contact["url"]);
+                       if (PortableContact::updateNeeded($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
+                               $last_updated = PortableContact::lastUpdated($contact["url"]);
                                $updated = datetime_convert();
                                if ($last_updated) {
                                        $fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
@@ -116,17 +120,17 @@ Class OnePoll {
 
                // Update the contact entry
                if (($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
-                       if (!poco_reachable($contact['url'])) {
+                       if (!PortableContact::reachable($contact['url'])) {
                                logger("Skipping probably dead contact ".$contact['url']);
                                return;
                        }
 
                        if (!update_contact($contact["id"])) {
-                               mark_for_death($contact);
+                               Contact::markForArchival($contact);
                                logger('Contact is marked dead');
                                return;
                        } else {
-                               unmark_for_death($contact);
+                               Contact::unmarkForArchival($contact);
                        }
                }
 
@@ -186,13 +190,13 @@ Class OnePoll {
 
 
                        if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) {
-                               logger("poller: $url appears to be dead - marking for death ");
+                               logger("$url appears to be dead - marking for death ");
 
                                // dead connection - might be a transient event, or this might
                                // mean the software was uninstalled or the domain expired.
                                // Will keep trying for one month.
 
-                               mark_for_death($contact);
+                               Contact::markForArchival($contact);
 
                                // set the last-update so we don't keep polling
                                $fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
@@ -202,9 +206,9 @@ Class OnePoll {
                        }
 
                        if (!strstr($handshake_xml, '<')) {
-                               logger('poller: response from ' . $url . ' did not contain XML.');
+                               logger('response from ' . $url . ' did not contain XML.');
 
-                               mark_for_death($contact);
+                               Contact::markForArchival($contact);
 
                                $fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
                                dba::update('contact', $fields, array('id' => $contact['id']));
@@ -216,17 +220,17 @@ Class OnePoll {
                        $res = parse_xml_string($handshake_xml);
 
                        if (intval($res->status) == 1) {
-                               logger("poller: $url replied status 1 - marking for death ");
+                               logger("$url replied status 1 - marking for death ");
 
                                // we may not be friends anymore. Will keep trying for one month.
                                // set the last-update so we don't keep polling
                                $fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
                                dba::update('contact', $fields, array('id' => $contact['id']));
 
-                               mark_for_death($contact);
+                               Contact::markForArchival($contact);
                        } elseif ($contact['term-date'] > NULL_DATE) {
-                               logger("poller: $url back from the dead - removing mark for death");
-                               unmark_for_death($contact);
+                               logger("$url back from the dead - removing mark for death");
+                               Contact::unmarkForArchival($contact);
                        }
 
                        if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
@@ -260,7 +264,7 @@ Class OnePoll {
                        }
 
                        if ($final_dfrn_id != $orig_id) {
-                               logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
+                               logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
                                // did not decode properly - cannot trust this site
                                return;
                        }
@@ -551,9 +555,9 @@ Class OnePoll {
                }
 
                if ($xml) {
-                       logger('poller: received xml : ' . $xml, LOGGER_DATA);
+                       logger('received xml : ' . $xml, LOGGER_DATA);
                        if (!strstr($xml, '<')) {
-                               logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
+                               logger('post_handshake: response from ' . $url . ' did not contain XML.');
 
                                $fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
                                dba::update('contact', $fields, array('id' => $contact['id']));
@@ -586,7 +590,7 @@ Class OnePoll {
                        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']);
+                               logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
                                $hubs = explode(',', $hub);
                                if (count($hubs)) {
                                        foreach ($hubs as $h) {