/** * Loads configuration related to Elgg as an application * * This runs on the engine boot and loads from the datalists database table. * * @see _elgg_engine_boot() * * @access private */ function _elgg_load_application_config() { global $CONFIG; $install_root = str_replace("\\", "/", dirname(dirname(dirname(__FILE__)))); $defaults = array('path' => "{$install_root}/", 'plugins_path' => "{$install_root}/mod/", 'language' => 'en', 'pluginspath' => "{$install_root}/mod/"); foreach ($defaults as $name => $value) { if (empty($CONFIG->{$name})) { $CONFIG->{$name} = $value; } } $GLOBALS['_ELGG']->view_path = "{$install_root}/views/"; // set cookie values for session and remember me _elgg_configure_cookies($CONFIG); if (!is_memcache_available()) { _elgg_services()->datalist->loadAll(); } // allow sites to set dataroot and simplecache_enabled in settings.php if (isset($CONFIG->dataroot)) { $CONFIG->dataroot = sanitise_filepath($CONFIG->dataroot); $GLOBALS['_ELGG']->dataroot_in_settings = true; } else { $dataroot = datalist_get('dataroot'); if (!empty($dataroot)) { $CONFIG->dataroot = $dataroot; } $GLOBALS['_ELGG']->dataroot_in_settings = false; } if (isset($CONFIG->simplecache_enabled)) { $GLOBALS['_ELGG']->simplecache_enabled_in_settings = true; } else { $simplecache_enabled = datalist_get('simplecache_enabled'); if ($simplecache_enabled !== false) { $CONFIG->simplecache_enabled = $simplecache_enabled; } else { $CONFIG->simplecache_enabled = 1; } $GLOBALS['_ELGG']->simplecache_enabled_in_settings = false; } $system_cache_enabled = datalist_get('system_cache_enabled'); if ($system_cache_enabled !== false) { $CONFIG->system_cache_enabled = $system_cache_enabled; } else { $CONFIG->system_cache_enabled = 1; } // needs to be set before system, init for links in html head $CONFIG->lastcache = (int) datalist_get("simplecache_lastupdate"); $GLOBALS['_ELGG']->i18n_loaded_from_cache = false; // this must be synced with the enum for the entities table $CONFIG->entity_types = array('group', 'object', 'site', 'user'); }
/** * Loads configuration related to Elgg as an application * * This runs on the engine boot and loads from the datalists database table. * * @see _elgg_engine_boot() * * @access private */ function _elgg_load_application_config() { _elgg_services()->timer->begin([__FUNCTION__]); global $CONFIG; $install_root = Directory\Local::root(); $defaults = array('path' => $install_root->getPath("/"), 'plugins_path' => $install_root->getPath("mod") . "/", 'language' => 'en', 'pluginspath' => $install_root->getPath("mod") . "/"); foreach ($defaults as $name => $value) { if (empty($CONFIG->{$name})) { $CONFIG->{$name} = $value; } } $GLOBALS['_ELGG']->view_path = \Elgg\Application::elggDir()->getPath("/views/"); // set cookie values for session and remember me _elgg_configure_cookies($CONFIG); if (!is_memcache_available()) { _elgg_services()->datalist->loadAll(); } // make sure dataroot gets set \Elgg\Application::getDataPath(); if (!$GLOBALS['_ELGG']->simplecache_enabled_in_settings) { $simplecache_enabled = datalist_get('simplecache_enabled'); $CONFIG->simplecache_enabled = $simplecache_enabled === false ? 1 : $simplecache_enabled; } $system_cache_enabled = datalist_get('system_cache_enabled'); $CONFIG->system_cache_enabled = $system_cache_enabled === false ? 1 : $system_cache_enabled; // needs to be set before system, init for links in html head $CONFIG->lastcache = (int) datalist_get("simplecache_lastupdate"); $GLOBALS['_ELGG']->i18n_loaded_from_cache = false; // this must be synced with the enum for the entities table $CONFIG->entity_types = array('group', 'object', 'site', 'user'); _elgg_services()->timer->end([__FUNCTION__]); }
return $inst; } /** * This is here as a temporary solution only. Instead of adding more global * state to this file as we migrate tests, try to refactor the code to be * testable without global state. */ global $CONFIG; $CONFIG = (object) ['dbprefix' => 'elgg_', 'boot_complete' => false, 'wwwroot' => 'http://localhost/', 'path' => __DIR__ . '/../../../', 'dataroot' => __DIR__ . '/test_files/dataroot/', 'site_guid' => 1, 'AutoloaderManager_skip_storage' => true, 'simplecache_enabled' => false]; global $_ELGG; $_ELGG = (object) ['view_path' => __DIR__ . '/../../../views/']; function _elgg_testing_config(\Elgg\Config $config = null) { static $inst; if ($config) { $inst = $config; } return $inst; } // PHPUnit will serialize globals between tests, so let's not introduce any globals here. call_user_func(function () use($CONFIG) { $config = new \Elgg\Config($CONFIG); _elgg_testing_config($config); $sp = new \Elgg\Di\ServiceProvider($config); $sp->setValue('mailer', new InMemoryTransport()); $app = new \Elgg\Application($sp); $app->loadCore(); // persistentLogin service needs this set to instantiate without calling DB _elgg_configure_cookies($CONFIG); _elgg_testing_application($app); });
/** * Load remaining engine libraries and complete bootstraping (see start.php) * * @param string $step Which step to boot strap for. Required because * boot strapping is different until the DB is populated. * * @return void * @throws InstallationException */ protected function finishBootstraping($step) { $dbIndex = array_search('database', $this->getSteps()); $settingsIndex = array_search('settings', $this->getSteps()); $adminIndex = array_search('admin', $this->getSteps()); $completeIndex = array_search('complete', $this->getSteps()); $stepIndex = array_search($step, $this->getSteps()); // To log in the user, we need to use the Elgg core session handling. // Otherwise, use default php session handling $useElggSession = $stepIndex == $adminIndex && $this->isAction || $stepIndex == $completeIndex; if (!$useElggSession) { session_name('Elgg_install'); session_start(); _elgg_services()->events->unregisterHandler('boot', 'system', 'session_init'); } if ($stepIndex > $dbIndex) { // once the database has been created, load rest of engine $lib_dir = \Elgg\Application::elggDir()->chroot('/engine/lib/'); $this->loadSettingsFile(); $lib_files = array('autoloader.php', 'database.php', 'actions.php', 'admin.php', 'annotations.php', 'cron.php', 'entities.php', 'extender.php', 'filestore.php', 'group.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', 'navigation.php', 'notification.php', 'objects.php', 'pagehandler.php', 'pam.php', 'plugins.php', 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'widgets.php', 'deprecated-1.9.php'); foreach ($lib_files as $file) { if (!(include_once $lib_dir->getPath($file))) { throw new InstallationException('InstallationException:MissingLibrary', array($file)); } } _elgg_services()->db->setupConnections(); _elgg_services()->translator->registerTranslations(\Elgg\Application::elggDir()->getPath("/languages/")); $this->CONFIG->language = 'en'; if ($stepIndex > $settingsIndex) { $this->CONFIG->site_guid = (int) _elgg_services()->datalist->get('default_site'); $this->CONFIG->site_id = $this->CONFIG->site_guid; $this->CONFIG->site = get_entity($this->CONFIG->site_guid); $this->CONFIG->dataroot = _elgg_services()->datalist->get('dataroot'); _elgg_configure_cookies($this->CONFIG); _elgg_session_boot(); } _elgg_services()->events->trigger('init', 'system'); } }