Compare commits

..

No commits in common. "develop" and "issue-14692" have entirely different histories.

29 changed files with 113 additions and 177 deletions

View file

@ -48,7 +48,7 @@ steps:
branch: [ develop, '*-rc' ]
event: push
composer_install:
image: friendicaci/php8.2:php8.2.28
image: friendicaci/php8.2:php8.2.16
commands:
- export COMPOSER_HOME=.composer
- composer validate

View file

@ -5,13 +5,11 @@ matrix:
- PHP_MAJOR_VERSION: 8.0
PHP_VERSION: 8.0.30
- PHP_MAJOR_VERSION: 8.1
PHP_VERSION: 8.1.31
PHP_VERSION: 8.1.27
- PHP_MAJOR_VERSION: 8.2
PHP_VERSION: 8.2.28
PHP_VERSION: 8.2.16
- PHP_MAJOR_VERSION: 8.3
PHP_VERSION: 8.3.17
- PHP_MAJOR_VERSION: 8.4
PHP_VERSION: 8.4.5
PHP_VERSION: 8.3.3
# This forces PHP Unit executions at the "opensocial" labeled location (because of much more power...)
labels:

View file

@ -45,7 +45,7 @@ steps:
repo: friendica/friendica-addons
event: tag
composer_install:
image: friendicaci/php8.2:php8.2.28
image: friendicaci/php8.2:php8.2.16
commands:
- export COMPOSER_HOME=.composer
- composer validate

View file

@ -672,8 +672,6 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
}
}
$item['body'] = bluesky_set_mentions($item['body']);
$urls = bluesky_get_urls($item['body']);
$item['body'] = $urls['body'];
@ -735,41 +733,14 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
}
}
function bluesky_set_mentions(string $body): string
{
// Remove all url based mention links
$body = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $body);
if (!preg_match_all("/[@!]\[url\=(did:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
return $body;
}
foreach ($matches as $match) {
$contact = Contact::selectFirst(['addr'], ['nurl' => $match[1]]);
if (!empty($contact['addr'])) {
$body = str_replace($match[0], '@[url=' . $match[1] . ']' . $contact['addr'] . '[/url]', $body);
} else {
$body = str_replace($match[0], '@' . $match[2], $body);
}
}
return $body;
}
function bluesky_get_urls(string $body): array
{
// Remove all hashtag and mention links
$body = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $body);
$body = BBCode::expandVideoLinks($body);
$urls = [];
// Search for Mentions
if (preg_match_all("/[@!]\[url\=(did:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$text = '@' . $match[2];
$urls[strpos($body, $match[0])] = ['mention' => $match[1], 'text' => $text, 'hash' => $text];
$body = str_replace($match[0], $text, $body);
}
}
// Search for hash tags
if (preg_match_all("/#\[url\=(https?:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
@ -854,9 +825,6 @@ function bluesky_get_facets(string $body, array $urls): array
} elseif (!empty($url['url'])) {
$feature->uri = $url['url'];
$feature->$type = 'app.bsky.richtext.facet#link';
} elseif (!empty($url['mention'])) {
$feature->did = $url['mention'];
$feature->$type = 'app.bsky.richtext.facet#mention';
} else {
continue;
}
@ -1037,10 +1005,6 @@ function bluesky_process_reason(stdClass $reason, string $uri, int $uid)
return;
}
if (Post::exists(['uid' => $item['uid'], 'thr-parent' => $item['thr-parent'], 'verb' => $item['verb'], 'contact-id' => $item['contact-id']])) {
return;
}
$item['guid'] = Item::guidFromUri($item['uri'], $contact['alias']);
$item['owner-name'] = $item['author-name'];
$item['owner-link'] = $item['author-link'];
@ -1174,14 +1138,8 @@ function bluesky_get_feeds(int $uid): array
return [];
}
foreach ($preferences->preferences as $preference) {
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPrefV2') {
$pinned = [];
foreach ($preference->items as $item) {
if (($item->type == 'feed') && $item->pinned) {
$pinned[] = $item->value;
}
}
return $pinned;
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPref') {
return $preference->pinned ?? [];
}
}
return [];

View file

