diff --git a/.woodpecker/.code_standards_check.yml b/.woodpecker/.code_standards_check.yml index 60a1bd2a..50872d4c 100644 --- a/.woodpecker/.code_standards_check.yml +++ b/.woodpecker/.code_standards_check.yml @@ -56,10 +56,6 @@ steps: - /tmp/drone-cache:/tmp/cache when: event: pull_request - phpstan: - image: friendicaci/php8.3:php8.3.3 - commands: - - ./bin/composer.phar run phpstan; check: image: friendicaci/php-cs commands: diff --git a/.woodpecker/.continuous-deployment.yml b/.woodpecker/.continuous-deployment.yml index d6d8a22a..6b41deae 100644 --- a/.woodpecker/.continuous-deployment.yml +++ b/.woodpecker/.continuous-deployment.yml @@ -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 diff --git a/.woodpecker/.phpunit.yml b/.woodpecker/.phpunit.yml index b0745ad0..8b840f80 100644 --- a/.woodpecker/.phpunit.yml +++ b/.woodpecker/.phpunit.yml @@ -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: diff --git a/.woodpecker/.releaser.yml b/.woodpecker/.releaser.yml index 7407f2bc..2d880a6b 100644 --- a/.woodpecker/.releaser.yml +++ b/.woodpecker/.releaser.yml @@ -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 diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index 53cb9ebe..418b253e 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -33,13 +33,16 @@ * */ +use Friendica\App; use Friendica\BaseModule; use Friendica\Content\Text\Markdown; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\Database\DBStructure; use Friendica\DI; +use Friendica\Model\Item; use Friendica\Model\Post; use Friendica\Model\Tag; use Friendica\Model\User; @@ -61,7 +64,7 @@ function advancedcontentfilter_install() Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition'); DBStructure::performUpdate(); - DI::logger()->notice('installed advancedcontentfilter'); + Logger::notice('installed advancedcontentfilter'); } /* @@ -120,22 +123,21 @@ function advancedcontentfilter_prepare_body_content_filter(&$hook_data) $expressionLanguage = new ExpressionLanguage\ExpressionLanguage(); } - $uid = $hook_data['uid'] ?? DI::userSession()->getLocalUserId(); - if (!$uid) { + if (!DI::userSession()->getLocalUserId()) { return; } $vars = advancedcontentfilter_get_filter_fields($hook_data['item']); - $rules = DI::cache()->get('rules_' . $uid); + $rules = DI::cache()->get('rules_' . DI::userSession()->getLocalUserId()); if (!isset($rules)) { $rules = DBA::toArray(DBA::select( 'advancedcontentfilter_rules', ['name', 'expression', 'serialized'], - ['uid' => $uid, 'active' => true] + ['uid' => DI::userSession()->getLocalUserId(), 'active' => true] )); - DI::cache()->set('rules_' . $uid, $rules); + DI::cache()->set('rules_' . DI::userSession()->getLocalUserId(), $rules); } if ($rules) { @@ -190,30 +192,9 @@ function advancedcontentfilter_init() if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') { $slim = \Slim\Factory\AppFactory::create(); - /** - * The routing middleware should be added before the ErrorMiddleware - * Otherwise exceptions thrown from it will not be handled - */ - $slim->addRoutingMiddleware(); - - $slim->addErrorMiddleware(true, true, true, DI::logger()); - - // register routes - $slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) { - $app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) { - $app->get('', 'advancedcontentfilter_get_rules'); - $app->post('', 'advancedcontentfilter_post_rules'); - - $app->get('/{id}', 'advancedcontentfilter_get_rules_id'); - $app->put('/{id}', 'advancedcontentfilter_put_rules_id'); - $app->delete('/{id}', 'advancedcontentfilter_delete_rules_id'); - }); - - $app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) { - $app->get('/{guid}', 'advancedcontentfilter_get_variables_guid'); - }); - }); + require __DIR__ . '/src/middlewares.php'; + require __DIR__ . '/src/routes.php'; $slim->run(); exit; @@ -271,7 +252,7 @@ function advancedcontentfilter_content() 'rule_expression' => DI::l10n()->t('Rule Expression'), 'cancel' => DI::l10n()->t('Cancel'), ], - '$current_theme' => DI::appHelper()->getCurrentTheme(), + '$current_theme' => DI::app()->getCurrentTheme(), '$rules' => DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => DI::userSession()->getLocalUserId()])), '$form_security_token' => BaseModule::getFormSecurityToken() ]); diff --git a/advancedcontentfilter/src/middlewares.php b/advancedcontentfilter/src/middlewares.php new file mode 100644 index 00000000..2b831473 --- /dev/null +++ b/advancedcontentfilter/src/middlewares.php @@ -0,0 +1,32 @@ +. + * + */ + +use Friendica\DI; + +/** @var $slim \Slim\App */ + +/** + * The routing middleware should be added before the ErrorMiddleware + * Otherwise exceptions thrown from it will not be handled + */ +$slim->addRoutingMiddleware(); + +$errorMiddleware = $slim->addErrorMiddleware(true, true, true, DI::logger()); diff --git a/advancedcontentfilter/src/routes.php b/advancedcontentfilter/src/routes.php new file mode 100644 index 00000000..a46f1b4b --- /dev/null +++ b/advancedcontentfilter/src/routes.php @@ -0,0 +1,36 @@ +. + * + */ + +/* @var $slim Slim\App */ +$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) { + $app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) { + $app->get('', 'advancedcontentfilter_get_rules'); + $app->post('', 'advancedcontentfilter_post_rules'); + + $app->get('/{id}', 'advancedcontentfilter_get_rules_id'); + $app->put('/{id}', 'advancedcontentfilter_put_rules_id'); + $app->delete('/{id}', 'advancedcontentfilter_delete_rules_id'); + }); + + $app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) { + $app->get('/{guid}', 'advancedcontentfilter_get_variables_guid'); + }); +}); diff --git a/birdavatar/birdavatar.php b/birdavatar/birdavatar.php index cd49b183..4841ba52 100644 --- a/birdavatar/birdavatar.php +++ b/birdavatar/birdavatar.php @@ -6,7 +6,9 @@ * Author: Fabio */ +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -26,7 +28,7 @@ function birdavatar_install() Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings'); Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post'); - DI::logger()->info('registered birdavatar'); + Logger::info('registered birdavatar'); } /** diff --git a/blackout/blackout.php b/blackout/blackout.php index ac1ee3e6..55fb8d32 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -44,7 +44,9 @@ * THE SOFTWARE. */ +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\DI; @@ -76,7 +78,7 @@ function blackout_redirect ($b) } if (( $date1 <= $now ) && ( $now <= $date2 )) { - DI::logger()->notice('redirecting user to blackout page'); + Logger::notice('redirecting user to blackout page'); System::externalRedirect($myurl); } } diff --git a/blockbot/blockbot.php b/blockbot/blockbot.php index 71e35c93..022f188d 100644 --- a/blockbot/blockbot.php +++ b/blockbot/blockbot.php @@ -11,6 +11,7 @@ use Friendica\Core\Hook; use Friendica\DI; use Jaybizzle\CrawlerDetect\CrawlerDetect; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Network\HTTPException\ForbiddenException; @@ -69,7 +70,7 @@ function blockbot_init_1() } if (empty($parts)) { - DI::logger()->debug('Known frontend found - accept', $logdata); + Logger::debug('Known frontend found - accept', $logdata); if ($isCrawler) { blockbot_save('badly-parsed-agents', $_SERVER['HTTP_USER_AGENT']); } @@ -79,66 +80,66 @@ function blockbot_init_1() blockbot_log_activitypub($_SERVER['REQUEST_URI'], $_SERVER['HTTP_USER_AGENT']); if (blockbot_is_crawler($parts)) { - DI::logger()->debug('Crawler found - reject', $logdata); + Logger::debug('Crawler found - reject', $logdata); blockbot_reject(); } if (blockbot_is_searchbot($parts)) { - DI::logger()->debug('Search bot found - reject', $logdata); + Logger::debug('Search bot found - reject', $logdata); blockbot_reject(); } if (blockbot_is_unwanted($parts)) { - DI::logger()->debug('Uncategorized unwanted agent found - reject', $logdata); + Logger::debug('Uncategorized unwanted agent found - reject', $logdata); blockbot_reject(); } if (blockbot_is_security_checker($parts)) { if (!DI::config()->get('blockbot', 'security_checker')) { - DI::logger()->debug('Security checker found - reject', $logdata); + Logger::debug('Security checker found - reject', $logdata); blockbot_reject(); } - DI::logger()->debug('Security checker found - accept', $logdata); + Logger::debug('Security checker found - accept', $logdata); return; } if (blockbot_is_social_media($parts)) { - DI::logger()->debug('Social media service found - accept', $logdata); + Logger::debug('Social media service found - accept', $logdata); return; } if (blockbot_is_fediverse_client($parts)) { - DI::logger()->debug('Fediverse client found - accept', $logdata); + Logger::debug('Fediverse client found - accept', $logdata); return; } if (blockbot_is_feed_reader($parts)) { - DI::logger()->debug('Feed reader found - accept', $logdata); + Logger::debug('Feed reader found - accept', $logdata); return; } if (blockbot_is_fediverse_tool($parts)) { - DI::logger()->debug('Fediverse tool found - accept', $logdata); + Logger::debug('Fediverse tool found - accept', $logdata); return; } if (blockbot_is_service_agent($parts)) { - DI::logger()->debug('Service agent found - accept', $logdata); + Logger::debug('Service agent found - accept', $logdata); return; } if (blockbot_is_monitor($parts)) { - DI::logger()->debug('Monitoring service found - accept', $logdata); + Logger::debug('Monitoring service found - accept', $logdata); return; } if (blockbot_is_validator($parts)) { - DI::logger()->debug('Validation service found - accept', $logdata); + Logger::debug('Validation service found - accept', $logdata); return; } if (blockbot_is_good_tool($parts)) { - DI::logger()->debug('Uncategorized helpful service found - accept', $logdata); + Logger::debug('Uncategorized helpful service found - accept', $logdata); return; } @@ -146,10 +147,10 @@ function blockbot_init_1() if (blockbot_is_http_library($parts)) { blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata); if (!DI::config()->get('blockbot', 'http_libraries')) { - DI::logger()->debug('HTTP Library found - reject', $logdata); + Logger::debug('HTTP Library found - reject', $logdata); blockbot_reject(); } - DI::logger()->debug('HTTP Library found - accept', $logdata); + Logger::debug('HTTP Library found - accept', $logdata); return; } @@ -160,12 +161,12 @@ function blockbot_init_1() if (!$isCrawler) { blockbot_save('good-agents', $_SERVER['HTTP_USER_AGENT']); - DI::logger()->debug('Non-bot user agent detected', $logdata); + Logger::debug('Non-bot user agent detected', $logdata); return; } blockbot_save('bad-agents', $_SERVER['HTTP_USER_AGENT']); - DI::logger()->notice('Possible bot found - reject', $logdata); + Logger::notice('Possible bot found - reject', $logdata); blockbot_reject(); } @@ -208,7 +209,7 @@ function blockbot_log_activitypub(string $url, string $agent) blockbot_save('activitypub-inbox-agents', $agent); } - if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER, false))) { + if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER))) { blockbot_save('activitypub-signature-agents', $agent); } } @@ -216,7 +217,7 @@ function blockbot_log_activitypub(string $url, string $agent) function blockbot_check_login_attempt(string $url, array $logdata) { if (in_array(trim(parse_url($url, PHP_URL_PATH), '/'), ['login', 'lostpass', 'register'])) { - DI::logger()->debug('Login attempt detected - reject', $logdata); + Logger::debug('Login attempt detected - reject', $logdata); blockbot_reject(); } } @@ -442,7 +443,7 @@ function blockbot_is_monitor(array $parts): bool } /** - * Services in the centralized and decentralized social media environment + * Services in the centralized and decentralized social media environment * * @param array $parts * @return boolean diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php index aef7156c..1355f000 100644 --- a/bluesky/bluesky.php +++ b/bluesky/bluesky.php @@ -30,6 +30,7 @@ use Friendica\Content\Text\Plaintext; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Config\Util\ConfigFileManager; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Worker; @@ -72,7 +73,7 @@ function bluesky_install() function bluesky_load_config(ConfigFileManager $loader) { - DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('bluesky'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); + DI::app()->getConfigCache()->load($loader->loadAddonConfig('bluesky'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); } function bluesky_check_item_notification(array &$notification_data) @@ -105,16 +106,16 @@ function bluesky_item_by_link(array &$hookData) if (empty($did)) { return; } - - DI::logger()->debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]); - + + Logger::debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]); + $uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2]; } else { $uri = $hookData['uri']; } $uri = DI::atpProcessor()->fetchMissingPost($uri, $hookData['uid'], Item::PR_FETCHED, 0, 0); - DI::logger()->debug('Got post', ['uri' => $uri]); + Logger::debug('Got post', ['uri' => $uri]); if (!empty($uri)) { $item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]); if (!empty($item['id'])) { @@ -137,7 +138,7 @@ function bluesky_follow(array &$hook_data) return; } - DI::logger()->debug('Check if contact is bluesky', ['data' => $hook_data]); + Logger::debug('Check if contact is bluesky', ['data' => $hook_data]); $contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]); if (empty($contact)) { return; @@ -158,7 +159,7 @@ function bluesky_follow(array &$hook_data) $activity = DI::atProtocol()->XRPCPost($hook_data['uid'], 'com.atproto.repo.createRecord', $post); if (!empty($activity->uri)) { $hook_data['contact'] = $contact; - DI::logger()->debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]); + Logger::debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]); } } @@ -212,7 +213,7 @@ function bluesky_block(array &$hook_data) if ($ucid) { Contact::remove($ucid); } - DI::logger()->debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]); + Logger::debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]); } } @@ -420,11 +421,11 @@ function bluesky_cron() if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - DI::logger()->notice('poll interval not reached'); + Logger::notice('poll interval not reached'); return; } } - DI::logger()->notice('cron_start'); + Logger::notice('cron_start'); $abandon_days = intval(DI::config()->get('system', 'account_abandon_days')); if ($abandon_days < 1) { @@ -436,19 +437,19 @@ function bluesky_cron() $pconfigs = DBA::selectToArray('pconfig', [], ["`cat` = ? AND `k` IN (?, ?) AND `v`", 'bluesky', 'import', 'import_feeds']); foreach ($pconfigs as $pconfig) { if (empty(DI::atProtocol()->getUserDid($pconfig['uid']))) { - DI::logger()->debug('User has got no valid DID', ['uid' => $pconfig['uid']]); + Logger::debug('User has got no valid DID', ['uid' => $pconfig['uid']]); continue; } if ($abandon_days != 0) { if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) { - DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); + Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); continue; } } // Refresh the token now, so that it doesn't need to be refreshed in parallel by the following workers - DI::logger()->debug('Refresh the token', ['uid' => $pconfig['uid']]); + Logger::debug('Refresh the token', ['uid' => $pconfig['uid']]); DI::atProtocol()->getUserToken($pconfig['uid']); $last_sync = DI::pConfig()->get($pconfig['uid'], 'bluesky', 'last_contact_sync'); @@ -462,32 +463,32 @@ function bluesky_cron() Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_timeline.php', $pconfig['uid']); } if (DI::pConfig()->get($pconfig['uid'], 'bluesky', 'import_feeds')) { - DI::logger()->debug('Fetch feeds for user', ['uid' => $pconfig['uid']]); + Logger::debug('Fetch feeds for user', ['uid' => $pconfig['uid']]); $feeds = bluesky_get_feeds($pconfig['uid']); foreach ($feeds as $feed) { Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_feed.php', $pconfig['uid'], $feed); } } - DI::logger()->debug('Polling done for user', ['uid' => $pconfig['uid']]); + Logger::debug('Polling done for user', ['uid' => $pconfig['uid']]); } - DI::logger()->notice('Polling done for all users'); + Logger::notice('Polling done for all users'); DI::keyValue()->set('bluesky_last_poll', time()); $last_clean = DI::keyValue()->get('bluesky_last_clean'); if (empty($last_clean) || ($last_clean + 86400 < time())) { - DI::logger()->notice('Start contact cleanup'); + Logger::notice('Start contact cleanup'); $contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::BLUESKY, 0, Contact::NOTHING]); while ($contact = DBA::fetch($contacts)) { Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0); } DBA::close($contacts); DI::keyValue()->set('bluesky_last_clean', time()); - DI::logger()->notice('Contact cleanup done'); + Logger::notice('Contact cleanup done'); } - DI::logger()->notice('cron_end'); + Logger::notice('cron_end'); } function bluesky_hook_fork(array &$b) @@ -507,7 +508,7 @@ function bluesky_hook_fork(array &$b) if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) { // Don't post if it isn't a reply to a bluesky post if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) { - DI::logger()->notice('No bluesky parent found', ['item' => $post['id']]); + Logger::notice('No bluesky parent found', ['item' => $post['id']]); $b['execute'] = false; return; } @@ -554,12 +555,12 @@ function bluesky_send(array &$b) } if ($b['gravity'] != Item::GRAVITY_PARENT) { - DI::logger()->debug('Got comment', ['item' => $b]); + Logger::debug('Got comment', ['item' => $b]); if ($b['deleted']) { $uri = DI::atpProcessor()->getUriClass($b['uri']); if (empty($uri)) { - DI::logger()->debug('Not a bluesky post', ['uri' => $b['uri']]); + Logger::debug('Not a bluesky post', ['uri' => $b['uri']]); return; } bluesky_delete_post($b['uri'], $b['uid']); @@ -570,12 +571,12 @@ function bluesky_send(array &$b) $parent = DI::atpProcessor()->getUriClass($b['thr-parent']); if (empty($root) || empty($parent)) { - DI::logger()->debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]); + Logger::debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]); return; } if ($b['gravity'] == Item::GRAVITY_COMMENT) { - DI::logger()->debug('Posting comment', ['root' => $root, 'parent' => $parent]); + Logger::debug('Posting comment', ['root' => $root, 'parent' => $parent]); bluesky_create_post($b, $root, $parent); return; } elseif (in_array($b['verb'], [Activity::LIKE, Activity::ANNOUNCE])) { @@ -602,8 +603,6 @@ function bluesky_create_activity(array $item, stdClass $parent = null) return; } - $post = []; - if ($item['verb'] == Activity::LIKE) { $record = [ 'subject' => $parent, @@ -634,10 +633,10 @@ function bluesky_create_activity(array $item, stdClass $parent = null) if (empty($activity->uri)) { return; } - DI::logger()->debug('Activity done', ['return' => $activity]); + Logger::debug('Activity done', ['return' => $activity]); $uri = DI::atpProcessor()->getUri($activity); Item::update(['extid' => $uri], ['guid' => $item['guid']]); - DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $activity]); + Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $activity]); } function bluesky_create_post(array $item, stdClass $root = null, stdClass $parent = null) @@ -672,8 +671,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']; @@ -723,53 +720,26 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren } return; } - DI::logger()->debug('Posting done', ['return' => $parent]); + Logger::debug('Posting done', ['return' => $parent]); if (empty($root)) { $root = $parent; } if (($key == 0) && ($item['gravity'] != Item::GRAVITY_PARENT)) { $uri = DI::atpProcessor()->getUri($parent); Item::update(['extid' => $uri], ['guid' => $item['guid']]); - DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $uri]); + Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $uri]); } } } -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 +824,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; } @@ -930,20 +897,20 @@ function bluesky_upload_blob(int $uid, array $photo): ?stdClass $new_size = strlen($content); if (($size != 0) && ($new_size == 0) && ($retrial == 0)) { - DI::logger()->warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + Logger::warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); $content = Photo::getImageForPhoto($photo); } else { - DI::logger()->info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); } $data = DI::atProtocol()->post($uid, '/xrpc/com.atproto.repo.uploadBlob', $content, ['Content-type' => $photo['type'], 'Authorization' => ['Bearer ' . DI::atProtocol()->getUserToken($uid)]]); if (empty($data) || empty($data->blob)) { - DI::logger()->info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + Logger::info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); return null; } Item::incrementOutbound(Protocol::BLUESKY); - DI::logger()->debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); + Logger::debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]); return $data->blob; } @@ -951,11 +918,11 @@ function bluesky_delete_post(string $uri, int $uid) { $parts = DI::atpProcessor()->getUriParts($uri); if (empty($parts)) { - DI::logger()->debug('No uri delected', ['uri' => $uri]); + Logger::debug('No uri delected', ['uri' => $uri]); return; } DI::atProtocol()->XRPCPost($uid, 'com.atproto.repo.deleteRecord', $parts); - DI::logger()->debug('Deleted', ['parts' => $parts]); + Logger::debug('Deleted', ['parts' => $parts]); } function bluesky_fetch_timeline(int $uid) @@ -1037,10 +1004,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']; @@ -1061,10 +1024,10 @@ function bluesky_fetch_notifications(int $uid) foreach ($data->notifications as $notification) { $uri = DI::atpProcessor()->getUri($notification); if (Post::exists(['uri' => $uri, 'uid' => $uid]) || Post::exists(['extid' => $uri, 'uid' => $uid])) { - DI::logger()->debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); + Logger::debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); continue; } - DI::logger()->debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); + Logger::debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]); switch ($notification->reason) { case 'like': $item = DI::atpProcessor()->getHeaderFromPost($notification, $uri, $uid, Conversation::PARCEL_CONNECTOR); @@ -1074,9 +1037,9 @@ function bluesky_fetch_notifications(int $uid) $item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0); if (!empty($item['thr-parent'])) { $data = Item::insert($item); - DI::logger()->debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); + Logger::debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); } else { - DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); + Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); } break; @@ -1088,37 +1051,37 @@ function bluesky_fetch_notifications(int $uid) $item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0); if (!empty($item['thr-parent'])) { $data = Item::insert($item); - DI::logger()->debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); + Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); } else { - DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); + Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); } break; case 'follow': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, $uid); - DI::logger()->debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]); + Logger::debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]); break; case 'mention': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0); $result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_TO, $contact['id'], 0); - DI::logger()->debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); + Logger::debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); break; case 'reply': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0); $result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_COMMENT, $contact['id'], 0); - DI::logger()->debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); + Logger::debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); break; case 'quote': $contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0); $result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_PUSHED, $contact['id'], 0); - DI::logger()->debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); + Logger::debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]); break; default: - DI::logger()->notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]); + Logger::notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]); break; } } @@ -1149,16 +1112,16 @@ function bluesky_fetch_feed(int $uid, string $feed) $languages = $entry->post->record->langs ?? []; if (!Relay::isWantedLanguage($entry->post->record->text, 0, $contact['id'] ?? 0, $languages)) { - DI::logger()->debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]); + Logger::debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]); continue; } $causer = DI::atpActor()->getContactByDID($entry->post->author->did, $uid, 0); $uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], Conversation::PARCEL_CONNECTOR); if (!empty($uri_id)) { $stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl); - DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]); + Logger::debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]); } else { - DI::logger()->notice('Post not found', ['entry' => $entry]); + Logger::notice('Post not found', ['entry' => $entry]); } if (!empty($entry->reason)) { bluesky_process_reason($entry->reason, DI::atpProcessor()->getUri($entry->post), $uid); @@ -1174,14 +1137,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 []; diff --git a/bluesky/bluesky_feed.php b/bluesky/bluesky_feed.php index e4aa3fdc..a20ef1b9 100644 --- a/bluesky/bluesky_feed.php +++ b/bluesky/bluesky_feed.php @@ -1,6 +1,6 @@ debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]); + Logger::debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]); bluesky_fetch_feed($argv[1], $argv[2]); - DI::logger()->debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]); + Logger::debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]); } diff --git a/bluesky/bluesky_notifications.php b/bluesky/bluesky_notifications.php index e1bf2047..1fbc8f67 100644 --- a/bluesky/bluesky_notifications.php +++ b/bluesky/bluesky_notifications.php @@ -1,6 +1,6 @@ notice('importing notifications - start', ['user' => $argv[1]]); + Logger::notice('importing notifications - start', ['user' => $argv[1]]); bluesky_fetch_notifications($argv[1]); - DI::logger()->notice('importing notifications - done', ['user' => $argv[1]]); + Logger::notice('importing notifications - done', ['user' => $argv[1]]); } diff --git a/bluesky/bluesky_timeline.php b/bluesky/bluesky_timeline.php index 37b22d99..fda846ba 100644 --- a/bluesky/bluesky_timeline.php +++ b/bluesky/bluesky_timeline.php @@ -1,6 +1,6 @@ notice('importing timeline - start', ['user' => $argv[1]]); + Logger::notice('importing timeline - start', ['user' => $argv[1]]); bluesky_fetch_timeline($argv[1]); - DI::logger()->notice('importing timeline - done', ['user' => $argv[1]]); + Logger::notice('importing timeline - done', ['user' => $argv[1]]); } diff --git a/buglink/buglink.php b/buglink/buglink.php index b7dd6504..78fb8bef 100644 --- a/buglink/buglink.php +++ b/buglink/buglink.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; diff --git a/calc/calc.php b/calc/calc.php index 76d1805c..a8a340c4 100644 --- a/calc/calc.php +++ b/calc/calc.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; @@ -15,7 +16,7 @@ function calc_install() { function calc_app_menu(array &$b) { - $b['app_menu'][] = ''; + $b['app_menu'][] = ''; } /** @@ -295,7 +296,7 @@ $o .= <<< EOT

Calculator



-
+
@@ -322,7 +323,7 @@ $o .= <<< EOT - + @@ -344,13 +345,13 @@ $o .= <<< EOT - +
diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 7b5f05c0..2116ac44 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -6,8 +6,11 @@ * Author: Fabio */ +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; +use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -26,7 +29,7 @@ function catavatar_install() Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings'); Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post'); - DI::logger()->notice('registered catavatar'); + Logger::notice('registered catavatar'); } /** diff --git a/cld/cld.php b/cld/cld.php index d4fef6c5..5ca4c932 100644 --- a/cld/cld.php +++ b/cld/cld.php @@ -7,6 +7,7 @@ */ use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\DI; function cld_install() @@ -17,17 +18,7 @@ function cld_install() function cld_detect_languages(array &$data) { if (!in_array('cld2', get_loaded_extensions())) { - DI::logger()->warning('CLD2 is not installed.'); - return; - } - - if (!class_exists('CLD2Detector')) { - DI::logger()->warning('CLD2Detector class does not exist.'); - return; - } - - if (!class_exists('CLD2Encoding')) { - DI::logger()->warning('CLD2Encoding class does not exist.'); + Logger::warning('CLD2 is not installed.'); return; } @@ -52,7 +43,7 @@ function cld_detect_languages(array &$data) } if (!$result['is_reliable']) { - DI::logger()->debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); + Logger::debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); if (($original == $detected) && ($data['detected'][$original] < $result['language_probability'] / 100)) { $data['detected'][$original] = $result['language_probability'] / 100; } @@ -62,12 +53,12 @@ function cld_detect_languages(array &$data) $available = array_keys(DI::l10n()->getLanguageCodes()); if (!in_array($detected, $available)) { - DI::logger()->debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); + Logger::debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); return; } if ($original != $detected) { - DI::logger()->debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); + Logger::debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]); } $length = count($data['detected']); diff --git a/convert/UnitConvertor.php b/convert/UnitConvertor.php index a3650e9b..d7933a8f 100644 --- a/convert/UnitConvertor.php +++ b/convert/UnitConvertor.php @@ -169,6 +169,7 @@ class UnitConvertor * @param string name of the source unit from which to convert * @param string name of the target unit to which we are converting * @param integer double precision of the end result + * @return void * @access public */ function convert($value, $from_unit, $to_unit, $precision) @@ -279,4 +280,4 @@ class UnitConvertor } // end func getConvSpecs } // end class UnitConvertor -?> +?> \ No newline at end of file diff --git a/convert/convert.php b/convert/convert.php index 2545974c..57ce6ea8 100644 --- a/convert/convert.php +++ b/convert/convert.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Hook; function convert_install() { @@ -25,7 +26,7 @@ function convert_content() { // @TODO Let's one day rewrite this to a modern composer package include 'UnitConvertor.php'; - $conv = new class('en') extends UnitConvertor + class TP_Converter extends UnitConvertor { public function __construct(string $lang = 'en') { @@ -42,7 +43,7 @@ function convert_content() { private function findBaseUnit($from, $to) { - foreach ($this->bases as $skey => $sval) { + while (list($skey, $sval) = each($this->bases)) { if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) { return $skey; } @@ -62,7 +63,7 @@ function convert_content() { $cells[] = $cell; // We now have the base unit and value now lets produce the table; - foreach ($this->bases[$base_unit] as $val) { + while (list($key, $val) = each($this->bases[$base_unit])) { $cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val; $cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : ''; $cells[] = $cell; @@ -85,7 +86,9 @@ function convert_content() { return $string; } - }; + } + + $conv = new TP_Converter('en'); $conversions = [ 'Temperature' => ['base' => 'Celsius', @@ -173,15 +176,15 @@ function convert_content() { ] ]; - foreach ($conversions as $key => $val) { + while (list($key, $val) = each($conversions)) { $conv->addConversion($val['base'], $val['conv']); $list[$key][] = $val['base']; - foreach ($val['conv'] as $ukey => $uval) { + while (list($ukey, $uval) = each($val['conv'])) { $list[$key][] = $ukey; } } - $o = '

