From 4f1a4c4c8a73a3ab4d866f2d47a5d516e872869a Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 21 Nov 2024 09:56:56 +0000 Subject: [PATCH 01/11] Replace App with AppHelper --- mod/photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/photos.php b/mod/photos.php index abd62989a2..3afca2db2a 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -49,7 +49,7 @@ function photos_init() Nav::setSelected('home'); if (DI::args()->getArgc() > 1) { - $owner = Profile::load(DI::app(), DI::args()->getArgv()[1], false); + $owner = Profile::load(DI::appHelper(), DI::args()->getArgv()[1], false); if (!isset($owner['account_removed']) || $owner['account_removed']) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } From 702abb28302151d65fbf7d4d71f202a1cc59876b Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 21 Nov 2024 10:12:27 +0000 Subject: [PATCH 02/11] Remove unused calls of DI::app() --- src/Module/Directory.php | 1 - src/Module/Invite.php | 4 +--- src/Module/NoScrape.php | 2 -- src/Module/Profile/Schedule.php | 2 -- src/Object/Post.php | 3 +-- 5 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Module/Directory.php b/src/Module/Directory.php index d173be6d96..ad95b49524 100644 --- a/src/Module/Directory.php +++ b/src/Module/Directory.php @@ -27,7 +27,6 @@ class Directory extends BaseModule { protected function content(array $request = []): string { - $app = DI::app(); $config = DI::config(); if (($config->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) || diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 92b777b641..bb8f94c9a5 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -30,7 +30,6 @@ class Invite extends BaseModule self::checkFormSecurityTokenRedirectOnError('/', 'send_invite'); - $app = DI::app(); $config = DI::config(); $max_invites = intval($config->get('system', 'max_invites')); @@ -117,7 +116,6 @@ class Invite extends BaseModule throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); } - $app = DI::app(); $config = DI::config(); $inviteOnly = false; @@ -142,7 +140,7 @@ class Invite extends BaseModule if (Register::getPolicy() === Register::CLOSED) { return DI::l10n()->t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); } else { - $linkTxt = DI::l10n()->t('To accept this invitation, please visit and register at %s.', DI::baseUrl() . '/register' + $linkTxt = DI::l10n()->t('To accept this invitation, please visit and register at %s.', DI::baseUrl() . '/register' . "\r\n" . "\r\n" . DI::l10n()->t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks.')); } } diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index 9ea239e0ea..71a48e6f04 100644 --- a/src/Module/NoScrape.php +++ b/src/Module/NoScrape.php @@ -22,8 +22,6 @@ class NoScrape extends BaseModule { protected function rawContent(array $request = []) { - $a = DI::app(); - if (isset($this->parameters['nick'])) { // Get infos about a specific nick (public) $which = $this->parameters['nick']; diff --git a/src/Module/Profile/Schedule.php b/src/Module/Profile/Schedule.php index ae64d695c9..212c02b78a 100644 --- a/src/Module/Profile/Schedule.php +++ b/src/Module/Profile/Schedule.php @@ -42,8 +42,6 @@ class Schedule extends BaseProfile throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); } - $a = DI::app(); - $o = self::getTabsHTML('schedule', true, DI::userSession()->getLocalUserNickname(), false); $schedule = []; diff --git a/src/Object/Post.php b/src/Object/Post.php index 450af95c84..ead75ef60b 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -726,7 +726,7 @@ class Post $title = DI::l10n()->t('Commented by: %s', $actors); $icon = ['fa' => 'fa-commenting', 'icon' => 'icon-commenting']; break; - + default: $title = DI::l10n()->t('Reacted with %s by: %s', $element['emoji'], $actors); $icon = []; @@ -1180,7 +1180,6 @@ class Post */ protected function checkWallToWall() { - $a = DI::app(); $conv = $this->getThread(); $this->wall_to_wall = false; From d7c25ce0b5479e5e611399023c419261418399d4 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 23 Nov 2024 07:41:34 +0000 Subject: [PATCH 03/11] Remove unused DI::app() call --- src/Security/BasicAuth.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Security/BasicAuth.php b/src/Security/BasicAuth.php index 5de8e8780e..c5da5b9f72 100644 --- a/src/Security/BasicAuth.php +++ b/src/Security/BasicAuth.php @@ -107,7 +107,6 @@ class BasicAuth */ private static function getUserIdByAuth(bool $do_login = true):int { - $a = DI::app(); self::$current_user_id = 0; // workaround for HTTP-auth in CGI mode From 7dbf1bb8bb6b64b85ed0089bb3b4099890548af4 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 23 Nov 2024 08:18:24 +0000 Subject: [PATCH 04/11] remove unused call of DI::app() --- src/Module/Admin/DBSync.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php index 3bf0ea5423..62b6db7eea 100644 --- a/src/Module/Admin/DBSync.php +++ b/src/Module/Admin/DBSync.php @@ -20,8 +20,6 @@ class DBSync extends BaseAdmin { parent::content(); - $a = DI::app(); - $action = $this->parameters['action'] ?? ''; $update = $this->parameters['update'] ?? 0; From 76d25a27b4bbb336b676229777d2ef9531441e8c Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 23 Nov 2024 08:26:59 +0000 Subject: [PATCH 05/11] Remove requirement for App class in legacy mods --- mod/item.php | 3 +-- mod/lostpass.php | 5 ++--- mod/notes.php | 11 ++++++----- mod/photos.php | 2 -- mod/update_contact.php | 3 +-- mod/update_notes.php | 5 ++--- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/mod/item.php b/mod/item.php index decb957bcc..c47dbac44d 100644 --- a/mod/item.php +++ b/mod/item.php @@ -16,7 +16,6 @@ * information. */ -use Friendica\AppHelper; use Friendica\Content\Conversation; use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; @@ -330,7 +329,7 @@ function item_post_return($baseurl, $return_path) System::jsonExit($json); } -function item_content(AppHelper $appHelper) +function item_content() { if (!DI::userSession()->isAuthenticated()) { throw new HTTPException\UnauthorizedException(); diff --git a/mod/lostpass.php b/mod/lostpass.php index 940546d951..d62fd5f5aa 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -7,7 +7,6 @@ * */ -use Friendica\AppHelper; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -15,7 +14,7 @@ use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; -function lostpass_post(AppHelper $a) +function lostpass_post() { $loginame = trim($_POST['login-name']); if (!$loginame) { @@ -78,7 +77,7 @@ function lostpass_post(AppHelper $a) DI::baseUrl()->redirect(); } -function lostpass_content(AppHelper $appHelper) +function lostpass_content() { if (DI::args()->getArgc() > 1) { $pwdreset_token = DI::args()->getArgv()[1]; diff --git a/mod/notes.php b/mod/notes.php index b61cb97850..478e4c4aca 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -7,7 +7,6 @@ * */ -use Friendica\AppHelper; use Friendica\Content\Conversation; use Friendica\Content\Nav; use Friendica\Content\Pager; @@ -17,7 +16,7 @@ use Friendica\Model\Item; use Friendica\Model\Post; use Friendica\Module\BaseProfile; -function notes_init(AppHelper $appHelper) +function notes_init() { if (! DI::userSession()->getLocalUserId()) { return; @@ -27,8 +26,10 @@ function notes_init(AppHelper $appHelper) } -function notes_content(AppHelper $appHelper, bool $update = false) +function notes_content(bool $update = false) { + $contactId = DI::appHelper()->getContactId(); + if (!DI::userSession()->getLocalUserId()) { DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; @@ -46,11 +47,11 @@ function notes_content(AppHelper $appHelper, bool $update = false) 'acl_data' => '', ]; - $o .= DI::conversation()->statusEditor($x, $appHelper->getContactId()); + $o .= DI::conversation()->statusEditor($x, $contactId); } $condition = ['uid' => DI::userSession()->getLocalUserId(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT, - 'contact-id'=> $appHelper->getContactId()]; + 'contact-id'=> $contactId]; if (DI::mode()->isMobile()) { $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network', diff --git a/mod/photos.php b/mod/photos.php index 3afca2db2a..c9fa60bca0 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -28,9 +28,7 @@ use Friendica\Model\Tag; use Friendica\Model\User; use Friendica\Module\BaseProfile; use Friendica\Network\HTTPException; -use Friendica\Network\Probe; use Friendica\Protocol\Activity; -use Friendica\Protocol\ActivityNamespace; use Friendica\Security\Security; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; diff --git a/mod/update_contact.php b/mod/update_contact.php index 30212e5589..adfbc513d7 100644 --- a/mod/update_contact.php +++ b/mod/update_contact.php @@ -9,14 +9,13 @@ * */ -use Friendica\AppHelper; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Post; use Friendica\Model\Contact; -function update_contact_content(AppHelper $appHelper) +function update_contact_content() { if (!empty(DI::args()->get(1)) && !empty($_GET['force'])) { $contact = DBA::selectFirst('account-user-view', ['pid', 'deleted'], ['id' => DI::args()->get(1)]); diff --git a/mod/update_notes.php b/mod/update_notes.php index 93b5e95207..06bbac6930 100644 --- a/mod/update_notes.php +++ b/mod/update_notes.php @@ -8,12 +8,11 @@ * AJAX synchronisation of notes page */ -use Friendica\AppHelper; use Friendica\Core\System; require_once 'mod/notes.php'; -function update_notes_content(AppHelper $appHelper) +function update_notes_content() { $profile_uid = intval($_GET['p']); @@ -27,7 +26,7 @@ function update_notes_content(AppHelper $appHelper) * */ - $text = notes_content($appHelper, $profile_uid); + $text = notes_content($profile_uid); System::htmlUpdateExit($text); } From 5f829ac1cd1998ad549e528e374dbbd513851f1c Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 23 Nov 2024 08:27:40 +0000 Subject: [PATCH 06/11] Remove DI::app() call from LegacyModule --- src/LegacyModule.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/LegacyModule.php b/src/LegacyModule.php index 8d12abd444..c4d70ee9f2 100644 --- a/src/LegacyModule.php +++ b/src/LegacyModule.php @@ -78,8 +78,7 @@ class LegacyModule extends BaseModule $function_name = $this->moduleName . '_' . $function_suffix; if (\function_exists($function_name)) { - $a = DI::app(); - return $function_name($a) ?? ''; + return $function_name() ?? ''; } return ''; From f93915075e7bbd30cb2b88773fc0ed19f84394aa Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 23 Nov 2024 08:38:37 +0000 Subject: [PATCH 07/11] remove requirement for DI::app() in addon_install() see https://github.com/friendica/friendica-addons/pull/1364 --- src/Core/Addon.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Core/Addon.php b/src/Core/Addon.php index e202d130ec..8ed5cc8512 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -155,7 +155,12 @@ class Addon @include_once($addon_file_path); if (function_exists($addon . '_install')) { $func = $addon . '_install'; - $func(DI::app()); + + // Addon webdav_storage has an unused but required parameter. + // @TODO: Remove $param after the required parameter is removed. + // See https://github.com/friendica/friendica-addons/pull/1364 + $param = null; + $func($param); } DI::config()->set('addons', $addon, [ From 3819ec9dd18a42033dccf95ce6722959253c854f Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 23 Nov 2024 12:18:07 +0000 Subject: [PATCH 08/11] Remove call for DI::app() --- src/Module/Profile/Media.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Module/Profile/Media.php b/src/Module/Profile/Media.php index a9e0dd9cf1..489d93eeaa 100644 --- a/src/Module/Profile/Media.php +++ b/src/Module/Profile/Media.php @@ -7,7 +7,9 @@ namespace Friendica\Module\Profile; -use Friendica\App; +use Friendica\App\Arguments; +use Friendica\App\BaseURL; +use Friendica\AppHelper; use Friendica\Core\L10n; use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\DI; @@ -21,23 +23,37 @@ use Psr\Log\LoggerInterface; class Media extends BaseProfile { + /** + * @var AppHelper + */ + private $appHelper; + /** * @var IHandleUserSessions */ private $userSession; - public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, $server, array $parameters = []) - { + public function __construct( + L10n $l10n, + BaseURL $baseUrl, + Arguments $args, + AppHelper $appHelper, + LoggerInterface $logger, + Profiler $profiler, + Response $response, + IHandleUserSessions $userSession, + $server, + array $parameters = [] + ) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + $this->appHelper = $appHelper; $this->userSession = $userSession; } protected function content(array $request = []): string { - $a = DI::app(); - - $profile = ProfileModel::load($a, $this->parameters['nickname']); + $profile = ProfileModel::load($this->appHelper, $this->parameters['nickname']); if (empty($profile)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } From 5b281d22ed2244cf26e36988102260091f347492 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 23 Nov 2024 12:25:03 +0000 Subject: [PATCH 09/11] Remove parameter App from addons __addon_admin_post() functions --- src/Module/Admin/Addons/Details.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index f332ffb898..c381212e64 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -31,7 +31,7 @@ class Details extends BaseAdmin self::checkFormSecurityTokenRedirectOnError($redirect, 'admin_addons_details'); $func = $addon . '_addon_admin_post'; - $func(DI::app()); + $func(); } } From a0da648214bbfdc2ddfcad9e9a9b4c261e567416 Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 28 Nov 2024 08:17:04 +0000 Subject: [PATCH 10/11] remove unused call for DI::app() --- src/Module/Admin/Addons/Details.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index c381212e64..9eb1c0cf40 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -42,8 +42,6 @@ class Details extends BaseAdmin { parent::content(); - $a = DI::app(); - $addons_admin = Addon::getAdminList(); $addon = Strings::sanitizeFilePathItem($this->parameters['addon']); From 8f66cbee9121264466822e221f70aaaf527f2939 Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 28 Nov 2024 08:26:26 +0000 Subject: [PATCH 11/11] remove unused parameter --- src/Core/Addon.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Core/Addon.php b/src/Core/Addon.php index 8ed5cc8512..1119f2d392 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -155,12 +155,7 @@ class Addon @include_once($addon_file_path); if (function_exists($addon . '_install')) { $func = $addon . '_install'; - - // Addon webdav_storage has an unused but required parameter. - // @TODO: Remove $param after the required parameter is removed. - // See https://github.com/friendica/friendica-addons/pull/1364 - $param = null; - $func($param); + $func(); } DI::config()->set('addons', $addon, [