@ -33,6 +33,7 @@ class Diaspora_Connection {
}
$this->cookiejar = tempnam(System::getTempPath(), 'cookies');
return $this;
}
public function __destruct() {

View file

@ -54,8 +54,8 @@ function invidious_settings(array &$data)
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/invidious/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['invidious-enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
'$server' => ['invidious-server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
'$enabled' => ['enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
'$server' => ['server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
]);
$data = [
@ -71,9 +71,9 @@ function invidious_settings_post(array &$b)
return;
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['invidious-enabled']);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['enabled']);
$server = trim($_POST['invidious-server'], " \n\r\t\v\x00/");
$server = trim($_POST['server'], " \n\r\t\v\x00/");
if ($server != DI::config()->get('invidious', 'server', INVIDIOUS_DEFAULT) && !empty($server)) {
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'server', $server);
} else {

View file

@ -188,7 +188,7 @@ class js_upload_qqFileUploader
private $sizeLimit;
/**
* @var js_upload_qqUploadedFileXhr|js_upload_qqUploadedFileForm|false
* @var js_upload_qqUploadedFileXhr|js_upload_qqUploadedFileForm
*/
private $file;

View file

@ -361,7 +361,7 @@ class Services_Libravatar
protected function domainGet($identifier)
{
if ($identifier === null) {
return '';
return null;
}
// What are we, email or openid? Split ourself up and get the

View file

@ -6,6 +6,7 @@
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -70,9 +71,7 @@ function libravatar_addon_admin(string &$o)
'pagan' => DI::l10n()->t('retro adventure game character'),
];
$addonHelper = DI::addonHelper();
if ($addonHelper->isAddonEnabled('gravatar')) {
if (Addon::isEnabled('gravatar')) {
$o = '<h5>' .DI::l10n()->t('Information') .'</h5><p>' .DI::l10n()->t('Gravatar addon is installed. Please disable the Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'</p><br><br>';
}

View file

@ -179,7 +179,7 @@ function mailstream_post_hook(array &$item)
function mailstream_do_images(array &$item, array &$attachments)
{
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) {
return $attachments;
return;
}
$attachments = [];

View file

@ -26,7 +26,7 @@ function markdown_addon_settings(array &$data)
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['markdown-enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
'$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
]);
$data = [
@ -42,7 +42,7 @@ function markdown_addon_settings_post(array &$b)
return;
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['markdown-enabled']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['enabled']));
}
function markdown_post_local_start(&$request) {

View file

@ -17,11 +17,7 @@ function membersince_install()
Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
}
/**
* @param array|string|null $b
* @return void
*/
function membersince_display(&$b)
function membersince_display(array &$b)
{
$uid = DI::userSession()->getLocalUserId();
@ -63,7 +59,7 @@ function membersince_display(&$b)
$div->appendChild($entry);
$elm->parentNode->insertBefore($div, $elm->nextSibling);
$b = (string) $doc->saveHTML();
$b = $doc->saveHTML();
} else {
// Works in Vier.
$b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($user['register_date']) . "</dd>\n</dl>", $b, 1);

View file

@ -1,4 +0,0 @@
# Monolog Addon
A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)).
There are just Friendica additions inside the src directory.

View file

@ -1,7 +1,7 @@
<?php
/*
* Name: Monolog
* Description: A Logging framework with lots of additions, customized for Friendica.
* Version: 1.1
* Description: A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)). There are just Friendica additions inside the src directory
* Version: 1.0
* Author: Philipp Holzer
*/

View file