Unit Conversions

'; + $o .= '

Unit Conversions

'; if (isset($_POST['from_unit']) && isset($_POST['value'])) { $o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '

'; @@ -199,9 +202,10 @@ function convert_content() { $o .= ''; $o .= ' - + {{foreach $th_users as $k=>$th}} - {{if $k < 2 || $order_users == $th.1 || ($k==4 && !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.5.1])) }} + {{if $k < 2 || $order_users == $th.1 || ($k==5 && !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1])) }} {{foreach $users as $u}} - - + + @@ -49,7 +63,11 @@ {{/if}} - {{if $order_users == $th_users.5.1}} + {{if $order_users == $th_users.4.1}} + + {{/if}} + + {{if !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1]) }} @@ -121,11 +135,30 @@ {{/foreach}} - + {{/foreach}}
+
+ + +
+
- + {{if $order_users == $th.1}} {{if $order_direction_users == "+"}} ↓ @@ -36,8 +41,17 @@
+ {{if $u.is_deletable}} +
+ + +
+ {{else}} +   + {{/if}} +
{{$u.name}} {{$u.email}}{{$u.login_date}}{{$u.lastitem_date}} + {{if $u.is_deletable}} + + + + + + + {{else}} +   + {{/if}} +
+ {{$pager nofilter}} diff --git a/rendertime/rendertime.php b/rendertime/rendertime.php index 4523d911..731cf003 100644 --- a/rendertime/rendertime.php +++ b/rendertime/rendertime.php @@ -7,6 +7,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\DI; @@ -59,7 +60,7 @@ function rendertime_page_end(string &$o) if (DI::userSession()->isSiteAdmin() && (($_GET['mode'] ?? '') != 'minimal') && !DI::mode()->isMobile() && !DI::mode()->isMobile() && !$ignored) { - $o = $o . '
'; //Add css to header - $css_file = __DIR__ . '/view/' . DI::appHelper()->getCurrentTheme() . '.css'; + $css_file = __DIR__ . '/view/' . DI::app()->getCurrentTheme() . '.css'; if (!file_exists($css_file)) { $css_file = __DIR__ . '/view/default.css'; } @@ -104,7 +105,7 @@ function smileybutton_jot_tool(string &$body) DI::page()->registerStylesheet($css_file); //Get the correct image for the theme - $image = 'addon/smileybutton/view/' . DI::appHelper()->getCurrentTheme() . '.png'; + $image = 'addon/smileybutton/view/' . DI::app()->getCurrentTheme() . '.png'; if (!file_exists($image)) { $image = 'addon/smileybutton/view/default.png'; } diff --git a/smilies_adult/smilies_adult.php b/smilies_adult/smilies_adult.php index 4a80168d..e8af21e1 100644 --- a/smilies_adult/smilies_adult.php +++ b/smilies_adult/smilies_adult.php @@ -4,11 +4,12 @@ * Description: Smily icons that could or should not be included in core * Version: 1.0 * Author: Mike Macgirvin - * + * * This is a template for how to extend the "smily" code. - * + * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; diff --git a/startpage/startpage.php b/startpage/startpage.php index 558af473..e4d80c0c 100644 --- a/startpage/startpage.php +++ b/startpage/startpage.php @@ -7,6 +7,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\DI; diff --git a/statusnet/library/codebirdsn.php b/statusnet/library/codebirdsn.php index bffca163..020c69c4 100644 --- a/statusnet/library/codebirdsn.php +++ b/statusnet/library/codebirdsn.php @@ -31,10 +31,11 @@ use Friendica\Core\System; /** * Define constants */ -defined('CODEBIRD_RETURNFORMAT_ARRAY') or define('CODEBIRD_RETURNFORMAT_ARRAY', 0); -defined('CODEBIRD_RETURNFORMAT_JSON') or define('CODEBIRD_RETURNFORMAT_JSON', 1); -defined('CODEBIRD_RETURNFORMAT_OBJECT') or define('CODEBIRD_RETURNFORMAT_OBJECT', 2); - +$constants = explode(' ', 'OBJECT ARRAY JSON'); +foreach ($constants as $i => $id) { + $id = 'CODEBIRD_RETURNFORMAT_' . $id; + defined($id) or define($id, $i); +} $constants = array( 'CURLE_SSL_CERTPROBLEM' => 58, 'CURLE_SSL_CACERT' => 60, @@ -54,8 +55,6 @@ unset($id); * * @package codebird * @subpackage codebird-php - * - * @method object statuses_update(array $postdata) */ class CodebirdSN { @@ -118,7 +117,7 @@ class CodebirdSN * Returns singleton class instance * Always use this method unless you're working with multiple authenticated users at once * - * @return CodebirdSN The instance + * @return Codebird The instance */ public static function getInstance() { @@ -422,7 +421,6 @@ class CodebirdSN } break; case CODEBIRD_RETURNFORMAT_OBJECT: - /** @var object $reply */ $reply->httpstatus = $httpstatus; if ($httpstatus == 200) { self::setBearerToken($reply->access_token); @@ -493,7 +491,7 @@ class CodebirdSN /** * Generates a (hopefully) unique random string * - * @param int $length The optional length of the string to generate + * @param int optional $length The length of the string to generate * * @return string The random string */ @@ -508,9 +506,9 @@ class CodebirdSN /** * Generates an OAuth signature * - * @param string $httpmethod Usually either 'GET' or 'POST' or 'DELETE' - * @param string $method The API method to call - * @param array $params optional The API call parameters, associative + * @param string $httpmethod Usually either 'GET' or 'POST' or 'DELETE' + * @param string $method The API method to call + * @param array optional $params The API call parameters, associative * * @return string Authorization HTTP header */ @@ -764,13 +762,13 @@ class CodebirdSN * @param string $method The API method to call * @param array $params The parameters to send along * - * @return string + * @return void */ protected function _buildMultipart($method, $params) { // well, files will only work in multipart methods if (! $this->_detectMultipart($method)) { - return ''; + return; } // only check specific parameters @@ -785,19 +783,18 @@ class CodebirdSN ); // method might have files? if (! in_array($method, array_keys($possible_files))) { - return ''; + return; } $possible_files = explode(' ', $possible_files[$method]); - $data = ''; - $multipart_border = '--------------------' . $this->_nonce(); $multipart_request = ''; foreach ($params as $key => $value) { // is it an array? if (is_array($value)) { throw new \Exception('Using URL-encoded parameters is not supported for uploading media.'); + continue; } // check for filenames @@ -874,12 +871,12 @@ class CodebirdSN /** * Calls the API using cURL * - * @param string $httpmethod The HTTP method to use for making the request - * @param string $method The API method to call - * @param string $method_template The templated API method to call - * @param array $params optional The parameters to send along - * @param bool $multipart optional Whether to use multipart/form-data - * @param bool $app_only_auth optional Whether to use app-only bearer authentication + * @param string $httpmethod The HTTP method to use for making the request + * @param string $method The API method to call + * @param string $method_template The templated API method to call + * @param array optional $params The parameters to send along + * @param bool optional $multipart Whether to use multipart/form-data + * @param bool optional $app_only_auth Whether to use app-only bearer authentication * * @return mixed The API reply, encoded in the set return_format */ @@ -921,7 +918,7 @@ class CodebirdSN $authorization = 'Authorization: Bearer ' . self::$_oauth_bearer_token; } $request_headers = array(); - if ($authorization !== '') { + if (isset($authorization)) { $request_headers[] = $authorization; $request_headers[] = 'Expect:'; } @@ -962,7 +959,6 @@ class CodebirdSN $httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); $reply = $this->_parseApiReply($method_template, $reply); if ($this->_return_format == CODEBIRD_RETURNFORMAT_OBJECT) { - /** @var object $reply */ $reply->httpstatus = $httpstatus; } elseif ($this->_return_format == CODEBIRD_RETURNFORMAT_ARRAY) { $reply['httpstatus'] = $httpstatus; @@ -976,7 +972,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) { diff --git a/statusnet/library/statusnetoauth.php b/statusnet/library/statusnetoauth.php index da21be58..c9bb0163 100644 --- a/statusnet/library/statusnetoauth.php +++ b/statusnet/library/statusnetoauth.php @@ -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,14 @@ 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 + * @param string $method + * @param string $host + * @param string $path + * @param array $parameters + * + * @return array|object API results */ - public function http($url, $method, $postfields = NULL) + function http($url, $method, $postfields = NULL) { $this->http_info = []; $ci = curl_init(); diff --git a/statusnet/library/twitteroauth.php b/statusnet/library/twitteroauth.php index bab66195..b33b5f9d 100644 --- a/statusnet/library/twitteroauth.php +++ b/statusnet/library/twitteroauth.php @@ -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); @@ -93,10 +93,10 @@ class TwitterOAuth /** * Get a request_token * - * @param callable $oauth_callback + * @param callback $oauth_callback * @return array */ - public function getRequestToken($oauth_callback = null) + function getRequestToken($oauth_callback = null) { $parameters = []; if (!empty($oauth_callback)) { @@ -112,9 +112,11 @@ class TwitterOAuth /** * Get the authorize URL * + * @param array $token + * @param bool $sign_in_with_tumblr * @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 +139,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 +164,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 +184,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 +201,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 +218,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 +236,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 +260,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 +307,7 @@ class TwitterOAuth * @param string $header * @return int */ - public function getHeader($ch, $header) + function getHeader($ch, $header) { $i = strpos($header, ':'); if (!empty($i)) { diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 8663aaea..4bc32050 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -38,8 +38,10 @@ define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'statusnetoauth.php'; use CodebirdSN\CodebirdSN; +use Friendica\App; use Friendica\Content\Text\Plaintext; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; @@ -57,7 +59,7 @@ function statusnet_install() Hook::register('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork'); Hook::register('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local'); Hook::register('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); - DI::logger()->notice('installed GNU Social'); + Logger::notice('installed GNU Social'); } function statusnet_jot_nets(array &$jotnets_fields) @@ -354,7 +356,7 @@ function statusnet_post_hook(array &$b) return; } - DI::logger()->notice('GNU Socialpost invoked'); + Logger::notice('GNU Socialpost invoked'); DI::pConfig()->load($b['uid'], 'statusnet'); @@ -364,8 +366,6 @@ function statusnet_post_hook(array &$b) $otoken = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthtoken'); $osecret = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthsecret'); - $iscomment = null; - if ($ckey && $csecret && $otoken && $osecret) { $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent @@ -406,7 +406,7 @@ function statusnet_post_hook(array &$b) $cb->setToken($otoken, $osecret); $result = $cb->statuses_update($postdata); //$result = $dent->post('statuses/update', $postdata); - DI::logger()->info('statusnet_post send, result: ' . print_r($result, true) . + Logger::info('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true)); if (!empty($result->source)) { @@ -414,9 +414,9 @@ function statusnet_post_hook(array &$b) } if (!empty($result->error)) { - DI::logger()->notice('Send to GNU Social failed: "' . $result->error . '"'); + Logger::notice('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { - DI::logger()->notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']); + Logger::notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']); Item::update(['extid' => $hostname . '::' . $result->id, 'body' => $result->text], ['id' => $b['id']]); } } diff --git a/tesseract/tesseract.php b/tesseract/tesseract.php index a07c690c..b3e1feb6 100644 --- a/tesseract/tesseract.php +++ b/tesseract/tesseract.php @@ -7,8 +7,8 @@ */ use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\System; -use Friendica\DI; use thiagoalessio\TesseractOCR\TesseractOCR; require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; @@ -17,7 +17,7 @@ function tesseract_install() { Hook::register('ocr-detection', __FILE__, 'tesseract_ocr_detection'); - DI::logger()->notice('installed tesseract'); + Logger::notice('installed tesseract'); } function tesseract_ocr_detection(&$media) @@ -26,13 +26,12 @@ function tesseract_ocr_detection(&$media) try { $languages = $ocr->availableLanguages(); if ($languages) { - /** @phpstan-ignore-next-line ignore call of \thiagoalessio\TesseractOCR\Option::lang() */ $ocr->lang(implode('+', $languages)); } $ocr->tempDir(System::getTempPath()); $ocr->imageData($media['img_str'], strlen($media['img_str'])); $media['description'] = $ocr->run(); } catch (\Throwable $th) { - DI::logger()->info('Error calling TesseractOCR', ['message' => $th->getMessage()]); - } + Logger::info('Error calling TesseractOCR', ['message' => $th->getMessage()]); + } } diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index 90fb5918..55645284 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Search; use Friendica\Database\DBA; @@ -26,7 +27,7 @@ function testdrive_install() function testdrive_load_config(ConfigFileManager $loader) { - DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('testdrive'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); + DI::app()->getConfigCache()->load($loader->loadAddonConfig('testdrive'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); } function testdrive_globaldir_update(array &$b) diff --git a/tictac/tictac.php b/tictac/tictac.php index 082b58c1..0f9f4fb6 100644 --- a/tictac/tictac.php +++ b/tictac/tictac.php @@ -7,6 +7,7 @@ * Status: unsupported */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; @@ -29,12 +30,7 @@ function tictac_module() {} function tictac_content() { - $o = ''; - $dimen = 3; - $handicap = 0; - $mefirst = 0; - $yours = ''; - $mine = ''; + $o = ''; if($_POST['move']) { $handicap = DI::args()->get(1); @@ -49,6 +45,9 @@ function tictac_content() { $handicap = DI::args()->get(1); $dimen = 3; } + else { + $dimen = 3; + } $o .= '

' . DI::l10n()->t('3D Tic-Tac-Toe') . '


'; @@ -71,7 +70,6 @@ class tictac { private $dimen; private $first_move = true; private $handicap = 0; - private $mefirst; private $yours; private $mine; private $winning_play; @@ -163,10 +161,10 @@ class tictac { ]; - function __construct($dimen, $handicap, $mefirst, $yours, $mine) { - $this->dimen = $dimen; - $this->handicap = $handicap ? 1 : 0; - $this->mefirst = $mefirst ? 1 : 0; + function __construct($dimen,$handicap,$mefirst,$yours,$mine) { + $this->dimen = 3; + $this->handicap = (($handicap) ? 1 : 0); + $this->mefirst = (($mefirst) ? 1 : 0); $this->yours = str_replace('XXX','',$yours); $this->mine = $mine; $this->you = $this->parse_moves('you'); @@ -177,7 +175,6 @@ class tictac { } function play() { - $o = ''; if($this->first_move) { if(rand(0,1) == 1) { @@ -229,8 +226,6 @@ class tictac { } function parse_moves($player) { - $str = ''; - if($player == 'me') $str = $this->mine; if($player == 'you') @@ -634,7 +629,7 @@ function winning_move() { function draw_board() { if(! strlen($this->yours)) $this->yours = 'XXX'; - $o = "
handicap}/{$this->mefirst}/{$this->dimen}/{$this->yours}/{$this->mine}\" method=\"post\" />"; + $o .= "handicap}/{$this->mefirst}/{$this->dimen}/{$this->yours}/{$this->mine}\" method=\"post\" />"; for($x = 0; $x < $this->dimen; $x ++) { $o .= ''; for($y = 0; $y < $this->dimen; $y ++) { diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 9e691bf2..ecd6f862 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -14,6 +14,7 @@ use Friendica\Content\Text\NPF; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Config\Util\ConfigFileManager; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\System; @@ -59,12 +60,12 @@ function tumblr_install() Hook::register('check_item_notification', __FILE__, 'tumblr_check_item_notification'); Hook::register('probe_detect', __FILE__, 'tumblr_probe_detect'); Hook::register('item_by_link', __FILE__, 'tumblr_item_by_link'); - DI::logger()->info('installed tumblr'); + Logger::info('installed tumblr'); } function tumblr_load_config(ConfigFileManager $loader) { - DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('tumblr'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); + DI::app()->getConfigCache()->load($loader->loadAddonConfig('tumblr'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); } function tumblr_check_item_notification(array &$notification_data) @@ -120,16 +121,16 @@ function tumblr_item_by_link(array &$hookData) return; } - DI::logger()->debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]); + Logger::debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]); $parameters = ['id' => $matches[2], 'reblog_info' => false, 'notes_info' => false, 'npf' => false]; $result = tumblr_get($hookData['uid'], 'blog/' . $matches[1] . '/posts', $parameters); if ($result->meta->status > 399) { - DI::logger()->notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]); + Logger::notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]); return []; } - DI::logger()->debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]); + Logger::debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]); if (!empty($result->response->posts)) { $hookData['item_id'] = tumblr_process_post($result->response->posts[0], $hookData['uid'], Item::PR_FETCHED); Item::incrementInbound(Protocol::TUMBLR); @@ -158,20 +159,20 @@ function tumblr_follow(array &$hook_data) return; } - DI::logger()->debug('Check if contact is Tumblr', ['url' => $hook_data['url']]); + Logger::debug('Check if contact is Tumblr', ['url' => $hook_data['url']]); $fields = tumblr_get_contact_by_url($hook_data['url'], $uid); if (empty($fields)) { - DI::logger()->debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]); + Logger::debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]); return; } $result = tumblr_post($uid, 'user/follow', ['url' => $fields['url']]); if ($result->meta->status <= 399) { $hook_data['contact'] = $fields; - DI::logger()->debug('Successfully start following', ['url' => $fields['url']]); + Logger::debug('Successfully start following', ['url' => $fields['url']]); } else { - DI::logger()->notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]); + Logger::notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]); } } @@ -391,17 +392,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); } @@ -419,11 +415,11 @@ function tumblr_cron() if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - DI::logger()->notice('poll interval not reached'); + Logger::notice('poll interval not reached'); return; } } - DI::logger()->notice('cron_start'); + Logger::notice('cron_start'); $abandon_days = intval(DI::config()->get('system', 'account_abandon_days')); if ($abandon_days < 1) { @@ -436,30 +432,30 @@ function tumblr_cron() foreach ($pconfigs as $pconfig) { if ($abandon_days != 0) { if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) { - DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); + Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]); continue; } } - DI::logger()->notice('importing timeline - start', ['user' => $pconfig['uid']]); + Logger::notice('importing timeline - start', ['user' => $pconfig['uid']]); tumblr_fetch_dashboard($pconfig['uid'], $last); tumblr_fetch_tags($pconfig['uid'], $last); - DI::logger()->notice('importing timeline - done', ['user' => $pconfig['uid']]); + Logger::notice('importing timeline - done', ['user' => $pconfig['uid']]); } $last_clean = DI::keyValue()->get('tumblr_last_clean'); if (empty($last_clean) || ($last_clean + 86400 < time())) { - DI::logger()->notice('Start contact cleanup'); + Logger::notice('Start contact cleanup'); $contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::TUMBLR, 0, Contact::NOTHING]); while ($contact = DBA::fetch($contacts)) { Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0); } DBA::close($contacts); DI::keyValue()->set('tumblr_last_clean', time()); - DI::logger()->notice('Contact cleanup done'); + Logger::notice('Contact cleanup done'); } - DI::logger()->notice('cron_end'); + Logger::notice('cron_end'); DI::keyValue()->set('tumblr_last_poll', time()); } @@ -482,7 +478,7 @@ function tumblr_hook_fork(array &$b) if (DI::pConfig()->get($post['uid'], 'tumblr', 'import')) { // Don't post if it isn't a reply to a tumblr post if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TUMBLR])) { - DI::logger()->notice('No tumblr parent found', ['item' => $post['id']]); + Logger::notice('No tumblr parent found', ['item' => $post['id']]); $b['execute'] = false; return; } @@ -529,20 +525,20 @@ function tumblr_send(array &$b) } if ($b['gravity'] != Item::GRAVITY_PARENT) { - DI::logger()->debug('Got comment', ['item' => $b]); + Logger::debug('Got comment', ['item' => $b]); $parent = tumblr_get_post_from_uri($b['thr-parent']); if (empty($parent)) { - DI::logger()->notice('No tumblr post', ['thr-parent' => $b['thr-parent']]); + Logger::notice('No tumblr post', ['thr-parent' => $b['thr-parent']]); return; } - DI::logger()->debug('Parent found', ['parent' => $parent]); + Logger::debug('Parent found', ['parent' => $parent]); $page = tumblr_get_page($b['uid']); if ($b['gravity'] == Item::GRAVITY_COMMENT) { - DI::logger()->notice('Commenting is not supported (yet)'); + Logger::notice('Commenting is not supported (yet)'); } else { if (($b['verb'] == Activity::LIKE) && !$b['deleted']) { $params = ['id' => $parent['id'], 'reblog_key' => $parent['reblog_key']]; @@ -566,12 +562,12 @@ function tumblr_send(array &$b) } if ($result->meta->status < 400) { - DI::logger()->info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]); + Logger::info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]); if (!$b['deleted'] && !empty($result->response->id_string)) { Item::update(['extid' => 'tumblr::' . $result->response->id_string], ['guid' => $b['guid']]); } } else { - DI::logger()->notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + Logger::notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); } } return; @@ -669,9 +665,9 @@ function tumblr_send_legacy(array $b) $result = tumblr_post($b['uid'], 'blog/' . $page . '/post', $params); if ($result->meta->status < 400) { - DI::logger()->info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); + Logger::info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); } else { - DI::logger()->notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + Logger::notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); } } @@ -680,7 +676,7 @@ function tumblr_send_npf(array $post): bool $page = tumblr_get_page($post['uid']); if (empty($page)) { - DI::logger()->notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]); + Logger::notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]); // "true" is returned, since the legacy function will fail as well. return true; } @@ -711,10 +707,10 @@ function tumblr_send_npf(array $post): bool $result = tumblr_post($post['uid'], 'blog/' . $page . '/posts', $params); if ($result->meta->status < 400) { - DI::logger()->info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); + Logger::info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); return true; } else { - DI::logger()->notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + Logger::notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); return false; } } @@ -747,25 +743,14 @@ 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)) { - DI::logger()->debug('Tag post imported', ['tag' => $tag, 'id' => $id]); + Logger::debug('Tag post imported', ['tag' => $tag, 'id' => $id]); $post = Post::selectFirst(['uri-id'], ['id' => $id]); $stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $tag); - DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]); + Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]); Item::incrementInbound(Protocol::TUMBLR); } } @@ -790,8 +775,8 @@ 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; + Logger::notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]); + return []; } if (empty($dashboard->response->posts)) { @@ -803,7 +788,7 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll) $last = $post->id; } - DI::logger()->debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]); + Logger::debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]); tumblr_process_post($post, $uid, Item::PR_NONE, $last_poll); Item::incrementInbound(Protocol::TUMBLR); @@ -1078,7 +1063,7 @@ function tumblr_get_type_replacement(array $data, string $plink): string } default: - DI::logger()->notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]); + Logger::notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]); $body = ''; } @@ -1133,9 +1118,9 @@ function tumblr_get_contact(stdClass $blog, int $uid): array $cid = $contact['id']; Contact::update($fields, ['id' => $cid], true); } - DI::logger()->debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); + Logger::debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); } else { - DI::logger()->debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); + Logger::debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); } if (!empty($avatar)) { @@ -1171,13 +1156,13 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra ]; if (!$update) { - DI::logger()->debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]); + Logger::debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]); return $fields; } $info = tumblr_get($uid, 'blog/' . $blog->uuid . '/info'); if ($info->meta->status > 399) { - DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]); + Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]); return $fields; } Item::incrementInbound(Protocol::TUMBLR); @@ -1199,7 +1184,7 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra $fields['header'] = $info->response->blog->theme->header_image_focused; - DI::logger()->debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]); + Logger::debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]); return $fields; } @@ -1241,7 +1226,7 @@ function tumblr_get_blogs(int $uid): array { $userinfo = tumblr_get($uid, 'user/info'); if ($userinfo->meta->status > 399) { - DI::logger()->notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]); + Logger::notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]); return []; } @@ -1297,15 +1282,15 @@ function tumblr_get_contact_by_url(string $url, int $uid): ?array return null; } - DI::logger()->debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]); + Logger::debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]); $info = tumblr_get($uid, 'blog/' . $blog . '/info'); if ($info->meta->status > 399) { - DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]); + Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]); return null; } - DI::logger()->debug('Got data', ['blog' => $blog, 'meta' => $info->meta]); + Logger::debug('Got data', ['blog' => $blog, 'meta' => $info->meta]); Item::incrementInbound(Protocol::TUMBLR); $baseurl = 'https://tumblr.com'; @@ -1434,7 +1419,7 @@ function tumblr_get_token(int $uid, string $code = ''): string $refresh_token = DI::pConfig()->get($uid, 'tumblr', 'refresh_token'); if (empty($code) && !empty($access_token) && ($expires_at > (time()))) { - DI::logger()->debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + Logger::debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); return $access_token; } @@ -1446,11 +1431,11 @@ function tumblr_get_token(int $uid, string $code = ''): string if (empty($refresh_token) && empty($code)) { $result = tumblr_exchange_token($uid); if (empty($result->refresh_token)) { - DI::logger()->info('Invalid result while exchanging token', ['uid' => $uid]); + Logger::info('Invalid result while exchanging token', ['uid' => $uid]); return ''; } $expires_at = time() + $result->expires_in; - DI::logger()->debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + Logger::debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); } else { if (!empty($code)) { $parameters['code'] = $code; @@ -1462,18 +1447,18 @@ function tumblr_get_token(int $uid, string $code = ''): string $curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters); if (!$curlResult->isSuccess()) { - DI::logger()->info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]); + Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]); return ''; } $result = json_decode($curlResult->getBodyString()); if (empty($result)) { - DI::logger()->info('Invalid result when updating token', ['uid' => $uid]); + Logger::info('Invalid result when updating token', ['uid' => $uid]); return ''; } $expires_at = time() + $result->expires_in; - DI::logger()->debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + Logger::debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); } DI::pConfig()->set($uid, 'tumblr', 'access_token', $result->access_token); @@ -1517,7 +1502,7 @@ function tumblr_exchange_token(int $uid): stdClass $response = $client->post('oauth2/exchange', ['auth' => 'oauth']); return json_decode($response->getBody()->getContents()); } catch (RequestException $exception) { - DI::logger()->notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); + Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); return new stdClass; } } diff --git a/twitter/twitter.php b/twitter/twitter.php index a9654405..10f8a2fb 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -38,6 +38,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\Worker; use Friendica\DI; @@ -66,7 +67,7 @@ function twitter_install() function twitter_load_config(ConfigFileManager $loader) { - DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('twitter'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); + DI::app()->getConfigCache()->load($loader->loadAddonConfig('twitter'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); } function twitter_jot_nets(array &$jotnets_fields) @@ -216,7 +217,7 @@ function twitter_post_hook(array &$b) $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b)); - DI::logger()->notice('twitter post invoked', ['id' => $b['id'], 'guid' => $b['guid']]); + Logger::notice('twitter post invoked', ['id' => $b['id'], 'guid' => $b['guid']]); DI::pConfig()->load($b['uid'], 'twitter'); @@ -226,17 +227,17 @@ function twitter_post_hook(array &$b) $access_secret = DI::pConfig()->get($b['uid'], 'twitter', 'access_secret'); if (empty($api_key) || empty($api_secret) || empty($access_token) || empty($access_secret)) { - DI::logger()->info('Missing keys, secrets or tokens.'); + Logger::info('Missing keys, secrets or tokens.'); return; } $msgarr = Plaintext::getPost($b, 280, true, BBCode::TWITTER); - DI::logger()->debug('Got plaintext', ['id' => $b['id'], 'message' => $msgarr]); + Logger::debug('Got plaintext', ['id' => $b['id'], 'message' => $msgarr]); $media_ids = []; if (!empty($msgarr['images']) || !empty($msgarr['remote_images'])) { - DI::logger()->info('Got images', ['id' => $b['id'], 'images' => $msgarr['images'] ?? []]); + Logger::info('Got images', ['id' => $b['id'], 'images' => $msgarr['images'] ?? []]); $retrial = Worker::getRetrial(); if ($retrial > 4) { @@ -249,7 +250,7 @@ function twitter_post_hook(array &$b) try { $media_ids[] = twitter_upload_image($b['uid'], $image, $retrial); } catch (RequestException $exception) { - DI::logger()->warning('Error while uploading image', ['image' => $image, 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); + Logger::warning('Error while uploading image', ['image' => $image, 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); Worker::defer(); return; } @@ -258,13 +259,13 @@ function twitter_post_hook(array &$b) $in_reply_to_tweet_id = 0; - DI::logger()->debug('Post message', ['id' => $b['id'], 'parts' => count($msgarr['parts'])]); + Logger::debug('Post message', ['id' => $b['id'], 'parts' => count($msgarr['parts'])]); foreach ($msgarr['parts'] as $key => $part) { try { $id = twitter_post_status($b['uid'], $part, $media_ids, $in_reply_to_tweet_id); - DI::logger()->info('twitter_post send', ['part' => $key, 'id' => $b['id'], 'result' => $id]); + Logger::info('twitter_post send', ['part' => $key, 'id' => $b['id'], 'result' => $id]); } catch (RequestException $exception) { - DI::logger()->warning('Error while posting message', ['part' => $key, 'id' => $b['id'], 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); + Logger::warning('Error while posting message', ['part' => $key, 'id' => $b['id'], 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); $status = [ 'code' => $exception->getCode(), 'reason' => $exception->getResponse()->getReasonPhrase(), @@ -318,9 +319,9 @@ function twitter_upload_image(int $uid, array $image, int $retrial) $picturedata = $picture->asString(); $new_size = strlen($picturedata); - DI::logger()->info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); + Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); $media = twitter_post($uid, 'https://upload.twitter.com/1.1/media/upload.json', 'form_params', ['media' => base64_encode($picturedata)]); - DI::logger()->info('Uploading done', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); + Logger::info('Uploading done', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); if (isset($media->media_id_string)) { $media_id = $media->media_id_string; @@ -333,10 +334,10 @@ function twitter_upload_image(int $uid, array $image, int $retrial) ] ]; $ret = twitter_post($uid, 'https://upload.twitter.com/1.1/media/metadata/create.json', 'json', $data); - DI::logger()->info('Metadata create', ['uid' => $uid, 'data' => $data, 'return' => $ret]); + Logger::info('Metadata create', ['uid' => $uid, 'data' => $data, 'return' => $ret]); } } else { - DI::logger()->error('Failed upload', ['uid' => $uid, 'size' => strlen($picturedata), 'image' => $image['url'], 'return' => $media]); + Logger::error('Failed upload', ['uid' => $uid, 'size' => strlen($picturedata), 'image' => $image['url'], 'return' => $media]); throw new Exception('Failed upload of ' . $image['url']); } @@ -372,7 +373,7 @@ function twitter_post(int $uid, string $url, string $type, array $data): stdClas DI::pConfig()->set($uid, 'twitter', 'last_status', $status); $content = json_decode($body) ?? new stdClass; - DI::logger()->debug('Success', ['content' => $content]); + Logger::debug('Success', ['content' => $content]); return $content; } @@ -401,7 +402,7 @@ function twitter_test_connection(int $uid) 'content' => $response->getBody()->getContents() ]; DI::pConfig()->set(1, 'twitter', 'last_status', $status); - DI::logger()->info('Test successful', ['uid' => $uid]); + Logger::info('Test successful', ['uid' => $uid]); } catch (RequestException $exception) { $status = [ 'code' => $exception->getCode(), @@ -409,6 +410,6 @@ function twitter_test_connection(int $uid) 'content' => $exception->getMessage() ]; DI::pConfig()->set(1, 'twitter', 'last_status', $status); - DI::logger()->info('Test failed', ['uid' => $uid]); + Logger::info('Test failed', ['uid' => $uid]); } } diff --git a/unicode_smilies/unicode_smilies.php b/unicode_smilies/unicode_smilies.php index 8ec47175..8d55c4be 100644 --- a/unicode_smilies/unicode_smilies.php +++ b/unicode_smilies/unicode_smilies.php @@ -7,6 +7,7 @@ * Author: Matthias Ebers */ +use Friendica\App; use Friendica\Content\Smilies; use Friendica\Core\Hook; diff --git a/viewsrc/viewsrc.php b/viewsrc/viewsrc.php index bd07b541..c4d21ccb 100644 --- a/viewsrc/viewsrc.php +++ b/viewsrc/viewsrc.php @@ -7,6 +7,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; diff --git a/webdav_storage/src/WebDavConfig.php b/webdav_storage/src/WebDavConfig.php index 320b06a2..2236e97a 100644 --- a/webdav_storage/src/WebDavConfig.php +++ b/webdav_storage/src/WebDavConfig.php @@ -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 = [ diff --git a/webdav_storage/webdav_storage.php b/webdav_storage/webdav_storage.php index fd2eb0d9..adcbea29 100644 --- a/webdav_storage/webdav_storage.php +++ b/webdav_storage/webdav_storage.php @@ -8,10 +8,11 @@ use Friendica\Addon\webdav_storage\src\WebDav; use Friendica\Addon\webdav_storage\src\WebDavConfig; +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; -function webdav_storage_install() +function webdav_storage_install($a) { Hook::register('storage_instance' , __FILE__, 'webdav_storage_instance'); Hook::register('storage_config' , __FILE__, 'webdav_storage_config'); diff --git a/webrtc/webrtc.php b/webrtc/webrtc.php index e5d4ce6e..e142b374 100644 --- a/webrtc/webrtc.php +++ b/webrtc/webrtc.php @@ -7,6 +7,7 @@ * Author: Tobias Diekershoff */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\DI; diff --git a/wppost/wppost.php b/wppost/wppost.php index de216806..dba738de 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -9,6 +9,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -256,13 +257,11 @@ function wppost_send(array &$b) EOT; - DI::logger()->debug('wppost: data: ' . $xml); - - $x = ''; + Logger::debug('wppost: data: ' . $xml); if ($wp_blog !== 'test') { $x = DI::httpClient()->post($wp_blog, $xml)->getBodyString(); } - DI::logger()->info('posted to wordpress: ' . $x); + Logger::info('posted to wordpress: ' . (($x) ? $x : '')); } }