From: Roland Haeder Date: Thu, 11 Feb 2016 13:31:04 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/master' into social-master X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fcbdf283f1009f30ebb3184f589431c4b6ab8ff6;p=quix0rs-gnu-social.git Merge remote-tracking branch 'upstream/master' into social-master There was an unneccessary cast to array which you don't need if you set it in the method's signature. Signed-off-by: Roland Haeder --- fcbdf283f1009f30ebb3184f589431c4b6ab8ff6 diff --cc actions/apimediaupload.php index 86742e07bd,38b3a6f4fe..0be9a188d6 --- a/actions/apimediaupload.php +++ b/actions/apimediaupload.php @@@ -42,17 -42,23 +42,23 @@@ class ApiMediaUploadAction extends ApiA { protected $needPost = true; - /** - * Handle the request - * - * Grab the file from the 'media' param, then store, and shorten - * - * @todo Upload throttle! - * @return void - */ + protected function prepare(array $args=array()) + { + parent::prepare($args); + + // fallback to xml for older clients etc + if (empty($this->format)) { + $this->format = 'xml'; + } + if (!in_array($this->format, ['json', 'xml'])) { + throw new ClientException('This API call does not support the format '._ve($this->format)); + } + return true; + } + protected function handle() { - parent::handle(); + parent::handle($args); // Workaround for PHP returning empty $_POST and $_FILES when POST // length > post_max_size in php.ini diff --cc actions/backupaccount.php index 4d7b6fcfcd,7f37f3b851..15bb4df8b7 --- a/actions/backupaccount.php +++ b/actions/backupaccount.php @@@ -128,29 -76,7 +76,7 @@@ class BackupaccountAction extends FormA $this->raw($stream->getString()); } - /** - * Show a little form so that the person can request a backup. - * - * @return void - */ - - function showContent() - { - $form = new BackupAccountForm($this); - $form->show(); - } - - /** - * Return true if read only. - * - * MAY override - * - * @param array $args other arguments - * - * @return boolean is read only action? - */ - function isReadOnly(array $args=array()) - { - public function isReadOnly($args) { ++ public function isReadOnly(array $args=array()) { return true; } diff --cc classes/File.php index 735655489b,6ba80eb5f6..dbd9a3bb44 --- a/classes/File.php +++ b/classes/File.php @@@ -423,10 -428,8 +428,11 @@@ class File extends Managed_DataObjec } } + // Debug log (convert crop to int to have TRUE being displayed as 1 and FALSE as 0) - /* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . ']: width=' . $width . ',height=' . $height . ',crop=' . intval($crop)); ++ /* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . ']: width=' . $width . ',height=' . $height . ',crop=' . intval($crop) . ',upscale=' . intval($upscale)); + - return $image->getFileThumbnail($width, $height, $crop); + return $image->getFileThumbnail($width, $height, $crop, + !is_null($upscale) ? $upscale : common_config('thumbnail', 'upscale')); } public function getPath() diff --cc lib/activityutils.php index 76e4777deb,b86dd65909..7376ff584b --- a/lib/activityutils.php +++ b/lib/activityutils.php @@@ -348,18 -348,18 +348,20 @@@ class ActivityUtil return null; } - static function compareTypes($type, $objects) + static function compareTypes($type, array $objects) { - $type = self::resolveUri($type); + $type = self::resolveUri($type, false); - foreach ((array)$objects as $object) { ++ + foreach ($objects as $object) { if ($type === self::resolveUri($object)) { return true; } } ++ return false; } -- static function compareVerbs($type, $objects) ++ static function compareVerbs($type, array $objects) { return self::compareTypes($type, $objects); } diff --cc lib/util.php index 322b8821ae,6a5c310193..23a169d006 --- a/lib/util.php +++ b/lib/util.php @@@ -1284,35 -1361,11 +1361,11 @@@ function common_local_url($action, $arg return $url; } - function common_is_sensitive($action) - { - static $sensitive = array( - 'login', - 'register', - 'passwordsettings', - 'api', - 'ApiOAuthRequestToken', - 'ApiOAuthAccessToken', - 'ApiOAuthAuthorize', - 'ApiOAuthPin', - 'showapplication' - ); - $ssl = null; - - if (Event::handle('SensitiveAction', array($action, &$ssl))) { - $ssl = in_array($action, $sensitive); - } - - return $ssl; - } - function common_path($relative, $ssl=false, $addSession=true) { - $pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : ''; + $pathpart = (!empty(common_config('site', 'path'))) ? common_config('site', 'path') . '/' : ''; - if (($ssl && (common_config('site', 'ssl') === 'sometimes')) - || GNUsocial::isHTTPS() - || common_config('site', 'ssl') === 'always') { + if ($ssl && GNUsocial::useHTTPS()) { $proto = 'https'; if (is_string(common_config('site', 'sslserver')) && mb_strlen(common_config('site', 'sslserver')) > 0) { @@@ -2455,34 -2514,7 +2514,39 @@@ function html_sprintf( return call_user_func_array('sprintf', $args); } +function common_location_shared() +{ + // Get default setting + $cfg = common_config('location', 'share'); + + if ($cfg == 'always') { + // Always enabled + return true; + } elseif ($cfg == 'never') { + // Never enabled + return false; + } + + // Is the user logged-in? + if (common_logged_in()) { + // Get current user + $user = common_current_user(); + + // Is it there? + if ($user instanceof User) { + // Yes, get profile + $profile = $user->getProfile(); + + // Get it from the profile + return $profile->shareLocation(); + } + } + + // User is not logged in, get default + return common_config('location', 'sharedefault'); +} ++ + function _ve($var) + { + return var_export($var, true); + } diff --cc plugins/Event/EventPlugin.php index a7d984fd83,82ba2c19cb..5d3f723c38 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@@ -364,9 -262,8 +262,8 @@@ class EventPlugin extends ActivityVerbH return true; } - function onStartAddNoticeReply($nli, $parent, $child) + function onStartAddNoticeReply(NoticeListItem $nli, Notice $parent, Notice $child) { - // Filter out any poll responses if (($parent->object_type == Happening::OBJECT_TYPE) && in_array($child->object_type, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE))) { return false; diff --cc plugins/OStatus/lib/magicenvelope.php index a057da515b,35171895ab..39a07d63c5 --- a/plugins/OStatus/lib/magicenvelope.php +++ b/plugins/OStatus/lib/magicenvelope.php @@@ -340,19 -340,19 +340,19 @@@ class MagicEnvelop public function verify(Profile $profile) { if ($this->alg != 'RSA-SHA256') { - common_debug("Salmon error: bad algorithm"); - common_log(LOG_DEBUG, 'Salmon error: bad algorithm: '._ve($this->alg)); ++ common_debug('Salmon error: bad algorithm: ' . _ve($this->alg)); return false; } if ($this->encoding != self::ENCODING) { - common_debug("Salmon error: bad encoding"); - common_log(LOG_DEBUG, 'Salmon error: bad encoding: '._ve($this->encoding)); ++ common_debug('Salmon error: bad encoding: ' . _ve($this->encoding)); return false; } try { $magicsig = $this->getKeyPair($profile, true); // Do discovery too if necessary } catch (Exception $e) { - common_debug("Salmon error: ".$e->getMessage()); - common_log(LOG_DEBUG, "Salmon error: getKeyPair for profile id=={$profile->getID()}: "._ve($e->getMessage())); ++ common_debug("Salmon error: getKeyPair for profile id=={$profile->getID()}: " . _ve($e->getMessage())); return false; } diff --cc plugins/OStatus/lib/salmonaction.php index 2f48042820,41e4262498..ef6099c883 --- a/plugins/OStatus/lib/salmonaction.php +++ b/plugins/OStatus/lib/salmonaction.php @@@ -93,7 -94,26 +94,26 @@@ class SalmonAction extends Actio { parent::handle(); - common_debug("Got a " . $this->activity->verb); + assert($this->activity instanceof Activity); + assert($this->target instanceof Profile); + - common_log(LOG_DEBUG, "Got a " . $this->activity->verb); ++ common_debug('Got a ' . $this->activity->verb); + try { + $options = [ 'source' => 'ostatus' ]; + common_debug('Save salmon slap directly with Notice::saveActivity for actor=='.$this->actor->getID()); + $stored = Notice::saveActivity($this->activity, $this->actor, $options); + common_debug('Save salmon slap finished, notice id=='.$stored->getID()); + return true; + } catch (AlreadyFulfilledException $e) { + // The action's results are already fulfilled. Maybe it was a + // duplicate? Maybe someone's database is out of sync? + // Let's just accept it and move on. + common_log(LOG_INFO, 'Salmon slap carried an event which had already been fulfilled.'); + return true; + } catch (NoticeSaveException $e) { + common_debug('Notice::saveActivity did not save our '._ve($this->activity->verb).' activity, trying old-fashioned salmon saving.'); + } + try { if (Event::handle('StartHandleSalmonTarget', array($this->activity, $this->target)) && Event::handle('StartHandleSalmon', array($this->activity))) { diff --cc plugins/OpportunisticQM/OpportunisticQMPlugin.php index fdd484caef,8e0486105f..89d79e9b0d --- a/plugins/OpportunisticQM/OpportunisticQMPlugin.php +++ b/plugins/OpportunisticQM/OpportunisticQMPlugin.php @@@ -30,8 -4,9 +30,9 @@@ class OpportunisticQMPlugin extends Plu public $qmkey = false; public $secs_per_action = 1; // total seconds to run script per action public $rel_to_pageload = true; // relative to pageload or queue start + public $verbosity = 1; - public function onRouterInitialized($m) + public function onRouterInitialized(URLMapper $m) { $m->connect('main/runqueue', array('action' => 'runqueue')); } diff --cc plugins/StrictTransportSecurity/StrictTransportSecurityPlugin.php index 3d7788c711,67cb665018..ca7434a7fb --- a/plugins/StrictTransportSecurity/StrictTransportSecurityPlugin.php +++ b/plugins/StrictTransportSecurity/StrictTransportSecurityPlugin.php @@@ -40,10 -40,10 +40,10 @@@ class StrictTransportSecurityPlugin ext parent::__construct(); } - function onArgsInitialize($args) + function onArgsInitialize(array &$args) { $path = common_config('site', 'path'); - if(common_config('site', 'ssl') == 'always' && ($path == '/' || ! $path )) { + if (GNUsocial::useHTTPS() && ($path == '/' || mb_strlen($path)==0 )) { header('Strict-Transport-Security: max-age=' . $this->max_age . ($this->includeSubDomains ? '; includeSubDomains' : '') . ($this->preloadToken ? '; preload' : ''));