From 2e4d654c0a241891a8a64ebd3e49ebde42fad8cc Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 28 Nov 2021 13:44:42 +0100 Subject: [PATCH] Make $_REQUEST processing independent of sub-calls - Move HTTPInputData::process() into App::runFrontend() - Pass $_REQUEST (including processed Input) to every Module method - Delete $_POST parameters at Module post() calls because of $_REQUEST --- src/App.php | 7 ++++- src/BaseModule.php | 29 +++++++++++-------- src/Capabilities/ICanHandleRequests.php | 5 ++-- src/LegacyModule.php | 4 +-- src/Module/Admin/Addons/Details.php | 2 +- src/Module/Admin/Blocklist/Contact.php | 2 +- src/Module/Admin/Blocklist/Server/Add.php | 2 +- src/Module/Admin/Blocklist/Server/Index.php | 2 +- src/Module/Admin/Features.php | 2 +- src/Module/Admin/Item/Delete.php | 3 +- src/Module/Admin/Logs/Settings.php | 3 +- src/Module/Admin/Site.php | 2 +- src/Module/Admin/Storage.php | 2 +- src/Module/Admin/Themes/Embed.php | 2 +- src/Module/Admin/Tos.php | 2 +- src/Module/Admin/Users/Active.php | 2 +- src/Module/Admin/Users/Blocked.php | 2 +- src/Module/Admin/Users/Create.php | 2 +- src/Module/Admin/Users/Deleted.php | 2 +- src/Module/Admin/Users/Index.php | 2 +- src/Module/Admin/Users/Pending.php | 2 +- src/Module/Api/ApiResponse.php | 6 ++-- src/Module/Api/Friendica/Index.php | 4 +-- src/Module/Api/Mastodon/Accounts/Block.php | 2 +- src/Module/Api/Mastodon/Accounts/Follow.php | 2 +- src/Module/Api/Mastodon/Accounts/Mute.php | 2 +- src/Module/Api/Mastodon/Accounts/Note.php | 2 +- src/Module/Api/Mastodon/Accounts/Unblock.php | 2 +- src/Module/Api/Mastodon/Accounts/Unfollow.php | 2 +- src/Module/Api/Mastodon/Accounts/Unmute.php | 2 +- .../Mastodon/Accounts/UpdateCredentials.php | 9 ++---- src/Module/Api/Mastodon/Apps.php | 2 +- src/Module/Api/Mastodon/Conversations.php | 2 +- .../Api/Mastodon/Conversations/Read.php | 2 +- src/Module/Api/Mastodon/Filters.php | 4 +-- src/Module/Api/Mastodon/FollowRequests.php | 2 +- src/Module/Api/Mastodon/Lists.php | 6 ++-- src/Module/Api/Mastodon/Lists/Accounts.php | 8 ++--- src/Module/Api/Mastodon/Markers.php | 4 +-- src/Module/Api/Mastodon/Media.php | 4 +-- .../Api/Mastodon/Notifications/Clear.php | 2 +- .../Api/Mastodon/Notifications/Dismiss.php | 2 +- src/Module/Api/Mastodon/PushSubscription.php | 6 ++-- src/Module/Api/Mastodon/ScheduledStatuses.php | 6 ++-- src/Module/Api/Mastodon/Statuses.php | 4 +-- src/Module/Api/Mastodon/Statuses/Bookmark.php | 2 +- .../Api/Mastodon/Statuses/Favourite.php | 2 +- src/Module/Api/Mastodon/Statuses/Mute.php | 2 +- src/Module/Api/Mastodon/Statuses/Pin.php | 2 +- src/Module/Api/Mastodon/Statuses/Reblog.php | 2 +- .../Api/Mastodon/Statuses/Unbookmark.php | 2 +- .../Api/Mastodon/Statuses/Unfavourite.php | 2 +- src/Module/Api/Mastodon/Statuses/Unmute.php | 2 +- src/Module/Api/Mastodon/Statuses/Unpin.php | 2 +- src/Module/Api/Mastodon/Statuses/Unreblog.php | 2 +- src/Module/Api/Mastodon/Unimplemented.php | 18 ++++++------ src/Module/BaseApi.php | 20 +++++-------- src/Module/Contact.php | 2 +- src/Module/Contact/Advanced.php | 2 +- src/Module/Contact/Poke.php | 2 +- src/Module/Contact/Profile.php | 2 +- src/Module/Contact/Revoke.php | 2 +- src/Module/DFRN/Notify.php | 2 +- src/Module/Debug/Localtime.php | 2 +- src/Module/Delegation.php | 2 +- src/Module/Diaspora/Receive.php | 2 +- src/Module/FollowConfirm.php | 4 +-- src/Module/FriendSuggest.php | 2 +- src/Module/Group.php | 4 +-- src/Module/HTTPException/PageNotFound.php | 4 +-- src/Module/Install.php | 2 +- src/Module/Invite.php | 2 +- src/Module/Item/Compose.php | 2 +- src/Module/Notifications/Notification.php | 2 +- src/Module/OAuth/Acknowledge.php | 2 +- src/Module/OAuth/Revoke.php | 2 +- src/Module/OAuth/Token.php | 2 +- src/Module/Profile/Schedule.php | 2 +- src/Module/Register.php | 2 +- src/Module/RemoteFollow.php | 2 +- src/Module/Security/Login.php | 2 +- src/Module/Security/TwoFactor/Recovery.php | 2 +- src/Module/Security/TwoFactor/Verify.php | 2 +- src/Module/Settings/Delegation.php | 2 +- src/Module/Settings/Display.php | 2 +- src/Module/Settings/Profile/Index.php | 2 +- src/Module/Settings/Profile/Photo/Crop.php | 2 +- src/Module/Settings/Profile/Photo/Index.php | 2 +- src/Module/Settings/TwoFactor/AppSpecific.php | 2 +- src/Module/Settings/TwoFactor/Index.php | 2 +- src/Module/Settings/TwoFactor/Recovery.php | 2 +- src/Module/Settings/TwoFactor/Trusted.php | 2 +- src/Module/Settings/TwoFactor/Verify.php | 2 +- .../Module/Api/Friendica/Photo/DeleteTest.php | 4 +-- .../Api/Friendica/Photoalbum/DeleteTest.php | 2 +- .../Api/Friendica/Photoalbum/UpdateTest.php | 2 +- 96 files changed, 156 insertions(+), 156 deletions(-) diff --git a/src/App.php b/src/App.php index c80518c192..b8b7fb99fe 100644 --- a/src/App.php +++ b/src/App.php @@ -40,6 +40,7 @@ use Friendica\Model\Profile; use Friendica\Module\Special\HTTPException as ModuleHTTPException; use Friendica\Network\HTTPException; use Friendica\Util\DateTimeFormat; +use Friendica\Util\HTTPInputData; use Friendica\Util\HTTPSignature; use Friendica\Util\Profiler; use Friendica\Util\Strings; @@ -702,8 +703,12 @@ class App $module = $router->getModule(); } + // Processes data from GET requests + $httpinput = HTTPInputData::process(); + $input = array_merge($httpinput['variables'], $httpinput['files'], $request ?? $_REQUEST); + // Let the module run it's internal process (init, get, post, ...) - $response = $module->run($_POST, $_REQUEST); + $response = $module->run($input); if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) { $page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig); } else { diff --git a/src/BaseModule.php b/src/BaseModule.php index a74c027131..7dcd821e49 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -128,8 +128,10 @@ abstract class BaseModule implements ICanHandleRequests * * Extend this method if the module is supposed to process DELETE requests. * Doesn't display any content + * + * @param string[] $request The $_REQUEST content */ - protected function delete() + protected function delete(array $request = []) { } @@ -138,8 +140,10 @@ abstract class BaseModule implements ICanHandleRequests * * Extend this method if the module is supposed to process PATCH requests. * Doesn't display any content + * + * @param string[] $request The $_REQUEST content */ - protected function patch() + protected function patch(array $request = []) { } @@ -150,10 +154,9 @@ abstract class BaseModule implements ICanHandleRequests * Doesn't display any content * * @param string[] $request The $_REQUEST content - * @param string[] $post The $_POST content * */ - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { // $this->baseUrl->redirect('module'); } @@ -163,15 +166,17 @@ abstract class BaseModule implements ICanHandleRequests * * Extend this method if the module is supposed to process PUT requests. * Doesn't display any content + * + * @param string[] $request The $_REQUEST content */ - protected function put() + protected function put(array $request = []) { } /** * {@inheritDoc} */ - public function run(array $post = [], array $request = []): ResponseInterface + public function run(array $request = []): ResponseInterface { // @see https://github.com/tootsuite/mastodon/blob/c3aef491d66aec743a3a53e934a494f653745b61/config/initializers/cors.rb if (substr($request['pagename'] ?? '', 0, 12) == '.well-known/') { @@ -208,17 +213,17 @@ abstract class BaseModule implements ICanHandleRequests switch ($this->server['REQUEST_METHOD'] ?? Router::GET) { case Router::DELETE: - $this->delete(); + $this->delete($request); break; case Router::PATCH: - $this->patch(); + $this->patch($request); break; case Router::POST: - Core\Hook::callAll($this->args->getModuleName() . '_mod_post', $post); - $this->post($request, $post); + Core\Hook::callAll($this->args->getModuleName() . '_mod_post', $request); + $this->post($request); break; case Router::PUT: - $this->put(); + $this->put($request); break; } @@ -231,7 +236,7 @@ abstract class BaseModule implements ICanHandleRequests $arr = ['content' => '']; Hook::callAll(static::class . '_mod_content', $arr); $this->response->addContent($arr['content']); - $this->response->addContent($this->content($_REQUEST)); + $this->response->addContent($this->content($request)); } catch (HTTPException $e) { $this->response->addContent((new ModuleHTTPException())->content($e)); } finally { diff --git a/src/Capabilities/ICanHandleRequests.php b/src/Capabilities/ICanHandleRequests.php index dc608ebbb7..b30be1a1d2 100644 --- a/src/Capabilities/ICanHandleRequests.php +++ b/src/Capabilities/ICanHandleRequests.php @@ -11,12 +11,11 @@ use Psr\Http\Message\ResponseInterface; interface ICanHandleRequests { /** - * @param array $post The $_POST content (in case of POST) - * @param array $request The $_REQUEST content (in case of GET, POST) + * @param array $request The $_REQUEST content (including content from the PHP input stream) * * @return ResponseInterface responding to the request handling * * @throws HTTPException\InternalServerErrorException */ - public function run(array $post = [], array $request = []): ResponseInterface; + public function run(array $request = []): ResponseInterface; } diff --git a/src/LegacyModule.php b/src/LegacyModule.php index 8c24617c83..17853015e6 100644 --- a/src/LegacyModule.php +++ b/src/LegacyModule.php @@ -73,9 +73,9 @@ class LegacyModule extends BaseModule return $this->runModuleFunction('content'); } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { - parent::post($post); + parent::post($request); $this->runModuleFunction('post'); } diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index 90abc54b57..7a84409fa5 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -30,7 +30,7 @@ use Friendica\Util\Strings; class Details extends BaseAdmin { - public function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index 1263b7c3f8..71a0739976 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -32,7 +32,7 @@ use Friendica\Util\Network; class Contact extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Blocklist/Server/Add.php b/src/Module/Admin/Blocklist/Server/Add.php index b7397d22b1..ad8f148a11 100644 --- a/src/Module/Admin/Blocklist/Server/Add.php +++ b/src/Module/Admin/Blocklist/Server/Add.php @@ -32,7 +32,7 @@ use GuzzleHttp\Psr7\Uri; class Add extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Blocklist/Server/Index.php b/src/Module/Admin/Blocklist/Server/Index.php index 3be131fac3..c7e82f7668 100644 --- a/src/Module/Admin/Blocklist/Server/Index.php +++ b/src/Module/Admin/Blocklist/Server/Index.php @@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin; class Index extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Features.php b/src/Module/Admin/Features.php index f5fea300fc..546b1d6c69 100644 --- a/src/Module/Admin/Features.php +++ b/src/Module/Admin/Features.php @@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin; class Features extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Item/Delete.php b/src/Module/Admin/Item/Delete.php index 4ae0563e56..f3415a2621 100644 --- a/src/Module/Admin/Item/Delete.php +++ b/src/Module/Admin/Item/Delete.php @@ -25,11 +25,10 @@ use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\Item; use Friendica\Module\BaseAdmin; -use Friendica\Util\Strings; class Delete extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Logs/Settings.php b/src/Module/Admin/Logs/Settings.php index 6f09b2957b..aeec02d591 100644 --- a/src/Module/Admin/Logs/Settings.php +++ b/src/Module/Admin/Logs/Settings.php @@ -24,12 +24,11 @@ namespace Friendica\Module\Admin\Logs; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Module\BaseAdmin; -use Friendica\Util\Strings; use Psr\Log\LogLevel; class Settings extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 71f042f8d7..ceeee8da15 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -43,7 +43,7 @@ require_once __DIR__ . '/../../../boot.php'; class Site extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Storage.php b/src/Module/Admin/Storage.php index 796f88bb32..33457d452d 100644 --- a/src/Module/Admin/Storage.php +++ b/src/Module/Admin/Storage.php @@ -31,7 +31,7 @@ use Friendica\Util\Strings; class Storage extends BaseAdmin { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 1eb3018d56..faa8061c57 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -50,7 +50,7 @@ class Embed extends BaseAdmin } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Tos.php b/src/Module/Admin/Tos.php index 684eb4f763..d064093e63 100644 --- a/src/Module/Admin/Tos.php +++ b/src/Module/Admin/Tos.php @@ -45,7 +45,7 @@ class Tos extends BaseAdmin $this->config = $config; } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Users/Active.php b/src/Module/Admin/Users/Active.php index fa8847d0ff..b5596c65fb 100644 --- a/src/Module/Admin/Users/Active.php +++ b/src/Module/Admin/Users/Active.php @@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers; class Active extends BaseUsers { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Users/Blocked.php b/src/Module/Admin/Users/Blocked.php index 8a8c105fa8..5f8f61f609 100644 --- a/src/Module/Admin/Users/Blocked.php +++ b/src/Module/Admin/Users/Blocked.php @@ -31,7 +31,7 @@ use Friendica\Util\Temporal; class Blocked extends BaseUsers { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Users/Create.php b/src/Module/Admin/Users/Create.php index 644b934342..8c3fa30767 100644 --- a/src/Module/Admin/Users/Create.php +++ b/src/Module/Admin/Users/Create.php @@ -28,7 +28,7 @@ use Friendica\Module\Admin\BaseUsers; class Create extends BaseUsers { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Users/Deleted.php b/src/Module/Admin/Users/Deleted.php index 4ebe153b87..61c681e308 100644 --- a/src/Module/Admin/Users/Deleted.php +++ b/src/Module/Admin/Users/Deleted.php @@ -33,7 +33,7 @@ use Friendica\Util\Temporal; class Deleted extends BaseUsers { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Users/Index.php b/src/Module/Admin/Users/Index.php index d0f29ee398..c74071562d 100644 --- a/src/Module/Admin/Users/Index.php +++ b/src/Module/Admin/Users/Index.php @@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers; class Index extends BaseUsers { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Admin/Users/Pending.php b/src/Module/Admin/Users/Pending.php index 2917bc2607..0d8fd25ce6 100644 --- a/src/Module/Admin/Users/Pending.php +++ b/src/Module/Admin/Users/Pending.php @@ -33,7 +33,7 @@ use Friendica\Util\Temporal; class Pending extends BaseUsers { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAdminAccess(); diff --git a/src/Module/Api/ApiResponse.php b/src/Module/Api/ApiResponse.php index 863e1d21d2..8f49313839 100644 --- a/src/Module/Api/ApiResponse.php +++ b/src/Module/Api/ApiResponse.php @@ -8,7 +8,6 @@ use Friendica\Core\L10n; use Friendica\Module\Response; use Friendica\Util\Arrays; use Friendica\Util\DateTimeFormat; -use Friendica\Util\HTTPInputData; use Friendica\Util\XML; use Psr\Log\LoggerInterface; use Friendica\Factory\Api\Twitter\User as TwitterUser; @@ -226,11 +225,12 @@ class ApiResponse extends Response * Quit execution with the message that the endpoint isn't implemented * * @param string $method + * @param array $request (optional) The request content of the current call for later analysis * * @return void * @throws \Exception */ - public function unsupported(string $method = 'all') + public function unsupported(string $method = 'all', array $request = []) { $path = $this->args->getQueryString(); $this->logger->info('Unimplemented API call', @@ -238,7 +238,7 @@ class ApiResponse extends Response 'method' => $method, 'path' => $path, 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '', - 'request' => HTTPInputData::process() + 'request' => $request, ]); $error = $this->l10n->t('API endpoint %s %s is not implemented', strtoupper($method), $path); $error_description = $this->l10n->t('The API endpoint is currently not implemented but might be in the future.'); diff --git a/src/Module/Api/Friendica/Index.php b/src/Module/Api/Friendica/Index.php index 53229b98e7..e48d719c5d 100644 --- a/src/Module/Api/Friendica/Index.php +++ b/src/Module/Api/Friendica/Index.php @@ -32,12 +32,12 @@ require_once __DIR__ . '/../../../../include/api.php'; */ class Index extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); } - protected function delete() + protected function delete(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); } diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index a4e0bb88b7..9b237cde88 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Block extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Follow.php b/src/Module/Api/Mastodon/Accounts/Follow.php index 443ac25402..03162652ef 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Follow extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Mute.php b/src/Module/Api/Mastodon/Accounts/Mute.php index 824277348f..858dc8d84d 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Mute extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index eb97a8856d..429581ccce 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Note extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Unblock.php b/src/Module/Api/Mastodon/Accounts/Unblock.php index 23d78e739b..fd1fdb38a9 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Unblock extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index 81f919a694..67193f8d83 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Unfollow extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Unmute.php b/src/Module/Api/Mastodon/Accounts/Unmute.php index c9673b98c3..a21f55dee0 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Unmute extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php index 8d9fb48695..e560d4c4f4 100644 --- a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php @@ -24,22 +24,19 @@ namespace Friendica\Module\Api\Mastodon\Accounts; use Friendica\App\Router; use Friendica\Core\Logger; use Friendica\Module\BaseApi; -use Friendica\Util\HTTPInputData; /** * @see https://docs.joinmastodon.org/methods/accounts/ */ class UpdateCredentials extends BaseApi { - protected function patch() + protected function patch(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - $data = HTTPInputData::process(); + Logger::info('Patch data', ['data' => $request]); - Logger::info('Patch data', ['data' => $data]); - - $this->response->unsupported(Router::PATCH); + $this->response->unsupported(Router::PATCH, $request); } } diff --git a/src/Module/Api/Mastodon/Apps.php b/src/Module/Api/Mastodon/Apps.php index 3f24810bbf..30ea29ac30 100644 --- a/src/Module/Api/Mastodon/Apps.php +++ b/src/Module/Api/Mastodon/Apps.php @@ -35,7 +35,7 @@ class Apps extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $request = $this->getRequest([ 'client_name' => '', diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index 125e13e609..6cc364c9cb 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Conversations extends BaseApi { - protected function delete() + protected function delete(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index a70cdfb00f..d5e87a6c9f 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Read extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Filters.php b/src/Module/Api/Mastodon/Filters.php index b48b38b6e4..781e0341a3 100644 --- a/src/Module/Api/Mastodon/Filters.php +++ b/src/Module/Api/Mastodon/Filters.php @@ -31,11 +31,11 @@ use Friendica\Module\BaseApi; */ class Filters extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); - $this->response->unsupported(Router::POST); + $this->response->unsupported(Router::POST, $request); } /** diff --git a/src/Module/Api/Mastodon/FollowRequests.php b/src/Module/Api/Mastodon/FollowRequests.php index eead8f96c1..b131debd60 100644 --- a/src/Module/Api/Mastodon/FollowRequests.php +++ b/src/Module/Api/Mastodon/FollowRequests.php @@ -42,7 +42,7 @@ class FollowRequests extends BaseApi * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow */ - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index 3ab41329cd..12f6ea011e 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -31,7 +31,7 @@ use Friendica\Model\Group; */ class Lists extends BaseApi { - protected function delete() + protected function delete(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -51,7 +51,7 @@ class Lists extends BaseApi System::jsonExit([]); } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -74,7 +74,7 @@ class Lists extends BaseApi System::jsonExit(DI::mstdnList()->createFromGroupId($id)); } - public function put() + public function put(array $request = []) { $request = $this->getRequest([ 'title' => '', // The title of the list to be updated. diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index 9ab676af02..96b6f5bc93 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -34,14 +34,14 @@ use Friendica\Module\BaseApi; */ class Accounts extends BaseApi { - protected function delete() + protected function delete(array $request = []) { - $this->response->unsupported(Router::DELETE); + $this->response->unsupported(Router::DELETE, $request); } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { - $this->response->unsupported(Router::POST); + $this->response->unsupported(Router::POST, $request); } /** diff --git a/src/Module/Api/Mastodon/Markers.php b/src/Module/Api/Mastodon/Markers.php index 9f208e9262..2f74c2d103 100644 --- a/src/Module/Api/Mastodon/Markers.php +++ b/src/Module/Api/Mastodon/Markers.php @@ -31,11 +31,11 @@ use Friendica\Module\BaseApi; */ class Markers extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); - $this->response->unsupported(Router::POST); + $this->response->unsupported(Router::POST, $request); } /** diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index 24d2a3bf8c..b6ba366613 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Media extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -53,7 +53,7 @@ class Media extends BaseApi System::jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id'])); } - public function put() + public function put(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Notifications/Clear.php b/src/Module/Api/Mastodon/Notifications/Clear.php index d910fe07df..d997a7fd44 100644 --- a/src/Module/Api/Mastodon/Notifications/Clear.php +++ b/src/Module/Api/Mastodon/Notifications/Clear.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class Clear extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Notifications/Dismiss.php b/src/Module/Api/Mastodon/Notifications/Dismiss.php index 98861a2753..277a34d5cb 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\ForbiddenException; */ class Dismiss extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/PushSubscription.php b/src/Module/Api/Mastodon/PushSubscription.php index 4978e980a8..3e90aebd9d 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -33,7 +33,7 @@ use Friendica\Object\Api\Mastodon\Notification; */ class PushSubscription extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); @@ -66,7 +66,7 @@ class PushSubscription extends BaseApi return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray(); } - public function put() + public function put(array $request = []) { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); @@ -99,7 +99,7 @@ class PushSubscription extends BaseApi return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray(); } - protected function delete() + protected function delete(array $request = []) { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index f6da23aa1a..a40406e8dc 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -33,15 +33,15 @@ use Friendica\Module\BaseApi; */ class ScheduledStatuses extends BaseApi { - public function put() + public function put(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - $this->response->unsupported(Router::PUT); + $this->response->unsupported(Router::PUT, $request); } - protected function delete() + protected function delete(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 05851a983a..ad76e3ad7e 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -41,7 +41,7 @@ use Friendica\Util\Images; */ class Statuses extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -207,7 +207,7 @@ class Statuses extends BaseApi DI::mstdnError()->InternalError(); } - protected function delete() + protected function delete(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index 0ff561189e..8092d824aa 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Bookmark extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index fc070548b9..c644d3df00 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Favourite extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 7b7a670517..9f8e5ae1ee 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Mute extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index 9697d795b9..778aa87883 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Pin extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index 64d30e66dd..9ac18a8ef5 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -35,7 +35,7 @@ use Friendica\Module\BaseApi; */ class Reblog extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index 3232e12981..ea5693af2b 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Unbookmark extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index 7e5081656d..3e580b2cc9 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Unfavourite extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index c380f05d0f..c01bbf52e7 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Unmute extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index 9af2fe28d2..7a8da4f2f2 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Unpin extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 27708acad2..ff5ab2ff0b 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -35,7 +35,7 @@ use Friendica\Module\BaseApi; */ class Unreblog extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Unimplemented.php b/src/Module/Api/Mastodon/Unimplemented.php index 22111781bb..c5d0eef122 100644 --- a/src/Module/Api/Mastodon/Unimplemented.php +++ b/src/Module/Api/Mastodon/Unimplemented.php @@ -32,33 +32,33 @@ class Unimplemented extends BaseApi /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - protected function delete() + protected function delete(array $request = []) { - $this->response->unsupported(Router::DELETE); + $this->response->unsupported(Router::DELETE, $request); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - protected function patch() + protected function patch(array $request = []) { - $this->response->unsupported(Router::PATCH); + $this->response->unsupported(Router::PATCH, $request); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { - $this->response->unsupported(Router::POST); + $this->response->unsupported(Router::POST, $request); } /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function put() + public function put(array $request = []) { - $this->response->unsupported(Router::PUT); + $this->response->unsupported(Router::PUT, $request); } /** @@ -66,6 +66,6 @@ class Unimplemented extends BaseApi */ protected function rawContent(array $request = []) { - $this->response->unsupported(Router::GET); + $this->response->unsupported(Router::GET, $request); } } diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index 7c0c77372e..cd9cfb8f5c 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -35,7 +35,6 @@ use Friendica\Network\HTTPException; use Friendica\Security\BasicAuth; use Friendica\Security\OAuth; use Friendica\Util\DateTimeFormat; -use Friendica\Util\HTTPInputData; use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; @@ -71,7 +70,7 @@ class BaseApi extends BaseModule $this->app = $app; } - protected function delete() + protected function delete(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); @@ -80,7 +79,7 @@ class BaseApi extends BaseModule } } - protected function patch() + protected function patch(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); @@ -89,7 +88,7 @@ class BaseApi extends BaseModule } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); @@ -98,7 +97,7 @@ class BaseApi extends BaseModule } } - public function put() + public function put(array $request = []) { self::checkAllowedScope(self::SCOPE_WRITE); @@ -112,21 +111,18 @@ class BaseApi extends BaseModule * * @param array $defaults Associative array of expected request keys and their default typed value. A null * value will remove the request key from the resulting value array. - * @param array|null $request Custom REQUEST array, superglobal instead + * @param array $request Custom REQUEST array, superglobal instead * @return array request data * @throws \Exception */ - public function getRequest(array $defaults, array $request = null): array + public function getRequest(array $defaults, array $request): array { - $httpinput = HTTPInputData::process(); - $input = array_merge($httpinput['variables'], $httpinput['files'], $request ?? $_REQUEST); - - self::$request = $input; + self::$request = $request; self::$boundaries = []; unset(self::$request['pagename']); - return $this->checkDefaults($defaults, $input); + return $this->checkDefaults($defaults, $request); } /** diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 9ffd176267..d89e556fcb 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -91,7 +91,7 @@ class Contact extends BaseModule DI::baseUrl()->redirect($redirectUrl); } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Contact/Advanced.php b/src/Module/Contact/Advanced.php index 2d99abf72d..3daafe94e6 100644 --- a/src/Module/Contact/Advanced.php +++ b/src/Module/Contact/Advanced.php @@ -61,7 +61,7 @@ class Advanced extends BaseModule } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $cid = $this->parameters['id']; diff --git a/src/Module/Contact/Poke.php b/src/Module/Contact/Poke.php index 718095c506..12ab757f3b 100644 --- a/src/Module/Contact/Poke.php +++ b/src/Module/Contact/Poke.php @@ -18,7 +18,7 @@ use Friendica\Util\XML; class Poke extends BaseModule { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user() || empty($this->parameters['id'])) { return self::postReturn(false); diff --git a/src/Module/Contact/Profile.php b/src/Module/Contact/Profile.php index 0431bd8961..88f927c40f 100644 --- a/src/Module/Contact/Profile.php +++ b/src/Module/Contact/Profile.php @@ -71,7 +71,7 @@ class Profile extends BaseModule $this->config = $config; } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Contact/Revoke.php b/src/Module/Contact/Revoke.php index 4c3a6dade5..5d4e7c3e39 100644 --- a/src/Module/Contact/Revoke.php +++ b/src/Module/Contact/Revoke.php @@ -74,7 +74,7 @@ class Revoke extends BaseModule } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { throw new HTTPException\UnauthorizedException(); diff --git a/src/Module/DFRN/Notify.php b/src/Module/DFRN/Notify.php index de03992da3..e1a2f19d48 100644 --- a/src/Module/DFRN/Notify.php +++ b/src/Module/DFRN/Notify.php @@ -38,7 +38,7 @@ use Friendica\Network\HTTPException; */ class Notify extends BaseModule { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $postdata = Network::postdata(); diff --git a/src/Module/Debug/Localtime.php b/src/Module/Debug/Localtime.php index 97a6454850..b686e5a565 100644 --- a/src/Module/Debug/Localtime.php +++ b/src/Module/Debug/Localtime.php @@ -31,7 +31,7 @@ class Localtime extends BaseModule { static $mod_localtime = ''; - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $time = ($_REQUEST['time'] ?? '') ?: 'now'; diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php index b242f5faa3..bc3c72e8d0 100644 --- a/src/Module/Delegation.php +++ b/src/Module/Delegation.php @@ -37,7 +37,7 @@ use Friendica\Util\Proxy; */ class Delegation extends BaseModule { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Diaspora/Receive.php b/src/Module/Diaspora/Receive.php index 242b774b33..2dd0d4dd88 100644 --- a/src/Module/Diaspora/Receive.php +++ b/src/Module/Diaspora/Receive.php @@ -49,7 +49,7 @@ class Receive extends BaseModule $this->config = $config; } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $enabled = $this->config->get('system', 'diaspora_enabled', false); if (!$enabled) { diff --git a/src/Module/FollowConfirm.php b/src/Module/FollowConfirm.php index 388c07a379..12055d7901 100644 --- a/src/Module/FollowConfirm.php +++ b/src/Module/FollowConfirm.php @@ -10,9 +10,9 @@ use Friendica\Model\Contact; */ class FollowConfirm extends BaseModule { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { - parent::post($post); + parent::post($request); $uid = local_user(); if (!$uid) { notice(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index 153f86d607..1bbae8042a 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -61,7 +61,7 @@ class FriendSuggest extends BaseModule $this->friendSuggestFac = $friendSuggestFac; } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $cid = intval($this->parameters['contact']); diff --git a/src/Module/Group.php b/src/Module/Group.php index 883f09cb55..ada1b82f69 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -32,7 +32,7 @@ require_once 'boot.php'; class Group extends BaseModule { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (DI::mode()->isAjax()) { $this->ajaxPost(); @@ -47,7 +47,7 @@ class Group extends BaseModule if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'new')) { BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit'); - $name = trim($_POST['groupname']); + $name = trim($request['groupname']); $r = Model\Group::create(local_user(), $name); if ($r) { $r = Model\Group::getIdByName(local_user(), $name); diff --git a/src/Module/HTTPException/PageNotFound.php b/src/Module/HTTPException/PageNotFound.php index ae156f05c8..9b88e463a0 100644 --- a/src/Module/HTTPException/PageNotFound.php +++ b/src/Module/HTTPException/PageNotFound.php @@ -33,7 +33,7 @@ class PageNotFound extends BaseModule throw new HTTPException\NotFoundException(DI::l10n()->t('Page not found.')); } - public function run(array $post = [], array $request = []): ResponseInterface + public function run(array $request = []): ResponseInterface { /* The URL provided does not resolve to a valid module. * @@ -61,6 +61,6 @@ class PageNotFound extends BaseModule 'query' => $this->server['QUERY_STRING'] ]); - return parent::run($post, $request); // TODO: Change the autogenerated stub + return parent::run($request); // TODO: Change the autogenerated stub } } diff --git a/src/Module/Install.php b/src/Module/Install.php index 2b287d96be..3e27a7d335 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -104,7 +104,7 @@ class Install extends BaseModule $this->currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK; } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $configCache = $this->app->getConfigCache(); diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 8c9c59d304..acd5778e3e 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -35,7 +35,7 @@ use Friendica\Util\Strings; */ class Invite extends BaseModule { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 0564e2f988..d0c6b6afb1 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -40,7 +40,7 @@ use Friendica\Util\Temporal; class Compose extends BaseModule { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!empty($_REQUEST['body'])) { $_REQUEST['return'] = 'network'; diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index 525159840f..653c229d28 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -42,7 +42,7 @@ class Notification extends BaseModule * @throws \ImagickException * @throws \Exception */ - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/OAuth/Acknowledge.php b/src/Module/OAuth/Acknowledge.php index f19837364d..477d3dfcf3 100644 --- a/src/Module/OAuth/Acknowledge.php +++ b/src/Module/OAuth/Acknowledge.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class Acknowledge extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { DI::session()->set('oauth_acknowledge', true); DI::app()->redirect(DI::session()->get('return_path')); diff --git a/src/Module/OAuth/Revoke.php b/src/Module/OAuth/Revoke.php index 745ab0673c..86bc01ced4 100644 --- a/src/Module/OAuth/Revoke.php +++ b/src/Module/OAuth/Revoke.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Revoke extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $request = $this->getRequest([ 'client_id' => '', // Client ID, obtained during app registration diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index c8ef9ee14d..d41708a092 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -34,7 +34,7 @@ use Friendica\Security\OAuth; */ class Token extends BaseApi { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $request = $this->getRequest([ 'client_id' => '', // Client ID, obtained during app registration diff --git a/src/Module/Profile/Schedule.php b/src/Module/Profile/Schedule.php index c14c19b9b2..6149e0237a 100644 --- a/src/Module/Profile/Schedule.php +++ b/src/Module/Profile/Schedule.php @@ -33,7 +33,7 @@ use Friendica\Util\DateTimeFormat; class Schedule extends BaseProfile { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Register.php b/src/Module/Register.php index 3c92c0062a..fbb30220e8 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -193,7 +193,7 @@ class Register extends BaseModule * Extend this method if the module is supposed to process POST requests. * Doesn't display any content */ - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register'); diff --git a/src/Module/RemoteFollow.php b/src/Module/RemoteFollow.php index ee2dcfe4dc..6737398e44 100644 --- a/src/Module/RemoteFollow.php +++ b/src/Module/RemoteFollow.php @@ -61,7 +61,7 @@ class RemoteFollow extends BaseModule $this->page = $page; } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) { $this->baseUrl->redirect(); diff --git a/src/Module/Security/Login.php b/src/Module/Security/Login.php index 90f2d663a7..3ba0eb714e 100644 --- a/src/Module/Security/Login.php +++ b/src/Module/Security/Login.php @@ -46,7 +46,7 @@ class Login extends BaseModule return self::form(Session::get('return_path'), intval(DI::config()->get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED); } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { $return_path = Session::get('return_path'); Session::clear(); diff --git a/src/Module/Security/TwoFactor/Recovery.php b/src/Module/Security/TwoFactor/Recovery.php index 6556e07c23..cd635c394a 100644 --- a/src/Module/Security/TwoFactor/Recovery.php +++ b/src/Module/Security/TwoFactor/Recovery.php @@ -56,7 +56,7 @@ class Recovery extends BaseModule $this->session = $session; } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Security/TwoFactor/Verify.php b/src/Module/Security/TwoFactor/Verify.php index 454cc9f7cf..4afe7ff310 100644 --- a/src/Module/Security/TwoFactor/Verify.php +++ b/src/Module/Security/TwoFactor/Verify.php @@ -38,7 +38,7 @@ class Verify extends BaseModule { private static $errors = []; - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index d385544afd..88750ed626 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -36,7 +36,7 @@ use Friendica\Util\Strings; */ class Delegation extends BaseSettings { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index 2155391a95..f8cd3e9d40 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -36,7 +36,7 @@ use Friendica\Network\HTTPException; */ class Display extends BaseSettings { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Settings/Profile/Index.php b/src/Module/Settings/Profile/Index.php index 9f25db5245..4ea8f72bda 100644 --- a/src/Module/Settings/Profile/Index.php +++ b/src/Module/Settings/Profile/Index.php @@ -41,7 +41,7 @@ use Friendica\Util\Temporal; class Index extends BaseSettings { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Settings/Profile/Photo/Crop.php b/src/Module/Settings/Profile/Photo/Crop.php index a77057e1ab..ec4863a48f 100644 --- a/src/Module/Settings/Profile/Photo/Crop.php +++ b/src/Module/Settings/Profile/Photo/Crop.php @@ -33,7 +33,7 @@ use Friendica\Network\HTTPException; class Crop extends BaseSettings { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!Session::isAuthenticated()) { return; diff --git a/src/Module/Settings/Profile/Photo/Index.php b/src/Module/Settings/Profile/Photo/Index.php index 309a893e66..3ba46e0071 100644 --- a/src/Module/Settings/Profile/Photo/Index.php +++ b/src/Module/Settings/Profile/Photo/Index.php @@ -34,7 +34,7 @@ use Friendica\Util\Strings; class Index extends BaseSettings { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!Session::isAuthenticated()) { return; diff --git a/src/Module/Settings/TwoFactor/AppSpecific.php b/src/Module/Settings/TwoFactor/AppSpecific.php index 94dfc6d412..a7d426b2e1 100644 --- a/src/Module/Settings/TwoFactor/AppSpecific.php +++ b/src/Module/Settings/TwoFactor/AppSpecific.php @@ -66,7 +66,7 @@ class AppSpecific extends BaseSettings } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index ec57a8d147..de6cae5a12 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -33,7 +33,7 @@ use PragmaRX\Google2FA\Google2FA; class Index extends BaseSettings { - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Settings/TwoFactor/Recovery.php b/src/Module/Settings/TwoFactor/Recovery.php index fb13b8b60d..7a77943838 100644 --- a/src/Module/Settings/TwoFactor/Recovery.php +++ b/src/Module/Settings/TwoFactor/Recovery.php @@ -64,7 +64,7 @@ class Recovery extends BaseSettings } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Settings/TwoFactor/Trusted.php b/src/Module/Settings/TwoFactor/Trusted.php index 1507d5fc5e..97fb1660d5 100644 --- a/src/Module/Settings/TwoFactor/Trusted.php +++ b/src/Module/Settings/TwoFactor/Trusted.php @@ -48,7 +48,7 @@ class Trusted extends BaseSettings } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/src/Module/Settings/TwoFactor/Verify.php b/src/Module/Settings/TwoFactor/Verify.php index 3c1853d7f3..8b2f1e54fe 100644 --- a/src/Module/Settings/TwoFactor/Verify.php +++ b/src/Module/Settings/TwoFactor/Verify.php @@ -70,7 +70,7 @@ class Verify extends BaseSettings } } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { if (!local_user()) { return; diff --git a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php index f248d0a9c2..6dd8efff81 100644 --- a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php @@ -51,7 +51,7 @@ class DeleteTest extends ApiTest $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); $delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]); - $response = $delete->run([], ['photo_id' => '709057080661a283a6aa598501504178']); + $response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']); $responseText = (string)$response->getBody(); @@ -68,7 +68,7 @@ class DeleteTest extends ApiTest $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); $delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::DELETE]); - $response = $delete->run([], ['photo_id' => '709057080661a283a6aa598501504178']); + $response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']); $responseText = (string)$response->getBody(); diff --git a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php index 58f20ee3b3..df8b720a82 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php @@ -47,7 +47,7 @@ class DeleteTest extends ApiTest $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); $delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::DELETE]); - $response = $delete->run([], ['album' => 'test_album']); + $response = $delete->run(['album' => 'test_album']); $responseText = (string)$response->getBody(); diff --git a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php index 93856fd971..22ca155cbb 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php @@ -56,7 +56,7 @@ class UpdateTest extends ApiTest { $this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba()); - $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run([], ['album' => 'test_album', 'album_new' => 'test_album_2']); + $response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'test_album', 'album_new' => 'test_album_2']); $responseBody = (string)$response->getBody();