]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorRoland Haeder <roland@mxchange.org>
Sun, 24 Jan 2016 15:13:11 +0000 (16:13 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 24 Jan 2016 15:13:11 +0000 (16:13 +0100)
1  2 
lib/default.php
lib/installer.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/OStatus/lib/ostatusqueuehandler.php
plugins/OpportunisticQM/lib/opportunisticqueuemanager.php

diff --combined lib/default.php
index 738f4de1e54a6b21f5e2863ea340ce0b51c5e61b,8d8ef1178810a98a8806b75d8969f03acafb3f5d..b19d3e4580d25765f371884caff38e242cb8e476
@@@ -133,7 -133,7 +133,7 @@@ $default 
                'delete' => false,
                'move' => true),
          'image' =>
 -        array('jpegquality' => 85),
 +        array('jpegquality' => 95),
          'avatar' =>
          array('server' => null,
                'dir' => INSTALLDIR . '/avatar/',
          array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt') (this activates "ssl_verify_peer")
                'ssl_verify_host' => true,    // HTTPRequest2 makes sure this is set to CURLOPT_SSL_VERIFYHOST==2 if using curl
                'curl' => false, // Use CURL backend for HTTP fetches if available. (If not, PHP's socket streams will be used.)
+               'connect_timeout' => 5,
                'proxy_host' => null,
                'proxy_port' => null,
                'proxy_user' => null,
diff --combined lib/installer.php
index 36f83a3ead5e723342022b2647d5ce8827e80c7e,650845f0f06712b16958fca6c865dd3eba3650fe..ff7677dc7d86ba03ef06499d1946c7c5adddd5c0
@@@ -299,10 -299,7 +299,10 @@@ abstract class Installe
              }
          }
  
 -        if (!$conn instanceof DB_common) {
 +        if (!is_object($conn)) {
 +            // No object at all
 +            throw new Exception('Fatal error: conn is no object.');
 +        } elseif (!$conn instanceof DB_common) {
              // Is not the right instance
              throw new Exception('Cannot connect to database: ' . $conn->getMessage());
          }
              $data['email'] = $this->adminEmail;
          }
          try {
-             $user = User::register($data);
+             $user = User::register($data, true);    // true to skip email sending verification
          } catch (Exception $e) {
              return false;
          }
