6 use Stash\Driver\BlackHole;
7 use Stash\Driver\FileSystem;
8 use Stash\Driver\Memcache;
9 use Stash\Invalidation;
27 const DEFAULT_BOOT_CACHE_TTL = 0;
36 set_error_handler(
'_elgg_php_error_handler');
37 set_exception_handler(
'_elgg_php_exception_handler');
44 $db->setupConnections();
45 $db->assertInstalled();
48 $local_path = Local::root()->getPath();
52 $CONFIG->plugins_path =
"{$local_path}mod/";
53 $CONFIG->pluginspath =
"{$local_path}mod/";
54 $CONFIG->entity_types = [
'group',
'object',
'site',
'user'];
61 $rows = $db->getData(
"
63 FROM {$db->prefix}datalists
64 WHERE `name` IN ('__site_secret__', 'default_site', 'dataroot')
68 $datalists[
$row->name] =
$row->value;
72 if (empty($datalists[
'dataroot'])) {
73 $datalists[
'dataroot'] =
'';
79 if (!$GLOBALS[
'_ELGG']->dataroot_in_settings) {
80 $CONFIG->dataroot = rtrim($datalists[
'dataroot'],
'/\\') . DIRECTORY_SEPARATOR;
82 $CONFIG->site_guid = (int)$datalists[
'default_site'];
83 $CONFIG->site_id = (int)$datalists[
'default_site'];
84 if (!isset(
$CONFIG->boot_cache_ttl)) {
85 $CONFIG->boot_cache_ttl = self::DEFAULT_BOOT_CACHE_TTL;
89 $this->timer->begin([__CLASS__ .
'::getBootData']);
96 $this->timer->begin([__CLASS__ .
'::getBootData']);
100 $datalist_cache =
$data->getDatalistCache();
101 foreach ([
'__site_secret__',
'default_site',
'dataroot'] as
$key) {
102 $datalist_cache->put(
$key, $datalists[
$key]);
122 if (!$GLOBALS[
'_ELGG']->simplecache_enabled_in_settings) {
123 $simplecache_enabled = $datalist_cache->get(
'simplecache_enabled');
124 $CONFIG->simplecache_enabled = ($simplecache_enabled ===
false) ? 1 : $simplecache_enabled;
127 $system_cache_enabled = $datalist_cache->get(
'system_cache_enabled');
128 $CONFIG->system_cache_enabled = ($system_cache_enabled ===
false) ? 1 : $system_cache_enabled;
131 $CONFIG->lastcache = (int)$datalist_cache->get(
"simplecache_lastupdate");
133 $GLOBALS[
'_ELGG']->i18n_loaded_from_cache =
false;
144 if (
$CONFIG->system_cache_enabled) {
150 $preload_md_guids = [
$CONFIG->site_guid];
155 _elgg_services()->metadataCache->populateFromEntities($preload_md_guids);
161 $CONFIG->site_config_loaded =
true;
165 if (0 === strpos(
$action,
'admin/' ||
$action ===
'plugins/settings/save')) {
166 $this->invalidateCache();
181 $site_guid =
$CONFIG->site_guid;
185 static $cleared = [];
186 if (empty($cleared[$site_guid])) {
187 $this->getStashItem(
$CONFIG, $site_guid)->clear();
188 $cleared[$site_guid] =
true;
203 $CONFIG->_boot_cache_hit =
false;
205 if (!
$CONFIG->boot_cache_ttl) {
212 $item->setInvalidationMethod(Invalidation::NONE);
214 if (
$item->isMiss()) {
215 $data =
new BootData();
221 $CONFIG->_boot_cache_hit =
true;
235 private function getStashItem(\stdClass
$CONFIG, $site_guid) {
236 if (!empty(
$CONFIG->memcache) && Memcache::isAvailable()) {
238 if (!empty(
$CONFIG->memcache_servers)) {
245 $driver =
new BlackHole();
247 $driver =
new FileSystem([
252 return (
new Pool($driver))->getItem(
"boot_data_{$site_guid}");
$user_guid
Avatar remove action.
static elggDir()
Returns a directory that points to the root of Elgg, but not necessarily the install root.
Serializable collection of data used to boot Elgg.
Boots Elgg and manages a cache of data needed during boot.
invalidateCache($site_guid=0)
Invalidate the cache item.
Namespace for generating local filesystems.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
trait Profilable
Make an object accept a timer.
_elgg_session_boot()
Initializes the session and checks for the remember me cookie.