Extend the use of exceptions in App::runFrontend
- Replace an explicit header locatiobn + exit with System::externalRedirect
This commit is contained in:
parent
92c1cbeeec
commit
56afc43b21
21
src/App.php
21
src/App.php
|
@ -12,10 +12,12 @@ use Friendica\Core\Config\Cache\ConfigCache;
|
||||||
use Friendica\Core\Config\Configuration;
|
use Friendica\Core\Config\Configuration;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n\L10n;
|
use Friendica\Core\L10n\L10n;
|
||||||
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
use Friendica\Module\Login;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\BaseURL;
|
use Friendica\Util\BaseURL;
|
||||||
use Friendica\Util\ConfigFileLoader;
|
use Friendica\Util\ConfigFileLoader;
|
||||||
|
@ -1001,11 +1003,10 @@ class App
|
||||||
*/
|
*/
|
||||||
public function runFrontend()
|
public function runFrontend()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
// Missing DB connection: ERROR
|
// Missing DB connection: ERROR
|
||||||
if ($this->getMode()->has(App\Mode::LOCALCONFIGPRESENT) && !$this->getMode()->has(App\Mode::DBAVAILABLE)) {
|
if ($this->getMode()->has(App\Mode::LOCALCONFIGPRESENT) && !$this->getMode()->has(App\Mode::DBAVAILABLE)) {
|
||||||
Module\Special\HTTPException::rawContent(
|
throw new HTTPException\InternalServerErrorException('Apologies but the website is unavailable at the moment.');
|
||||||
new HTTPException\InternalServerErrorException('Apologies but the website is unavailable at the moment.')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max Load Average reached: ERROR
|
// Max Load Average reached: ERROR
|
||||||
|
@ -1013,17 +1014,13 @@ class App
|
||||||
header('Retry-After: 120');
|
header('Retry-After: 120');
|
||||||
header('Refresh: 120; url=' . $this->getBaseURL() . "/" . $this->query_string);
|
header('Refresh: 120; url=' . $this->getBaseURL() . "/" . $this->query_string);
|
||||||
|
|
||||||
Module\Special\HTTPException::rawContent(
|
throw new HTTPException\ServiceUnavailableException('The node is currently overloaded. Please try again later.');
|
||||||
new HTTPException\ServiceUnavailableException('The node is currently overloaded. Please try again later.')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->getMode()->isInstall()) {
|
if (!$this->getMode()->isInstall()) {
|
||||||
// Force SSL redirection
|
// Force SSL redirection
|
||||||
if ($this->baseURL->checkRedirectHttps()) {
|
if ($this->baseURL->checkRedirectHttps()) {
|
||||||
header('HTTP/1.1 302 Moved Temporarily');
|
System::externalRedirect($this->getBaseURL() . '/' . $this->query_string);
|
||||||
header('Location: ' . $this->getBaseURL() . '/' . $this->query_string);
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Core\Session::init();
|
Core\Session::init();
|
||||||
|
@ -1067,9 +1064,7 @@ class App
|
||||||
// Someone came with an invalid parameter, maybe as a DDoS attempt
|
// Someone came with an invalid parameter, maybe as a DDoS attempt
|
||||||
// We simply stop processing here
|
// We simply stop processing here
|
||||||
Core\Logger::log("Invalid ZRL parameter " . $_GET['zrl'], Core\Logger::DEBUG);
|
Core\Logger::log("Invalid ZRL parameter " . $_GET['zrl'], Core\Logger::DEBUG);
|
||||||
Module\Special\HTTPException::rawContent(
|
throw new HTTPException\ForbiddenException();
|
||||||
new HTTPException\ForbiddenException()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1225,7 +1220,7 @@ class App
|
||||||
|
|
||||||
// Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid
|
// Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid
|
||||||
$this->page['page_title'] = $this->module;
|
$this->page['page_title'] = $this->module;
|
||||||
try {
|
|
||||||
$placeholder = '';
|
$placeholder = '';
|
||||||
|
|
||||||
Core\Hook::callAll($this->module . '_mod_init', $placeholder);
|
Core\Hook::callAll($this->module . '_mod_init', $placeholder);
|
||||||
|
|
Loading…
Reference in a new issue