index 9d41b6727341d41eaa31949f574bd1b2c6cd47c4,a8269bdf0728594687656769ec2ef4e12e719446..07432d78fa1c4d65a3134973bcc948ec7a84e38c
@@@ -371,20 -371,24 +371,25 @@@ class Ostatus_profile extends Managed_D
       * send immediately but won't get the return value.
       *
       * @param mixed $entry XML string, Notice, or Activity
 +     * @param Profile $actor Acting profile
       * @return boolean success
       */
 -    public function notifyDeferred($entry, $actor)
 +    public function notifyDeferred($entry, Profile $actor)
      {
          if ($this->salmonuri) {
-             common_debug("OSTATUS: user {$actor->getNickname()} ({$actor->getID()}) wants to ping {$this->localProfile()->getNickname()} on {$this->salmonuri}");
-             $data = array('salmonuri' => $this->salmonuri,
-                           'entry' => $this->notifyPrepXml($entry),
-                           'actor' => $actor->getID(),
-                           'target' => $this->localProfile()->getID());
-             $qm = QueueManager::get();
-             return $qm->enqueue($data, 'salmon');
+             try {
+                 common_debug("OSTATUS: user {$actor->getNickname()} ({$actor->getID()}) wants to ping {$this->localProfile()->getNickname()} on {$this->salmonuri}");
+                 $data = array('salmonuri' => $this->salmonuri,
+                               'entry' => $this->notifyPrepXml($entry),
+                               'actor' => $actor->getID(),
+                               'target' => $this->localProfile()->getID());
+                 $qm = QueueManager::get();
+                 return $qm->enqueue($data, 'salmon');
+             } catch (Exception $e) {
+                 common_log(LOG_ERR, 'OSTATUS: Something went wrong when creating a Salmon slap: '._ve($e->getMessage()));
+                 return false;
+             }
          }
  
          return false;
       * @param string $method 'push' or 'salmon'
       * @return mixed saved Notice or false
       */
 -    public function processPost($activity, $method)
 +    public function processPost(Activity $activity, $method)
      {
          $actor = ActivityUtils::checkAuthorship($activity, $this->localProfile());
  
       */
      static public function filterAttention(Profile $sender, array $attention)
      {
 -        common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', array_keys($attention)));
 +        common_debug("Original reply recipients: " . implode(', ', array_keys($attention)));
          $groups = array();
          $replies = array();
          foreach ($attention as $recipient=>$type) {
                      if ($sender->isMember($group)) {
                          $groups[] = $group->id;
                      } else {
 -                        common_log(LOG_DEBUG, sprintf('Skipping reply to local group %s as sender %d is not a member', $group->getNickname(), $sender->id));
 +                        common_debug(sprintf('Skipping reply to local group %s as sender %d is not a member', $group->getNickname(), $sender->id));
                      }
                      continue;
                  } else {
 -                    common_log(LOG_DEBUG, "Skipping reply to bogus group $recipient");
 +                    common_debug("Skipping reply to bogus group $recipient");
                  }
              }
  
                  continue;
              } catch (Exception $e) {
                  // Neither a recognizable local nor remote user!
 -                common_log(LOG_DEBUG, "Skipping reply to unrecognized profile $recipient: " . $e->getMessage());
 +                common_debug("Skipping reply to unrecognized profile $recipient: " . $e->getMessage());
              }
  
          }
 -        common_log(LOG_DEBUG, "Local reply recipients: " . implode(', ', $replies));
 -        common_log(LOG_DEBUG, "Local group recipients: " . implode(', ', $groups));
 +        common_debug("Local reply recipients: " . implode(', ', $replies));
 +        common_debug("Local group recipients: " . implode(', ', $groups));
          return array($groups, $replies);
      }
  
  
          // @todo FIXME: This should be better encapsulated
          // ripped from oauthstore.php (for old OMB client)
 -        $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
 +        $temp_filename = tempnam(common_get_temp_dir(), 'listener_avatar');
          try {
              $imgData = HTTPClient::quickGet($url);
              // Make sure it's at least an image file. ImageFile can do the rest.
          $discover = false;
  
          if (!$homeuri) {
 -            common_log(LOG_DEBUG, __METHOD__ . " empty actor profile URI: " . var_export($activity, true));
 +            common_debug(__METHOD__ . " empty actor profile URI: " . var_export($activity, true));
              // TRANS: Exception.
              throw new Exception(_m('No profile URI.'));
          }
          // @todo tags from categories
  
          if ($profile->id) {
 -            common_log(LOG_DEBUG, "Updating OStatus profile $profile->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
 +            common_debug("Updating OStatus profile $profile->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
              $profile->update($orig);
          }
      }
          $group->homepage = self::getActivityObjectHomepage($object, $hints);
  
          if ($group->id) {   // If no id, we haven't called insert() yet, so don't run update()
 -            common_log(LOG_DEBUG, "Updating OStatus group $group->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
 +            common_debug("Updating OStatus group $group->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
              $group->update($orig);
          }
      }
  
 -    protected static function updatePeopletag($tag, ActivityObject $object, array $hints=array()) {
 +    protected static function updatePeopletag(Peopletag $tag, ActivityObject $object, array $hints=array()) {
          $orig = clone($tag);
  
          $tag->tag = $object->title;
          $tag->tagger = $tagger->profile_id;
  
          if ($tag->id) {
 -            common_log(LOG_DEBUG, "Updating OStatus peopletag $tag->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
 +            common_debug("Updating OStatus peopletag $tag->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
              $tag->update($orig);
          }
      }
          } else {
              $actor = $activity->actor;
  
 -            if (empty($actor)) {
 +            if (!$actor instanceof Profile) {
                  // OK here! assume the default
              } else if ($actor->id == $this->getUri() || $actor->link == $this->getUri()) {
                  $this->updateFromActivityObject($actor);
index 2914f933552d7196b844635b36aca209a09e0fe6,fed93b6ea62b69200c7c0303ae92ec02cc4758d9..a4d9e527e2afed5459ba8120277f4e7b0b77298d
@@@ -174,7 -174,7 +174,7 @@@ class OStatusQueueHandler extends Queue
              // remote user or group.
              // @fixme as an optimization we can skip this if the
              // remote profile is subscribed to the author.
 -            $oprofile->notifyDeferred($this->notice, $this->user);
 +            $oprofile->notifyDeferred($this->notice, $this->user->getProfile());
          }
      }
  
                  }
              }
          }
-         if (count($batch) >= 0) {
+         if (count($batch) > 0) {
              $sub->bulkDistribute($atom, $batch);
          }
      }
index c0339f958b5e4a2bdcf7b751ecd53f66612c2b62,2834b9a0ee849af228922d4dc65beb5546e50432..db1404ba6c4168b101d6610fbee479aeffd2604b
@@@ -18,7 -18,7 +18,7 @@@ class OpportunisticQueueManager extend
  {
      protected $qmkey = false;
      protected $max_execution_time = null;
-     protected $max_execution_margin = null; // margin to execution time, including timeouts etc.
+     protected $max_execution_margin = null; // margin to PHP's max_execution_time
      protected $max_queue_items = null;
  
      protected $started_at = null;
@@@ -43,7 -43,7 +43,7 @@@
          }
  
          if ($this->max_execution_margin === null) {
-             $this->max_execution_margin = 10;    // should be calculated from our default timeouts for http requests etc.
+             $this->max_execution_margin = common_config('http', 'connect_timeout') + 1;   // think PHP's max exec time, minus this value to have time for timeouts etc.
          }
  
          return parent::__construct();
@@@ -65,7 -65,7 +65,7 @@@
              return false;
          }
          // If too much time has passed, stop
-         if ($time_passed >= $this->max_execution_time - $this->max_execution_margin) {
+         if ($time_passed >= $this->max_execution_time || $time_passed > ini_get('max_execution_time') - $this->max_execution_margin) {
              return false;
          }
          // If we have a max-item-limit, check if it has been passed
              try {
                  $this->poll();
              } catch (RunQueueOutOfWorkException $e) {
 +                common_debug('Opportunistic queue manager finished: ' . $e->getMessage());
                  return true;
              }
          }