aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/configuration.php103
-rw-r--r--engine/lib/database.php5
-rw-r--r--engine/lib/install.php53
-rw-r--r--engine/lib/sessions.php10
-rw-r--r--engine/lib/sites.php22
-rw-r--r--engine/lib/version.php5
-rw-r--r--engine/start.php2
7 files changed, 75 insertions, 125 deletions
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
index 27514a0ae..9b6386c05 100644
--- a/engine/lib/configuration.php
+++ b/engine/lib/configuration.php
@@ -18,6 +18,37 @@
*/
/**
+ * Check that installation has completed and the database is populated.
+ *
+ * @throws InstallationException
+ * @return void
+ */
+function verify_installation() {
+ global $CONFIG;
+
+ if (isset($CONFIG->installed)) {
+ return $CONFIG->installed;
+ }
+
+ try {
+ $dblink = get_db_link('read');
+ if (!$dblink) {
+ throw new DatabaseException();
+ }
+
+ mysql_query("SELECT value FROM {$CONFIG->dbprefix}datalists WHERE name = 'installed'", $dblink);
+ if (mysql_errno($dblink) > 0) {
+ throw new DatabaseException();
+ }
+
+ $CONFIG->installed = true;
+
+ } catch (DatabaseException $e) {
+ throw new InstallationException(elgg_echo('InstallationException:SiteNotInstalled'));
+ }
+}
+
+/**
* An array of key value pairs from the datalists table.
*
* Used as a cache in datalist functions.
@@ -40,12 +71,6 @@ $DATALIST_CACHE = array();
function datalist_get($name) {
global $CONFIG, $DATALIST_CACHE;
- // We need this, because sometimes datalists are attempted
- // to be retrieved before the database is created
- if (!is_db_installed()) {
- return false;
- }
-
$name = sanitise_string($name);
if (isset($DATALIST_CACHE[$name])) {
return $DATALIST_CACHE[$name];
@@ -351,43 +376,39 @@ function set_default_config() {
* @elgg_event boot system
* @return true|null
*/
-function configuration_init() {
+function configuration_boot() {
global $CONFIG;
- if (is_installed() || is_db_installed()) {
- $path = datalist_get('path');
- if (!empty($path)) {
- $CONFIG->path = $path;
- }
- $dataroot = datalist_get('dataroot');
- if (!empty($dataroot)) {
- $CONFIG->dataroot = $dataroot;
- }
- $simplecache_enabled = datalist_get('simplecache_enabled');
- if ($simplecache_enabled !== false) {
- $CONFIG->simplecache_enabled = $simplecache_enabled;
- } else {
- $CONFIG->simplecache_enabled = 1;
- }
- $viewpath_cache_enabled = datalist_get('viewpath_cache_enabled');
- if ($viewpath_cache_enabled !== false) {
- $CONFIG->viewpath_cache_enabled = $viewpath_cache_enabled;
- } else {
- $CONFIG->viewpath_cache_enabled = 1;
- }
- if (isset($CONFIG->site) && ($CONFIG->site instanceof ElggSite)) {
- $CONFIG->wwwroot = $CONFIG->site->url;
- $CONFIG->sitename = $CONFIG->site->name;
- $CONFIG->sitedescription = $CONFIG->site->description;
- $CONFIG->siteemail = $CONFIG->site->email;
- }
- $CONFIG->url = $CONFIG->wwwroot;
-
- // Load default settings from database
- get_all_config();
-
- return true;
+ $path = datalist_get('path');
+ if (!empty($path)) {
+ $CONFIG->path = $path;
+ }
+ $dataroot = datalist_get('dataroot');
+ if (!empty($dataroot)) {
+ $CONFIG->dataroot = $dataroot;
+ }
+ $simplecache_enabled = datalist_get('simplecache_enabled');
+ if ($simplecache_enabled !== false) {
+ $CONFIG->simplecache_enabled = $simplecache_enabled;
+ } else {
+ $CONFIG->simplecache_enabled = 1;
}
+ $viewpath_cache_enabled = datalist_get('viewpath_cache_enabled');
+ if ($viewpath_cache_enabled !== false) {
+ $CONFIG->viewpath_cache_enabled = $viewpath_cache_enabled;
+ } else {
+ $CONFIG->viewpath_cache_enabled = 1;
+ }
+ if (isset($CONFIG->site) && ($CONFIG->site instanceof ElggSite)) {
+ $CONFIG->wwwroot = $CONFIG->site->url;
+ $CONFIG->sitename = $CONFIG->site->name;
+ $CONFIG->sitedescription = $CONFIG->site->description;
+ $CONFIG->siteemail = $CONFIG->site->email;
+ }
+ $CONFIG->url = $CONFIG->wwwroot;
+
+ // Load default settings from database
+ get_all_config();
}
-register_elgg_event_handler('boot', 'system', 'configuration_init', 10); \ No newline at end of file
+register_elgg_event_handler('boot', 'system', 'configuration_boot', 10); \ No newline at end of file
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 4b0a38bb3..16efb5874 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -667,11 +667,6 @@ function run_sql_script($scriptlocation) {
function db_upgrade($version, $fromdir = "", $quiet = FALSE) {
global $CONFIG;
- // Elgg and its database must be installed to upgrade it!
- if (!is_db_installed() || !is_installed()) {
- return false;
- }
-
$version = (int) $version;
if (!$fromdir) {
diff --git a/engine/lib/install.php b/engine/lib/install.php
index c47eedd40..47ad47e39 100644
--- a/engine/lib/install.php
+++ b/engine/lib/install.php
@@ -8,55 +8,8 @@
* @subpackage Installation
*/
-/**
- * Returns whether or not the database has been installed
- *
- * @return true|false Whether the database has been installed
- */
-function is_db_installed() {
- global $CONFIG;
-
- if (isset($CONFIG->db_installed)) {
- return $CONFIG->db_installed;
- }
-
- if ($dblink = get_db_link('read')) {
- mysql_query("select name from {$CONFIG->dbprefix}datalists limit 1", $dblink);
- if (mysql_errno($dblink) > 0) {
- return false;
- }
- } else {
- return false;
- }
-
- // Set flag if db is installed (if false then we want to check every time)
- $CONFIG->db_installed = true;
-
- return true;
-}
-
-/**
- * Returns whether or not other settings have been set
- *
- * @return true|false Whether or not the rest of the installation has been followed through with
- */
+// @todo - remove this internal function as soon as it is pulled from elgg_view()
function is_installed() {
global $CONFIG;
- return datalist_get('installed');
-}
-
-/**
- * Check that installation has completed and the database is populated.
- *
- * @throws InstallationException
- * @return void
- */
-function verify_installation() {
- $installed = FALSE;
- try {
- $installed = is_installed();
- } catch (DatabaseException $e) {}
- if (!$installed) {
- throw new InstallationException(elgg_echo('InstallationException:SiteNotInstalled'));
- }
-}
+ return $CONFIG->installed;
+} \ No newline at end of file
diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php
index 887904371..05258243f 100644
--- a/engine/lib/sessions.php
+++ b/engine/lib/sessions.php
@@ -51,9 +51,6 @@ function get_loggedin_userid() {
* @return bool
*/
function isloggedin() {
- if (!is_installed()) {
- return false;
- }
$user = get_loggedin_user();
@@ -71,9 +68,6 @@ function isloggedin() {
* @return bool
*/
function isadminloggedin() {
- if (!is_installed()) {
- return FALSE;
- }
$user = get_loggedin_user();
@@ -390,10 +384,6 @@ function logout() {
function session_init($event, $object_type, $object) {
global $DB_PREFIX, $CONFIG;
- if (!is_db_installed()) {
- return false;
- }
-
// Use database for sessions
// HACK to allow access to prefix after object destruction
$DB_PREFIX = $CONFIG->dbprefix;
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index d5984a75f..960e54ee3 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -409,27 +409,23 @@ function get_site_domain($guid) {
*
* @return true
*/
-function sites_init($event, $object_type, $object) {
+function sites_boot($event, $object_type, $object) {
global $CONFIG;
- if (is_installed() && is_db_installed()) {
- $site = trigger_plugin_hook("siteid", "system");
- if ($site === null || $site === false) {
- $CONFIG->site_id = (int) datalist_get('default_site');
- } else {
- $CONFIG->site_id = $site;
- }
- $CONFIG->site_guid = $CONFIG->site_id;
- $CONFIG->site = get_entity($CONFIG->site_guid);
-
- return true;
+ $site = trigger_plugin_hook("siteid", "system");
+ if ($site === null || $site === false) {
+ $CONFIG->site_id = (int) datalist_get('default_site');
+ } else {
+ $CONFIG->site_id = $site;
}
+ $CONFIG->site_guid = $CONFIG->site_id;
+ $CONFIG->site = get_entity($CONFIG->site_guid);
return true;
}
// Register event handlers
-register_elgg_event_handler('boot', 'system', 'sites_init', 2);
+register_elgg_event_handler('boot', 'system', 'sites_boot', 2);
// Register with unit test
register_plugin_hook('unit_test', 'system', 'sites_test');
diff --git a/engine/lib/version.php b/engine/lib/version.php
index c11707417..3e4e0e4f7 100644
--- a/engine/lib/version.php
+++ b/engine/lib/version.php
@@ -18,11 +18,6 @@
function upgrade_code($version, $quiet = FALSE) {
global $CONFIG;
- // Elgg and its database must be installed to upgrade it!
- if (!is_db_installed() || !is_installed()) {
- return FALSE;
- }
-
$version = (int) $version;
if ($handle = opendir($CONFIG->path . 'engine/lib/upgrades/')) {
diff --git a/engine/start.php b/engine/start.php
index 28f6aa56a..6dd227d42 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -8,7 +8,7 @@
* - {@elgg_event plugins_boot system}
* - {@elgg_event init system}
*
- * If Elgg is uninstalled, the browser will be redirected to an
+ * If Elgg is fully uninstalled, the browser will be redirected to an
* installation page.
*
* @see install.php