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
This commit is contained in:
Philipp Holzer 2021-11-28 13:44:42 +01:00 committed by Hypolite Petovan
parent f580d8e5c0
commit 2e4d654c0a
96 changed files with 156 additions and 156 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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;
}

View file

@ -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');
}

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -50,7 +50,7 @@ class Embed extends BaseAdmin
}
}
protected function post(array $request = [], array $post = [])
protected function post(array $request = [])
{
self::checkAdminAccess();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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.');

View file

@ -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);
}

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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' => '',

View file

@ -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();

View file

@ -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();

View file

@ -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);
}
/**

View file

@ -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();

View file

@ -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.

View file

@ -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);
}
/**

View file

@ -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);
}
/**

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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);
}
/**

View file

@ -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;

View file

@ -61,7 +61,7 @@ class Advanced extends BaseModule
}
}
protected function post(array $request = [], array $post = [])
protected function post(array $request = [])
{
$cid = $this->parameters['id'];

View file

@ -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);

View file

@ -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;

View file

@ -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();

View file

@ -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();

View file

@ -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';

View file

@ -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;

View file

@ -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) {

View file

@ -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.'));

View file

@ -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']);

View file

@ -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);

View file

@ -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
}
}

View file

@ -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();

View file

@ -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.'));

View file

@ -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';

View file

@ -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.'));

View file

@ -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'));

View file

@ -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

View file

@ -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

View file

@ -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.'));

View file

@ -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');

View file

@ -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();

View file

@ -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();

View file

@ -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;

View file

@ -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;

View file

@ -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.'));

View file

@ -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.'));

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -66,7 +66,7 @@ class AppSpecific extends BaseSettings
}
}
protected function post(array $request = [], array $post = [])
protected function post(array $request = [])
{
if (!local_user()) {
return;

View file

@ -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;

View file

@ -64,7 +64,7 @@ class Recovery extends BaseSettings
}
}
protected function post(array $request = [], array $post = [])
protected function post(array $request = [])
{
if (!local_user()) {
return;

View file

@ -48,7 +48,7 @@ class Trusted extends BaseSettings
}
}
protected function post(array $request = [], array $post = [])
protected function post(array $request = [])
{
if (!local_user()) {
return;

View file

@ -70,7 +70,7 @@ class Verify extends BaseSettings
}
}
protected function post(array $request = [], array $post = [])
protected function post(array $request = [])
{
if (!local_user()) {
return;

View file

@ -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();

View file

@ -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();

View file

@ -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();