]> git.mxchange.org Git - friendica.git/blobdiff - src/BaseModule.php
Add previous exception to unexpected worker exception logging
[friendica.git] / src / BaseModule.php
index e532b95362dfc150d3e360be40b306c165af5170..11f884472e65c448c774d6b8f1576ef986903bac 100644 (file)
@@ -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')