mirror of
https://github.com/flarum/framework.git
synced 2025-02-25 19:49:56 +08:00
Display only exception messages during booting
By not letting PHP render the stack trace, we prevent displaying sensitive information (such as the database credentials). Instead, we display a simple line with the exception message. In the console, the full exception can still be shown, as that is a tool only for forum admins anyway. Fixes #1421.
This commit is contained in:
parent
d35532b744
commit
712d1cdd1e
@ -31,7 +31,7 @@ class Server
|
|||||||
|
|
||||||
public function listen()
|
public function listen()
|
||||||
{
|
{
|
||||||
$app = $this->site->bootApp();
|
$app = $this->safelyBootApp();
|
||||||
|
|
||||||
$runner = new RequestHandlerRunner(
|
$runner = new RequestHandlerRunner(
|
||||||
$app->getRequestHandler(),
|
$app->getRequestHandler(),
|
||||||
@ -45,4 +45,18 @@ class Server
|
|||||||
);
|
);
|
||||||
$runner->run();
|
$runner->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to boot Flarum, and prevent exceptions from exposing sensitive info.
|
||||||
|
*
|
||||||
|
* @return \Flarum\Foundation\AppInterface
|
||||||
|
*/
|
||||||
|
private function safelyBootApp()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->site->bootApp();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
exit('Error booting Flarum: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user