@ -4,8 +4,7 @@ namespace Friendica\Addon\monolog\src\Factory;
use Friendica\Addon\monolog\src\Monolog\IntrospectionProcessor;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Friendica\Core\Logger\Factory\LoggerFactory;
use Friendica\Core\Logger\Factory\AbstractLoggerTypeFactory;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
@ -17,49 +16,32 @@ use Psr\Log\LogLevel;
require_once __DIR__ . '/../../vendor/autoload.php';
final class MonologFactory implements LoggerFactory
class Monolog extends AbstractLoggerTypeFactory
{
private IHaveCallIntrospections $introspection;
private IManageConfigValues $config;
public function __construct(IHaveCallIntrospections $introspection, IManageConfigValues $config)
{
$this->introspection = $introspection;
$this->config = $config;
}
/**
* Creates and returns a PSR-3 Logger instance.
*
* Calling this method multiple times with the same parameters SHOULD return the same object.
*
* @param \Psr\Log\LogLevel::* $logLevel The log level
* @param \Friendica\Core\Logger\Capability\LogChannel::* $logChannel The log channel
*/
public function createLogger(string $logLevel, string $logChannel): LoggerInterface
public function create(IManageConfigValues $config, string $loglevel = null): LoggerInterface
{
$loggerTimeZone = new \DateTimeZone('UTC');
$logger = new Logger($logChannel);
$logger = new Logger($this->channel);
$logger->setTimezone($loggerTimeZone);
$logger->pushProcessor(new PsrLogMessageProcessor());
$logger->pushProcessor(new ProcessIdProcessor());
$logger->pushProcessor(new UidProcessor());
$logger->pushProcessor(new IntrospectionProcessor($this->introspection, LogLevel::DEBUG));
$logfile = $this->config->get('system', 'logfile');
$logfile = $config->get('system', 'logfile');
// just add a stream in case it's either writable or not file
if (is_writable($logfile)) {
$logLevel = Logger::toMonologLevel($logLevel);
$loglevel = $loglevel ?? static::mapLegacyConfigDebugLevel($config->get('system', 'loglevel'));
$loglevel = Logger::toMonologLevel($loglevel);
// fallback to notice if an invalid loglevel is set
if (!is_int($logLevel)) {
$logLevel = LogLevel::NOTICE;
if (!is_int($loglevel)) {
$loglevel = LogLevel::NOTICE;
}
$fileHandler = new StreamHandler($logfile, $logLevel);
$fileHandler = new StreamHandler($logfile, $loglevel);
$formatter = new LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
$fileHandler->setFormatter($formatter);

View file

@ -20,7 +20,10 @@
*/
return [
\Friendica\Core\Logger\Factory\LoggerFactory::class => [
'instanceOf' => \Friendica\Addon\monolog\src\Factory\MonologFactory::class,
\Monolog\Logger::class => [
'instanceOf' => \Friendica\Addon\monolog\src\Factory\Monolog::class,
'call' => [
['create', [], \Dice\Dice::CHAIN_CALL],
],
],
];

View file

@ -0,0 +1,26 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
return [
\Psr\Log\LoggerInterface::class => [
\Monolog\Logger::class => ['monolog'],
],
];

View file

@ -57,7 +57,7 @@ function notifyall_post()
$notifyEmail = new NotifyAllEmail(DI::l10n(), DI::config(), DI::baseUrl(), $text);
foreach (DBA::toArray($recipients) as $recipient) {
foreach ($recipients as $recipient) {
DI::emailer()->send($notifyEmail->withRecipient($recipient['email']));
}

View file

@ -28,14 +28,10 @@ function phpmailer_load_config(ConfigFileManager $loader)
}
/**
* @param null|IEmail $email
* @param IEmail $email
*/
function phpmailer_emailer_send_prepare(?IEmail &$email)
function phpmailer_emailer_send_prepare(IEmail &$email)
{
if ($email === null) {
return;
}
// Passing `true` enables exceptions
$mailer = new PHPMailer(true);
try {

View file

@ -1025,7 +1025,7 @@ class phpnut
* see: https://docs.pnut.io/resources/posts/search
* @param string $query The search query. Supports
* normal search terms. Searches post text.
* @return string|array|false An array of associative arrays, each representing one post.
* @return array An array of associative arrays, each representing one post.
* or false on error
*/
public function searchPosts(array $params=[], string $query='', string $order='default')
@ -1769,7 +1769,7 @@ class phpnut
* see: https://docs.pnut.io/resources/messages/search
* @param string $query The search query. Supports
* normal search terms. Searches common channel raw.
* @return string|array|false An array of associative arrays, each representing one channel.
* @return array An array of associative arrays, each representing one channel.
* or false on error
*/
public function searchMessages(array $params=[], string $query='', string $order='default')

View file

@ -8,6 +8,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
@ -626,9 +627,7 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
function pumpio_sync()
{
$addonHelper = DI::addonHelper();
if (!$addonHelper->isAddonEnabled('pumpio')) {
if (!Addon::isEnabled('pumpio')) {
return;
}

View file

@ -59,7 +59,7 @@ function rendertime_page_end(string &$o)
if (DI::userSession()->isSiteAdmin() && (($_GET['mode'] ?? '') != 'minimal') && !DI::mode()->isMobile() && !DI::mode()->isMobile() && !$ignored) {
$o = $o . '<div class="renderinfo" aria-hidden="true">' . DI::l10n()->t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
$o = $o . '<div class="renderinfo">' . DI::l10n()->t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
round($profiler->get('database') - $profiler->get('database_write'), 3),
round($profiler->get('database_write'), 3),
round($profiler->get('network'), 2),

View file

@ -82,13 +82,11 @@ function saml_footer(string &$body)
<script>
var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); }
document.getElementById('id_email').setAttribute('readonly', 'readonly');
var saml_hint = document.createElement("span");
var saml_hint_text = document.createTextNode('$samlhint');
saml_hint.appendChild(saml_hint_text);
if ( document.getElementById('id_email') != null ) {
document.getElementById('id_email').setAttribute('readonly', 'readonly');
document.getElementById('id_email').parentNode.insertBefore(saml_hint, document.getElementById('id_email').nextSibling);
}
document.getElementById('id_email').parentNode.insertBefore(saml_hint, document.getElementById('id_email').nextSibling);
// Frio theme
if ( document.getElementById('password-settings-collapse') != null ) {
document.getElementById('password-settings-collapse').replaceChildren(saml_hint.cloneNode(true));

View file

@ -59,7 +59,7 @@ function addHeightToggleHandler($item) {
$item.data("item-id", itemId);
var toggleId = "wall-item-body-toggle-" + itemId;
$item.append('<div class="wall-item-body-toggle" data-item-id="' + itemId + '" id="' + toggleId + '" ><button type="button" class="wall-item-body-toggle-text" aria-hidden="true">' + showmore_dyn_showmore_linktext + '</button></div>');
$item.append('<div class="wall-item-body-toggle" data-item-id="' + itemId + '" id="' + toggleId + '" ><button type="button" class="wall-item-body-toggle-text">' + showmore_dyn_showmore_linktext + '</button></div>');
$item.addClass("limitable limit-height");
var $toggle = $("#" + toggleId);

View file

@ -976,7 +976,7 @@ class CodebirdSN
* @param string $method The method that has been called
* @param string $reply The actual reply, JSON-encoded or URL-encoded
*
* @return string|array|object The parsed reply
* @return array|object The parsed reply
*/
protected function _parseApiReply($method, $reply)
{

View file

@ -12,7 +12,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'twitteroauth.php';
*/
class StatusNetOAuth extends TwitterOAuth
{
public function get_maxlength()
function get_maxlength()
{
$config = $this->get($this->host . 'statusnet/config.json');
if (empty($config)) {
@ -21,27 +21,27 @@ class StatusNetOAuth extends TwitterOAuth
return $config->site->textlimit;
}
public function accessTokenURL()
function accessTokenURL()
{
return $this->host . 'oauth/access_token';
}
public function authenticateURL()
function authenticateURL()
{
return $this->host . 'oauth/authenticate';
}
public function authorizeURL()
function authorizeURL()
{
return $this->host . 'oauth/authorize';
}
public function requestTokenURL()
function requestTokenURL()
{
return $this->host . 'oauth/request_token';
}
public function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
{
parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$this->host = $apipath;
@ -52,9 +52,9 @@ class StatusNetOAuth extends TwitterOAuth
*
* Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica
*
* @return array|object|mixed API results
* @return array|object API results
*/
public function http($url, $method, $postfields = NULL)
function http($url, $method, $postfields = NULL)
{
$this->http_info = [];
$ci = curl_init();

View file

@ -45,11 +45,11 @@ class TwitterOAuth
public $http_header;
/**
* Contains the last HTTP request info
* @var array
* @var string
*/
public $http_info;
/** @var OAuthToken|null */
/** @var OAuthToken */
private $token;
/** @var OAuthConsumer */
private $consumer;
@ -59,27 +59,27 @@ class TwitterOAuth
/**
* Set API URLS
*/
public function accessTokenURL()
function accessTokenURL()
{
return 'https://api.twitter.com/oauth/access_token';
}
public function authenticateURL()
function authenticateURL()
{
return 'https://twitter.com/oauth/authenticate';
}
public function authorizeURL()
function authorizeURL()
{
return 'https://twitter.com/oauth/authorize';
}
public function requestTokenURL()
function requestTokenURL()
{
return 'https://api.twitter.com/oauth/request_token';
}
public function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
{
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
@ -96,7 +96,7 @@ class TwitterOAuth
* @param callable $oauth_callback
* @return array
*/
public function getRequestToken($oauth_callback = null)
function getRequestToken($oauth_callback = null)
{
$parameters = [];
if (!empty($oauth_callback)) {
@ -114,7 +114,7 @@ class TwitterOAuth
*
* @return string
*/
public function getAuthorizeURL($token, $sign_in_with_twitter = TRUE)
function getAuthorizeURL($token, $sign_in_with_twitter = TRUE)
{
if (is_array($token)) {
$token = $token['oauth_token'];
@ -137,7 +137,7 @@ class TwitterOAuth
* "user_id" => "9436992",
* "screen_name" => "abraham")
*/
public function getAccessToken($oauth_verifier = FALSE)
function getAccessToken($oauth_verifier = FALSE)
{
$parameters = [];
if (!empty($oauth_verifier)) {
@ -162,7 +162,7 @@ class TwitterOAuth
* "screen_name" => "abraham",
* "x_auth_expires" => "0")
*/
public function getXAuthToken($username, $password)
function getXAuthToken($username, $password)
{
$parameters = [];
$parameters['x_auth_username'] = $username;
@ -182,7 +182,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function get($url, $parameters = [])
function get($url, $parameters = [])
{
$response = $this->oAuthRequest($url, 'GET', $parameters);
if ($this->format === 'json' && $this->decode_json) {
@ -199,7 +199,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function post($url, $parameters = [])
function post($url, $parameters = [])
{
$response = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->format === 'json' && $this->decode_json) {
@ -216,7 +216,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function delete($url, $parameters = [])
function delete($url, $parameters = [])
{
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
if ($this->format === 'json' && $this->decode_json) {
@ -234,7 +234,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function oAuthRequest($url, $method, $parameters)
function oAuthRequest($url, $method, $parameters)
{
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
$url = "{$this->host}{$url}.{$this->format}";
@ -258,9 +258,9 @@ class TwitterOAuth
* @param string $url
* @param string $method
* @param mixed $postfields
* @return string|bool|mixed API results
* @return string API results
*/
public function http($url, $method, $postfields = null)
function http($url, $method, $postfields = null)
{
$this->http_info = [];
$ci = curl_init();
@ -305,7 +305,7 @@ class TwitterOAuth
* @param string $header
* @return int
*/
public function getHeader($ch, $header)
function getHeader($ch, $header)
{
$i = strpos($header, ':');
if (!empty($i)) {

View file

@ -391,17 +391,12 @@ function tumblr_settings_post(array &$b)
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'import', intval($_POST['tumblr_import']));
$max_tags = DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS;
$tags = array_slice(
array_filter(
array_map(
function($tag) { return trim($tag, ' #');},
explode(',', $_POST['tags']) ?: []
)
),
0,
$max_tags,
);
$tags = [];
foreach (explode(',', $_POST['tags']) as $tag) {
if (count($tags) < $max_tags) {
$tags[] = trim($tag, ' #');
}
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'tags', $tags);
}
@ -747,18 +742,7 @@ function tumblr_fetch_tags(int $uid, int $last_poll)
}
foreach (DI::pConfig()->get($uid, 'tumblr', 'tags') ?? [] as $tag) {
// Tumblr will return an error for queries on empty tag
if (!$tag) {
continue;
}
$data = tumblr_get($uid, 'tagged', ['tag' => $tag]);
if (!is_array($data->response)) {
DI::logger()->warning('Unexpected Tumblr response format', ['uid' => $uid, 'url' => 'tagged', 'parameters' => ['tag' => $tag], 'data' => $data]);
continue;
}
foreach (array_reverse($data->response) as $post) {
$id = tumblr_process_post($post, $uid, Item::PR_TAG, $last_poll);
if (!empty($id)) {
@ -791,7 +775,7 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll)
$dashboard = tumblr_get($uid, 'user/dashboard', $parameters);
if ($dashboard->meta->status > 399) {
DI::logger()->notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]);
return;
return [];
}
if (empty($dashboard->response->posts)) {

View file

@ -52,7 +52,7 @@ class WebDavConfig implements ICanConfigureStorage
$this->config = $config;
$this->client = $client;
$this->authOptions = [];
$this->authOptions = null;
if (!empty($this->config->get('webdav', 'username'))) {
$this->authOptions = [