Fix that (raw)content is always executed during Module::run()

This commit is contained in:
Philipp 2021-11-27 13:41:37 +01:00
parent f245fdaa5d
commit 7cba74bb6c
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432

View File

@ -220,23 +220,22 @@ abstract class BaseModule implements ICanHandleRequests
case Router::PUT: case Router::PUT:
$this->put(); $this->put();
break; break;
default: }
$timestamp = microtime(true);
// "rawContent" is especially meant for technical endpoints.
// This endpoint doesn't need any theme initialization or other comparable stuff.
$this->rawContent($request);
try { $timestamp = microtime(true);
$arr = ['content' => '']; // "rawContent" is especially meant for technical endpoints.
Hook::callAll(static::class . '_mod_content', $arr); // This endpoint doesn't need any theme initialization or other comparable stuff.
$this->response->addContent($arr['content']); $this->rawContent($request);
$this->response->addContent($this->content($_REQUEST));
} catch (HTTPException $e) { try {
$this->response->addContent((new ModuleHTTPException())->content($e)); $arr = ['content' => ''];
} finally { Hook::callAll(static::class . '_mod_content', $arr);
$this->profiler->set(microtime(true) - $timestamp, 'content'); $this->response->addContent($arr['content']);
} $this->response->addContent($this->content($_REQUEST));
break; } catch (HTTPException $e) {
$this->response->addContent((new ModuleHTTPException())->content($e));
} finally {
$this->profiler->set(microtime(true) - $timestamp, 'content');
} }
return $this->response->generate(); return $this->response->generate();