X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FBaseModule.php;h=b43e984772f6cfd7b6ecfa220f8dc6ea52c999a6;hb=131695cb1167a831dbe87a0f2b1bde755dabd55f;hp=99c297b7564fd36a98430f0e5413590d7b15191b;hpb=b96daeeeef0cff461dc4d677d8594c198c62d507;p=friendica.git diff --git a/src/BaseModule.php b/src/BaseModule.php index 99c297b756..b43e984772 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -1,6 +1,6 @@ l10n->tt($singular, $plurarl, $count); + return $this->l10n->tt($singular, $plural, $count); } /** @@ -181,7 +181,7 @@ abstract class BaseModule implements ICanHandleRequests /** * {@inheritDoc} */ - public function run(array $request = []): ResponseInterface + public function run(ModuleHTTPException $httpException, array $request = []): ResponseInterface { // @see https://github.com/tootsuite/mastodon/blob/c3aef491d66aec743a3a53e934a494f653745b61/config/initializers/cors.rb if (substr($this->args->getQueryString(), 0, 12) == '.well-known/') { @@ -243,7 +243,15 @@ abstract class BaseModule implements ICanHandleRequests $this->response->addContent($arr['content']); $this->response->addContent($this->content($request)); } catch (HTTPException $e) { - $this->response->addContent((new ModuleHTTPException())->content($e)); + // In case of System::externalRedirects(), we don't want to prettyprint the exception + // just redirect to the new location + if (($e instanceof HTTPException\FoundException) || + ($e instanceof HTTPException\MovedPermanentlyException) || + ($e instanceof HTTPException\TemporaryRedirectException)) { + throw $e; + } + + $this->response->addContent($httpException->content($e)); } finally { $this->profiler->set(microtime(true) - $timestamp, 'content'); } @@ -389,7 +397,7 @@ abstract class BaseModule implements ICanHandleRequests public static function getFormSecurityStandardErrorMessage(): string { - return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL; + return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it."); } public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token') @@ -397,7 +405,7 @@ abstract class BaseModule implements ICanHandleRequests if (!self::checkFormSecurityToken($typename, $formname)) { Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]); - notice(self::getFormSecurityStandardErrorMessage()); + DI::sysmsg()->addNotice(self::getFormSecurityStandardErrorMessage()); DI::baseUrl()->redirect($err_redirect); } }