This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/core/_bootstrap.php

84 lines
2.2 KiB
PHP
Raw Normal View History

<?php
/*
* Load all the files into memory, sanitise the environment, but don't
* actually do anything as far as the app is concerned
*/
global $cache, $config, $database, $user, $page, $_tracer;
2015-08-02 18:29:25 +00:00
require_once "core/sys_config.php";
require_once "core/polyfills.php";
require_once "core/util.php";
2016-05-11 22:27:42 +00:00
require_once "vendor/autoload.php";
// set up and purify the environment
_version_check();
_sanitise_environment();
// The trace system has a certain amount of memory consumption every time it is used,
// so to prevent running out of memory during complex operations code that uses it should
// check if tracer output is enabled before making use of it.
$tracer_enabled = constant('TRACE_FILE')!==null;
// load base files
2019-07-05 19:49:47 +00:00
$_tracer->begin("Bootstrap");
$_tracer->begin("Opening core files");
2017-09-17 18:37:30 +00:00
$_shm_files = array_merge(
zglob("core/*.php"),
zglob("core/{".ENABLED_MODS."}/*.php"),
zglob("ext/*/info.php")
);
foreach ($_shm_files as $_shm_filename) {
if (basename($_shm_filename)[0] != "_") {
require_once $_shm_filename;
}
}
2017-09-17 18:37:30 +00:00
unset($_shm_files);
unset($_shm_filename);
2019-07-05 19:49:47 +00:00
$_tracer->end();
$_tracer->begin("Connecting to Cache");
$cache = new Cache(CACHE_DSN);
$_tracer->end();
2019-09-29 13:50:31 +00:00
$_tracer->begin("Connecting to DB");
$database = new Database();
$config = new DatabaseConfig($database);
$_tracer->end();
$_tracer->begin("Loading extension info");
ExtensionInfo::load_all_extension_info();
Extension::determine_enabled_extensions();
$_tracer->end();
$_tracer->begin("Opening enabled extension files");
$_shm_files = zglob("ext/{".Extension::get_enabled_extensions_as_string()."}/main.php");
foreach ($_shm_files as $_shm_filename) {
if (basename($_shm_filename)[0] != "_") {
require_once $_shm_filename;
}
}
unset($_shm_files);
unset($_shm_filename);
$_tracer->end();
// load the theme parts
2019-07-05 19:49:47 +00:00
$_tracer->begin("Loading themelets");
foreach (_get_themelet_files(get_theme()) as $themelet) {
require_once $themelet;
}
2015-08-02 18:29:25 +00:00
unset($themelet);
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
2019-07-05 19:49:47 +00:00
$_tracer->end();
// hook up event handlers
$_tracer->begin("Loading event listeners");
2015-08-02 19:54:41 +00:00
_load_event_listeners();
2019-07-05 19:49:47 +00:00
$_tracer->end();
2019-07-05 18:14:09 +00:00
send_event(new InitExtEvent());
if(AUTO_DB_UPGRADE) {
send_event(new DatabaseUpgradeEvent());
}
2019-07-05 19:49:47 +00:00
$_tracer->end();