X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FApp.php;h=488c2301b6738be5a9162383862b9b4de9b726d4;hb=31cbc809814a05425175d1c7ef8d43d5a6bc4a0b;hp=02215d2e69fcc10cf224301acbac836ff3326762;hpb=f2b97f932095ed76656be09e3ba94646187808dc;p=friendica.git diff --git a/src/App.php b/src/App.php index 02215d2e69..488c2301b6 100644 --- a/src/App.php +++ b/src/App.php @@ -140,6 +140,8 @@ class App * @brief App constructor. * * @param string $basepath Path to the app base folder + * + * @throws Exception if the Basepath is not usable */ public function __construct($basepath) { @@ -172,40 +174,7 @@ class App $this->callstack['rendering'] = []; $this->callstack['parser'] = []; - // The order of the following calls is important to ensure proper initialization - $this->loadConfigFiles(); - - $this->loadDatabase(); - - $this->determineMode(); - - $this->determineUrlPath(); - - Config::load(); - - if ($this->mode & self::MODE_DBAVAILABLE) { - Core\Addon::loadHooks(); - - $this->loadAddonConfig(); - } - - $this->loadDefaultTimezone(); - - $this->page = [ - 'aside' => '', - 'bottom' => '', - 'content' => '', - 'end' => '', - 'footer' => '', - 'htmlhead' => '', - 'nav' => '', - 'page_title' => '', - 'right_aside' => '', - 'template' => '', - 'title' => '' - ]; - - $this->process_id = System::processID('log'); + $this->reload(); set_time_limit(0); @@ -312,6 +281,47 @@ class App $this->register_template_engine('Friendica\Render\FriendicaSmartyEngine'); } + /** + * Reloads the whole app instance + */ + public function reload() + { + // The order of the following calls is important to ensure proper initialization + $this->loadConfigFiles(); + + $this->loadDatabase(); + + $this->determineMode(); + + $this->determineUrlPath(); + + Config::load(); + + if ($this->mode & self::MODE_DBAVAILABLE) { + Core\Addon::loadHooks(); + + $this->loadAddonConfig(); + } + + $this->loadDefaultTimezone(); + + $this->page = [ + 'aside' => '', + 'bottom' => '', + 'content' => '', + 'end' => '', + 'footer' => '', + 'htmlhead' => '', + 'nav' => '', + 'page_title' => '', + 'right_aside' => '', + 'template' => '', + 'title' => '' + ]; + + $this->process_id = System::processID('log'); + } + /** * Load the configuration files * @@ -1064,7 +1074,11 @@ class App $meminfo = []; foreach ($memdata as $line) { - list($key, $val) = explode(':', $line); + $data = explode(':', $line); + if (count($data) != 2) { + continue; + } + list($key, $val) = $data; $meminfo[$key] = (int) trim(str_replace('kB', '', $val)); $meminfo[$key] = (int) ($meminfo[$key] / 1024); } @@ -1307,11 +1321,11 @@ class App // Only arrays are serialized in database, so we have to unserialize sparingly $value = is_string($v) && preg_match("|^a:[0-9]+:{.*}$|s", $v) ? unserialize($v) : $v; - if (!isset($this->config[$uid])) { + if (!isset($this->config[$uid]) || !is_array($this->config[$uid])) { $this->config[$uid] = []; } - if (!isset($this->config[$uid][$cat])) { + if (!isset($this->config[$uid][$cat]) || !is_array($this->config[$uid][$cat])) { $this->config[$uid][$cat] = []; } @@ -1399,16 +1413,12 @@ class App } } - if (!empty($_SESSION)) { - $user_theme = defaults($_SESSION, 'theme', $system_theme); - } else { - $user_theme = $system_theme; - } + $user_theme = Core\Session::get('theme', $system_theme); // Specific mobile theme override - if (($this->is_mobile || $this->is_tablet) && defaults($_SESSION, 'show-mobile', true)) { + if (($this->is_mobile || $this->is_tablet) && Core\Session::get('show-mobile', true)) { $system_mobile_theme = Config::get('system', 'mobile-theme'); - $user_mobile_theme = defaults($_SESSION, 'mobile-theme', $system_mobile_theme); + $user_mobile_theme = Core\Session::get('mobile-theme', $system_mobile_theme); // --- means same mobile theme as desktop if (!empty($user_mobile_theme) && $user_mobile_theme !== '---') {