mirror of
https://github.com/friendica/friendica
synced 2025-01-30 17:39:47 +00:00
Inject Mode into App::runFrontend() via parameter
This commit is contained in:
parent
76aec2d575
commit
52c6f93c9a
1 changed files with 12 additions and 10 deletions
22
src/App.php
22
src/App.php
|
@ -168,6 +168,7 @@ class App
|
|||
$this->registerTemplateEngine();
|
||||
|
||||
$this->runFrontend(
|
||||
$this->mode,
|
||||
$this->container->create(IManagePersonalConfigValues::class),
|
||||
$this->container->create(Page::class),
|
||||
$this->container->create(Nav::class),
|
||||
|
@ -340,6 +341,7 @@ class App
|
|||
* @throws \ImagickException
|
||||
*/
|
||||
private function runFrontend(
|
||||
Mode $mode,
|
||||
IManagePersonalConfigValues $pconfig,
|
||||
Page $page,
|
||||
Nav $nav,
|
||||
|
@ -347,7 +349,7 @@ class App
|
|||
float $start_time,
|
||||
ServerRequestInterface $request
|
||||
) {
|
||||
$this->mode->setExecutor(Mode::INDEX);
|
||||
$mode->setExecutor(Mode::INDEX);
|
||||
|
||||
$httpInput = new HTTPInputData($request->getServerParams());
|
||||
$serverVars = $request->getServerParams();
|
||||
|
@ -366,11 +368,11 @@ class App
|
|||
|
||||
try {
|
||||
// Missing DB connection: ERROR
|
||||
if ($this->mode->has(Mode::LOCALCONFIGPRESENT) && !$this->mode->has(Mode::DBAVAILABLE)) {
|
||||
if ($mode->has(Mode::LOCALCONFIGPRESENT) && !$mode->has(Mode::DBAVAILABLE)) {
|
||||
throw new HTTPException\InternalServerErrorException($this->l10n->t('Apologies but the website is unavailable at the moment.'));
|
||||
}
|
||||
|
||||
if (!$this->mode->isInstall()) {
|
||||
if (!$mode->isInstall()) {
|
||||
// Force SSL redirection
|
||||
if ($this->config->get('system', 'force_ssl') &&
|
||||
(empty($serverVars['HTTPS']) || $serverVars['HTTPS'] === 'off') &&
|
||||
|
@ -384,7 +386,7 @@ class App
|
|||
|
||||
DID::routeRequest($this->args->getCommand(), $serverVars);
|
||||
|
||||
if ($this->mode->isNormal() && !$this->mode->isBackend()) {
|
||||
if ($mode->isNormal() && !$mode->isBackend()) {
|
||||
$requester = HTTPSignature::getSigner('', $serverVars);
|
||||
if (!empty($requester)) {
|
||||
OpenWebAuth::addVisitorCookieForHandle($requester);
|
||||
|
@ -392,7 +394,7 @@ class App
|
|||
}
|
||||
|
||||
// ZRL
|
||||
if (!empty($queryVars['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->session->getLocalUserId()) {
|
||||
if (!empty($queryVars['zrl']) && $mode->isNormal() && !$mode->isBackend() && !$this->session->getLocalUserId()) {
|
||||
// Only continue when the given profile link seems valid.
|
||||
// Valid profile links contain a path with "/profile/" and no query parameters
|
||||
if ((parse_url($queryVars['zrl'], PHP_URL_QUERY) == '') &&
|
||||
|
@ -407,12 +409,12 @@ class App
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($queryVars['owt']) && $this->mode->isNormal()) {
|
||||
if (!empty($queryVars['owt']) && $mode->isNormal()) {
|
||||
$token = $queryVars['owt'];
|
||||
OpenWebAuth::init($token);
|
||||
}
|
||||
|
||||
if (!$this->mode->isBackend()) {
|
||||
if (!$mode->isBackend()) {
|
||||
$this->auth->withSession();
|
||||
}
|
||||
|
||||
|
@ -428,7 +430,7 @@ class App
|
|||
|
||||
// in install mode, any url loads install module
|
||||
// but we need "view" module for stylesheet
|
||||
if ($this->mode->isInstall() && $moduleName !== 'install') {
|
||||
if ($mode->isInstall() && $moduleName !== 'install') {
|
||||
$this->baseURL->redirect('install');
|
||||
} else {
|
||||
Core\Update::check($this->appHelper->getBasePath(), false);
|
||||
|
@ -478,7 +480,7 @@ class App
|
|||
$page['page_title'] = $moduleName;
|
||||
|
||||
// The "view" module is required to show the theme CSS
|
||||
if (!$this->mode->isInstall() && !$this->mode->has(Mode::MAINTENANCEDISABLED) && $moduleName !== 'view') {
|
||||
if (!$mode->isInstall() && !$mode->has(Mode::MAINTENANCEDISABLED) && $moduleName !== 'view') {
|
||||
$module = $this->createModuleInstance(Maintenance::class);
|
||||
} else {
|
||||
// determine the module class and save it to the module instance
|
||||
|
@ -500,7 +502,7 @@ class App
|
|||
|
||||
// Wrapping HTML responses in the theme template
|
||||
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
|
||||
$response = $page->run($this->appHelper, $this->session, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $nav, $this->session->getLocalUserId());
|
||||
$response = $page->run($this->appHelper, $this->session, $this->baseURL, $this->args, $mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $nav, $this->session->getLocalUserId());
|
||||
}
|
||||
|
||||
$this->logger->debug('Request processed sucessfully', ['response' => $response->getStatusCode(), 'address' => $serverVars['REMOTE_ADDR'] ?? '', 'request' => $requeststring, 'referer' => $serverVars['HTTP_REFERER'] ?? '', 'user-agent' => $serverVars['HTTP_USER_AGENT'] ?? '', 'duration' => number_format(microtime(true) - $request_start, 3)]);
|
||||
|
|
Loading…
Add table
Reference in a new issue