]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/OnePoll.php
Just some more fixed notice
[friendica.git] / src / Worker / OnePoll.php
index eaef5f252d4404a01217a7618abe3f64e924a498..8d2e6f2b0b1b5b43ca2c880bbb7b78ada342aa0e 100644 (file)
@@ -4,9 +4,11 @@
  */
 namespace Friendica\Worker;
 
+use Friendica\BaseObject;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
+use Friendica\Database\dba;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
@@ -15,14 +17,14 @@ use Friendica\Protocol\PortableContact;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\XML;
-use dba;
 
 require_once 'include/dba.php';
 
 class OnePoll
 {
-       public static function execute($contact_id = 0, $command = '') {
-               global $a;
+       public static function execute($contact_id = 0, $command = '')
+       {
+               $a = BaseObject::getApp();
 
                require_once 'include/items.php';
 
@@ -183,7 +185,7 @@ class OnePoll
 
                        $ret = Network::curl($url);
 
-                       if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
+                       if (!$ret["success"] && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
                                // set the last-update so we don't keep polling
                                dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
                                Contact::markForArchival($contact);
@@ -319,7 +321,7 @@ class OnePoll
                        $ret = Network::curl($contact['poll'], false, $redirects, ['cookiejar' => $cookiejar]);
                        unlink($cookiejar);
 
-                       if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
+                       if (!$ret["success"] && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
                                // set the last-update so we don't keep polling
                                dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
                                Contact::markForArchival($contact);
@@ -634,7 +636,8 @@ class OnePoll
                return;
        }
 
-       private static function RemoveReply($subject) {
+       private static function RemoveReply($subject)
+       {
                while (in_array(strtolower(substr($subject, 0, 3)), ["re:", "aw:"])) {
                        $subject = trim(substr($subject, 4));
                }
@@ -648,7 +651,8 @@ class OnePoll
         * @param array $contact The personal contact entry
         * @param array $fields The fields that are updated
         */
-       private static function updateContact($contact, $fields) {
+       private static function updateContact($contact, $fields)
+       {
                dba::update('contact', $fields, ['id' => $contact['id']]);
                dba::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
        }