From f0999a1e46e655a287cc4dbd68136dcc1dc6d3b1 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 1 Jan 2025 20:06:43 +0100 Subject: [PATCH 01/47] [CI] Fix releaser --- .woodpecker/.code_standards_check.yml | 2 +- .woodpecker/.continuous-deployment.yml | 2 +- .woodpecker/.messages.po_check.yml | 2 +- .woodpecker/.phpunit.yml | 2 +- .woodpecker/.releaser.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.woodpecker/.code_standards_check.yml b/.woodpecker/.code_standards_check.yml index fb5be33c..50872d4c 100644 --- a/.woodpecker/.code_standards_check.yml +++ b/.woodpecker/.code_standards_check.yml @@ -1,6 +1,6 @@ skip_clone: true -pipeline: +steps: clone_friendica_base: image: alpine/git commands: diff --git a/.woodpecker/.continuous-deployment.yml b/.woodpecker/.continuous-deployment.yml index 4d3bc5b7..6b41deae 100644 --- a/.woodpecker/.continuous-deployment.yml +++ b/.woodpecker/.continuous-deployment.yml @@ -5,7 +5,7 @@ labels: skip_clone: true -pipeline: +steps: clone_friendica_base: image: alpine/git commands: diff --git a/.woodpecker/.messages.po_check.yml b/.woodpecker/.messages.po_check.yml index aa40ab4e..e0239dcd 100644 --- a/.woodpecker/.messages.po_check.yml +++ b/.woodpecker/.messages.po_check.yml @@ -1,6 +1,6 @@ skip_clone: true -pipeline: +steps: clone_friendica_base: image: alpine/git commands: diff --git a/.woodpecker/.phpunit.yml b/.woodpecker/.phpunit.yml index 6acbf787..8b840f80 100644 --- a/.woodpecker/.phpunit.yml +++ b/.woodpecker/.phpunit.yml @@ -17,7 +17,7 @@ labels: skip_clone: true -pipeline: +steps: clone_friendica_base: image: alpine/git commands: diff --git a/.woodpecker/.releaser.yml b/.woodpecker/.releaser.yml index f12697b9..2d880a6b 100644 --- a/.woodpecker/.releaser.yml +++ b/.woodpecker/.releaser.yml @@ -5,7 +5,7 @@ labels: skip_clone: true -pipeline: +steps: clone_friendica_base: image: alpine/git commands: From e6d92cc94a56660207e08095865195da97d403a5 Mon Sep 17 00:00:00 2001 From: Art4 Date: Wed, 5 Feb 2025 15:11:14 +0000 Subject: [PATCH 02/47] Rewrite Monolog factory to implement LoggerFactory --- .../{Monolog.php => MonologFactory.php} | 41 ++++++++++++++----- monolog/static/dependencies.config.php | 7 +--- monolog/static/strategies.config.php | 26 ------------ 3 files changed, 33 insertions(+), 41 deletions(-) rename monolog/src/Factory/{Monolog.php => MonologFactory.php} (51%) delete mode 100644 monolog/static/strategies.config.php diff --git a/monolog/src/Factory/Monolog.php b/monolog/src/Factory/MonologFactory.php similarity index 51% rename from monolog/src/Factory/Monolog.php rename to monolog/src/Factory/MonologFactory.php index c5c69824..ede4d5b2 100644 --- a/monolog/src/Factory/Monolog.php +++ b/monolog/src/Factory/MonologFactory.php @@ -4,7 +4,8 @@ namespace Friendica\Addon\monolog\src\Factory; use Friendica\Addon\monolog\src\Monolog\IntrospectionProcessor; use Friendica\Core\Config\Capability\IManageConfigValues; -use Friendica\Core\Logger\Factory\AbstractLoggerTypeFactory; +use Friendica\Core\Logger\Capability\IHaveCallIntrospections; +use Friendica\Core\Logger\Factory\LoggerFactory; use Monolog\Formatter\LineFormatter; use Monolog\Handler\StreamHandler; use Monolog\Logger; @@ -16,32 +17,52 @@ use Psr\Log\LogLevel; require_once __DIR__ . '/../../vendor/autoload.php'; -class Monolog extends AbstractLoggerTypeFactory +final class MonologFactory implements LoggerFactory { - public function create(IManageConfigValues $config, string $loglevel = null): LoggerInterface + private IHaveCallIntrospections $introspection; + + private IManageConfigValues $config; + + /** + * @param string $channel The channel for the logger + */ + 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 { $loggerTimeZone = new \DateTimeZone('UTC'); - $logger = new Logger($this->channel); + $logger = new Logger($logChannel); $logger->setTimezone($loggerTimeZone); $logger->pushProcessor(new PsrLogMessageProcessor()); $logger->pushProcessor(new ProcessIdProcessor()); $logger->pushProcessor(new UidProcessor()); $logger->pushProcessor(new IntrospectionProcessor($this->introspection, LogLevel::DEBUG)); - $logfile = $config->get('system', 'logfile'); + $logfile = $this->config->get('system', 'logfile'); // just add a stream in case it's either writable or not file if (is_writable($logfile)) { - $loglevel = $loglevel ?? static::mapLegacyConfigDebugLevel($config->get('system', 'loglevel')); - $loglevel = Logger::toMonologLevel($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); diff --git a/monolog/static/dependencies.config.php b/monolog/static/dependencies.config.php index e3066594..75ea8df7 100644 --- a/monolog/static/dependencies.config.php +++ b/monolog/static/dependencies.config.php @@ -20,10 +20,7 @@ */ return [ - \Monolog\Logger::class => [ - 'instanceOf' => \Friendica\Addon\monolog\src\Factory\Monolog::class, - 'call' => [ - ['create', [], \Dice\Dice::CHAIN_CALL], - ], + \Friendica\Core\Logger\Factory\LoggerFactory::class => [ + 'instanceOf' => \Friendica\Addon\monolog\src\Factory\MonologFactory::class, ], ]; diff --git a/monolog/static/strategies.config.php b/monolog/static/strategies.config.php deleted file mode 100644 index 87153839..00000000 --- a/monolog/static/strategies.config.php +++ /dev/null @@ -1,26 +0,0 @@ -. - * - */ - -return [ - \Psr\Log\LoggerInterface::class => [ - \Monolog\Logger::class => ['monolog'], - ], -]; From 0bafcc78f827b4bc1f064a0cc73a3c87700ced63 Mon Sep 17 00:00:00 2001 From: Art4 Date: Wed, 5 Feb 2025 15:20:06 +0000 Subject: [PATCH 03/47] Add READMD.md for monolog addon --- monolog/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 monolog/README.md diff --git a/monolog/README.md b/monolog/README.md new file mode 100644 index 00000000..e5a139e9 --- /dev/null +++ b/monolog/README.md @@ -0,0 +1,14 @@ +# 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. + +Set `system.logger_config` to `monolog` in your `config/local.config.php` file to activate Monolog. + +``` +// in config/local.config.php +// ... + 'system' => [ + 'logger_config' => 'monolog', + ] +// ... +``` From f7ec934893bda2ac130dd5e6867ed564a074a943 Mon Sep 17 00:00:00 2001 From: Art4 Date: Wed, 5 Feb 2025 15:20:22 +0000 Subject: [PATCH 04/47] bump version to 1.1 --- monolog/monolog.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monolog/monolog.php b/monolog/monolog.php index b13efff9..f194aac4 100644 --- a/monolog/monolog.php +++ b/monolog/monolog.php @@ -1,7 +1,7 @@ Date: Wed, 5 Feb 2025 15:32:24 +0000 Subject: [PATCH 05/47] Remove wrong phpdoc --- monolog/src/Factory/MonologFactory.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/monolog/src/Factory/MonologFactory.php b/monolog/src/Factory/MonologFactory.php index ede4d5b2..e0c11e13 100644 --- a/monolog/src/Factory/MonologFactory.php +++ b/monolog/src/Factory/MonologFactory.php @@ -23,9 +23,6 @@ final class MonologFactory implements LoggerFactory private IManageConfigValues $config; - /** - * @param string $channel The channel for the logger - */ public function __construct(IHaveCallIntrospections $introspection, IManageConfigValues $config) { $this->introspection = $introspection; From ed75360eb4f573c961dc1e1eca58bed7b2ba37e1 Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 6 Feb 2025 09:27:22 +0000 Subject: [PATCH 06/47] Setting the logger_config config is no longer needed --- monolog/README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/monolog/README.md b/monolog/README.md index e5a139e9..74ade29d 100644 --- a/monolog/README.md +++ b/monolog/README.md @@ -3,12 +3,3 @@ A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)). There are just Friendica additions inside the src directory. Set `system.logger_config` to `monolog` in your `config/local.config.php` file to activate Monolog. - -``` -// in config/local.config.php -// ... - 'system' => [ - 'logger_config' => 'monolog', - ] -// ... -``` From 5701853d295f08c93cdc5f2b0e807bab85d4cddd Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 6 Feb 2025 11:35:10 +0000 Subject: [PATCH 07/47] Remove config docs, format syntax --- monolog/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/monolog/README.md b/monolog/README.md index 74ade29d..efb7959a 100644 --- a/monolog/README.md +++ b/monolog/README.md @@ -1,5 +1,4 @@ # 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. - -Set `system.logger_config` to `monolog` in your `config/local.config.php` file to activate Monolog. +A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)). +There are just Friendica additions inside the src directory. From 373c30b5d0fc84dd1cb238bcf9dc2cd381d2c5d6 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 6 Feb 2025 20:50:40 -0500 Subject: [PATCH 08/47] [tumblr] Ward against unexpected response format in tumblr_fetch_tags() - Adress https://github.com/friendica/friendica/issues/14646#issuecomment-2628090487 --- tumblr/tumblr.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 819c0ca5..f2e2d78d 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -743,6 +743,12 @@ function tumblr_fetch_tags(int $uid, int $last_poll) foreach (DI::pConfig()->get($uid, 'tumblr', 'tags') ?? [] as $tag) { $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)) { From 07008af9c15bbe2ed431f97e9429b03642ec8820 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Feb 2025 06:12:49 +0000 Subject: [PATCH 09/47] Bluesky: Avoid duplicated reshares --- bluesky/bluesky.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php index 7f6bb9e7..ba80660c 100644 --- a/bluesky/bluesky.php +++ b/bluesky/bluesky.php @@ -1005,6 +1005,10 @@ 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']; From 859d92ab02ce74718b10853f84522d84f85b35b6 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Feb 2025 05:48:09 +0000 Subject: [PATCH 10/47] Improve accessibility with showmore and rendertime --- rendertime/rendertime.php | 2 +- showmore_dyn/showmore_dyn.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rendertime/rendertime.php b/rendertime/rendertime.php index 1cce5b1b..4523d911 100644 --- a/rendertime/rendertime.php +++ b/rendertime/rendertime.php @@ -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 . '
' . DI::l10n()->t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s", + $o = $o . '