]> git.mxchange.org Git - friendica.git/blobdiff - index.php
"rawcontent" is now a baseobject method
[friendica.git] / index.php
index 8d40dbf85f2dfbfca4d8657c1e4053cd33068485..46b95c75e4bfe0b0962b81f7f54cbea9ad763179 100644 (file)
--- a/index.php
+++ b/index.php
@@ -92,11 +92,13 @@ if (!$a->is_backend()) {
  * 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 (DBA::isResult($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'];
+               }
        }
 }
 
@@ -105,7 +107,7 @@ if (x($_SESSION, 'language') && ($_SESSION['language'] !== $lang)) {
        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
@@ -340,15 +342,21 @@ if ($a->module_loaded) {
        $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);