From c363b45e0d210f87a9ea23a0ab384165822b475b Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 31 Jan 2025 07:55:53 +0000 Subject: [PATCH 1/9] Hard deprecate all Logger methods --- src/Core/Logger.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Core/Logger.php b/src/Core/Logger.php index a87be78633..a050f7e245 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -8,7 +8,6 @@ namespace Friendica\Core; use Friendica\DI; -use Friendica\Core\Logger\Type\WorkerLogger; use Psr\Log\LoggerInterface; /** @@ -18,10 +17,7 @@ use Psr\Log\LoggerInterface; */ class Logger { - /** - * @return LoggerInterface|WorkerLogger - */ - private static function getInstance() + private static function getInstance(): LoggerInterface { return DI::logger(); } @@ -38,6 +34,8 @@ class Logger */ public static function emergency(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->emergency($message, $context); } @@ -55,6 +53,8 @@ class Logger */ public static function alert(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->alert($message, $context); } @@ -71,6 +71,8 @@ class Logger */ public static function critical(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->critical($message, $context); } @@ -86,6 +88,8 @@ class Logger */ public static function error(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->error($message, $context); } @@ -103,6 +107,8 @@ class Logger */ public static function warning(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->warning($message, $context); } @@ -117,6 +123,8 @@ class Logger */ public static function notice(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->notice($message, $context); } @@ -134,6 +142,8 @@ class Logger */ public static function info(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->info($message, $context); } @@ -148,6 +158,8 @@ class Logger */ public static function debug(string $message, array $context = []) { + trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + self::getInstance()->debug($message, $context); } } From c206e60ad49b8dd2a555b2b17fceee45eb20b8b1 Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 31 Jan 2025 07:56:30 +0000 Subject: [PATCH 2/9] Hard deprecate DI::workerLogger(), mark DI::loggerManager() as internal --- src/DI.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/DI.php b/src/DI.php index c9c973f722..405735e168 100644 --- a/src/DI.php +++ b/src/DI.php @@ -332,9 +332,16 @@ abstract class DI */ public static function workerLogger() { + trigger_error('`' . __METHOD__ . '()` is deprecated since 2025.02 and will be removed after 5 months, use `DI::logger()` instead.', E_USER_DEPRECATED); + return self::$dice->create(Core\Logger\Type\WorkerLogger::class); } + /** + * @internal Only for use in Friendica\Core\Worker class + * + * @see Friendica\Core\Worker::execFunction() + */ public static function loggerManager(): LoggerManager { return self::$dice->create(LoggerManager::class); From 02cde27a122edb2adc5ba8fbde490ff82245c43a Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 31 Jan 2025 15:35:07 +0000 Subject: [PATCH 3/9] Mute calles of trigger_error() --- src/Core/Logger.php | 16 ++++++++-------- src/DI.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Core/Logger.php b/src/Core/Logger.php index a050f7e245..e10b9f2ef4 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -34,7 +34,7 @@ class Logger */ public static function emergency(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->emergency($message, $context); } @@ -53,7 +53,7 @@ class Logger */ public static function alert(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->alert($message, $context); } @@ -71,7 +71,7 @@ class Logger */ public static function critical(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->critical($message, $context); } @@ -88,7 +88,7 @@ class Logger */ public static function error(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->error($message, $context); } @@ -107,7 +107,7 @@ class Logger */ public static function warning(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->warning($message, $context); } @@ -123,7 +123,7 @@ class Logger */ public static function notice(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->notice($message, $context); } @@ -142,7 +142,7 @@ class Logger */ public static function info(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->info($message, $context); } @@ -158,7 +158,7 @@ class Logger */ public static function debug(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->debug($message, $context); } diff --git a/src/DI.php b/src/DI.php index 405735e168..94bb4c308a 100644 --- a/src/DI.php +++ b/src/DI.php @@ -332,7 +332,7 @@ abstract class DI */ public static function workerLogger() { - trigger_error('`' . __METHOD__ . '()` is deprecated since 2025.02 and will be removed after 5 months, use `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('`' . __METHOD__ . '()` is deprecated since 2025.02 and will be removed after 5 months, use `DI::logger()` instead.', E_USER_DEPRECATED); return self::$dice->create(Core\Logger\Type\WorkerLogger::class); } From af96a957cd1964ce7fdff68dfb43f2acbd2581f8 Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 31 Jan 2025 15:36:08 +0000 Subject: [PATCH 4/9] Log trigger_error() of deprecated code --- src/Core/Logger/Handler/ErrorHandler.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Core/Logger/Handler/ErrorHandler.php b/src/Core/Logger/Handler/ErrorHandler.php index 90c08eacd6..2d311b5150 100644 --- a/src/Core/Logger/Handler/ErrorHandler.php +++ b/src/Core/Logger/Handler/ErrorHandler.php @@ -197,7 +197,7 @@ class ErrorHandler E_STRICT => LogLevel::NOTICE, E_RECOVERABLE_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::NOTICE, - E_USER_DEPRECATED => LogLevel::NOTICE, + E_USER_DEPRECATED => LogLevel::WARNING, ]; } @@ -248,17 +248,29 @@ class ErrorHandler */ public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool { - if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) { + if ($this->handleOnlyReportedErrors && !(error_reporting() & $code) && $code !== E_USER_DEPRECATED) { return true; } + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + + array_shift($trace); // Exclude handleError from trace + + if ($code === E_USER_DEPRECATED && $trace[0]['function'] ?? '' === 'trigger_error') { + $calledPlace = $trace[1] ?? []; + + $message .= sprintf( + ' It was called in `%s`%s.', + $calledPlace['file'], + isset($calledPlace['line']) ? ' in line ' . $calledPlace['line'] : '' + ); + } + // fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) { $level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL; $this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]); } else { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - array_shift($trace); // Exclude handleError from trace $this->lastFatalTrace = $trace; } From 3e43b27e834e04317a7754f77e2cf1d4fdde8478 Mon Sep 17 00:00:00 2001 From: Julien Desrosiers Date: Sat, 1 Feb 2025 00:35:58 -0500 Subject: [PATCH 5/9] Making addon/ folder exist since it's now mandatory --- addon/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 addon/.gitkeep diff --git a/addon/.gitkeep b/addon/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From f135e18522ccf0f7f42333a2846cc16d2e353ee1 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 1 Feb 2025 09:21:00 +0000 Subject: [PATCH 6/9] deprecations should be muted trigger_error calls --- doc/Developers-Intro.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/Developers-Intro.md b/doc/Developers-Intro.md index 99e84739d0..8540109f85 100644 --- a/doc/Developers-Intro.md +++ b/doc/Developers-Intro.md @@ -210,9 +210,9 @@ If the deprecated code is no longer used inside Friendica or the official addons The code MUST NOT be deleted. Starting from the next release, it MUST be stay for at least 5 months. Hard deprecated code COULD remain longer than 5 months, depending on when a release appears. -Addon developer MUST NOT consider that they have more than 5 months to adjust their code. +Addon developer SHOULD NOT consider that they have more than 5 months to adjust their code. -Hard deprecation code means that the code triggers an `E_USER_DEPRECATION` error if it is called. +Hard deprecation code means that the code triggers a muted `E_USER_DEPRECATION` error if it is called. For instance with the deprecated class `Friendica\Core\Logger` the call of every method should trigger an error: ```php @@ -224,7 +224,7 @@ For instance with the deprecated class `Friendica\Core\Logger` the call of every class Logger { public static function info(string $message, array $context = []) { - trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.05 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); + @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.05 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); self::getInstance()->info($message, $context); } @@ -233,7 +233,7 @@ class Logger { } ``` -This way the maintainer or users of addons will be notified that the addon will stop working in one of the next releases. +This way the maintainer or users of addons will be notified in the logs that the addon will stop working in one of the next releases. The addon maintainer now has at least 5 months or at least one release to fix the deprecations. Please note that the deprecation message contains the release that will be released next. From 16b268f0cab971343e8f87b66ca81809442b3abe Mon Sep 17 00:00:00 2001 From: Julien Desrosiers Date: Sat, 1 Feb 2025 12:08:31 -0500 Subject: [PATCH 7/9] .gitkeep to allow addon(s) folders to exist by default --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 3a673832bd..ac58473600 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,9 @@ venv/ #ignore addons directory /addons /addon +# except those: +!/addons/.gitkeep +!/addon/.gitkeep #ignore base .htaccess /.htaccess From f1bf64a8ff57d7ae03727c23086c7f8103640cd8 Mon Sep 17 00:00:00 2001 From: Julien Desrosiers Date: Sat, 1 Feb 2025 13:21:36 -0500 Subject: [PATCH 8/9] If we follow the installation doc, it says to clone the addon repo inside this dir which would fail if said dir exist and is not empty. --- .gitignore | 4 ---- addon/.gitkeep | 0 doc/Install.md | 20 +++++++++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 addon/.gitkeep diff --git a/.gitignore b/.gitignore index ac58473600..bfc5094d9a 100644 --- a/.gitignore +++ b/.gitignore @@ -72,11 +72,7 @@ venv/ /.idea #ignore addons directory -/addons /addon -# except those: -!/addons/.gitkeep -!/addon/.gitkeep #ignore base .htaccess /.htaccess diff --git a/addon/.gitkeep b/addon/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/doc/Install.md b/doc/Install.md index 68bc934776..cb4b2de33d 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -76,14 +76,6 @@ This makes the software much easier to update. The Linux commands to clone the repository into a directory "mywebsite" would be git clone https://github.com/friendica/friendica.git -b stable mywebsite - cd mywebsite - bin/composer.phar install --no-dev - -Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case *www-data* - - mkdir -p view/smarty3 - chown www-data:www-data view/smarty3 - chmod 775 view/smarty3 Get the addons by going into your website folder. @@ -91,7 +83,17 @@ Get the addons by going into your website folder. Clone the addon repository (separately): - git clone https://github.com/friendica/friendica-addons.git -b stable addon + git clone https://github.com/friendica/friendica-addons.git -b stable addon + +Install the dependencies: + + bin/composer.phar install --no-dev + +Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case *www-data* + + mkdir -p view/smarty3 + chown www-data:www-data view/smarty3 + chmod 775 view/smarty3 If you want to use the development version of Friendica you can switch to the develop branch in the repository by running From 410fe155072f0942276b1d1cc0e592962b5a7967 Mon Sep 17 00:00:00 2001 From: Hannes Heute Date: Sat, 1 Feb 2025 20:45:15 +0100 Subject: [PATCH 9/9] [frio] Small CSS fix for circle-update-wrapper shortmode headings --- view/theme/frio/css/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 9ae95c4765..85acd0a3bc 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -2708,10 +2708,10 @@ ul li:hover .contact-wrapper .contact-action-link:hover { #circle-update-wrapper .shortmode .contact-entry-desc { font-size: 12px !important; } -#circle-update-wrapper .shortmode .contact-entry-desc h1.media-heading { +#circle-update-wrapper .shortmode .contact-entry-desc h4.media-heading { margin: 0; } -#circle-update-wrapper .shortmode .contact-entry-desc h1.media-heading a { +#circle-update-wrapper .shortmode .contact-entry-desc h4.media-heading a { font-size: 13px !important; white-space: nowrap; }