use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
use Friendica\Model\Profile;
use Friendica\Module\Login;
System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'System is currently overloaded. Please try again later.']);
}
-if ($a->isInstallMode()) {
+if (!$a->isInstallMode()) {
if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http")
&& (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
&& (substr(System::baseUrl(), 0, 8) == "https://")
* We have to do it here because the session was just now opened.
*/
if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
- // we haven't loaded user data yet, but we need user language
- $user = dba::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang;
- if (DBM::is_result($user)) {
- $_SESSION['language'] = $user['language'];
+ // we haven't loaded user data yet, but we need user language
+ if (!empty($_SESSION['uid'])) {
+ $user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
+ if (DBA::isResult($user)) {
+ $_SESSION['language'] = $user['language'];
+ }
}
}
-if ((x($_SESSION, 'language')) && ($_SESSION['language'] !== $lang)) {
+if (x($_SESSION, 'language') && ($_SESSION['language'] !== $lang)) {
$lang = $_SESSION['language'];
L10n::loadTranslationTable($lang);
}
-if ((x($_GET,'zrl')) && $a->mode == App::MODE_NORMAL) {
+if (!empty($_GET['zrl']) && $a->mode == App::MODE_NORMAL) {
$a->query_string = Profile::stripZrls($a->query_string);
if (!local_user()) {
// Only continue when the given profile link seems valid
$a->page['page_title'] = $a->module;
$placeholder = '';
+ Addon::callHooks($a->module . '_mod_init', $placeholder);
+
if ($a->module_class) {
- Addon::callHooks($a->module . '_mod_init', $placeholder);
call_user_func([$a->module_class, 'init']);
} else if (function_exists($a->module . '_init')) {
- Addon::callHooks($a->module . '_mod_init', $placeholder);
$func = $a->module . '_init';
$func($a);
}
+ // "rawContent" is especially meant for technical endpoints.
+ // This endpoint doesn't need any theme initialization or other comparable stuff.
+ if (!$a->error && $a->module_class) {
+ call_user_func([$a->module_class, 'rawContent']);
+ }
+
if (function_exists(str_replace('-', '_', $a->getCurrentTheme()) . '_init')) {
$func = str_replace('-', '_', $a->getCurrentTheme()) . '_init';
$func($a);