aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-19 14:12:35 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-19 14:12:35 +0000
commit1f851e08ba9274fa524db6f75b2c2cc21ec4dcf2 (patch)
treec508d6c61e6bb80c69df42a089b00dea2fa33f52
parent386ae51928196b85b371ced288ccbf9393ff89c7 (diff)
downloadelgg-1f851e08ba9274fa524db6f75b2c2cc21ec4dcf2.tar.gz
elgg-1f851e08ba9274fa524db6f75b2c2cc21ec4dcf2.tar.bz2
Refs #256: Basic installation parameters checked.
Fixes #266: If the install flag isn't set then elgg_view will no longer attempt to load data from the database. git-svn-id: https://code.elgg.org/elgg/trunk@2016 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/database.php21
-rw-r--r--engine/lib/elgglib.php2
-rw-r--r--engine/lib/install.php34
-rw-r--r--install.php3
-rw-r--r--languages/en.php5
-rw-r--r--views/failsafe/messages/exceptions/exception.php10
6 files changed, 67 insertions, 8 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 9df5f991c..86044a375 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -408,6 +408,27 @@
throw new DatabaseException(sprintf(elgg_echo('DatabaseException:ScriptNotFound'), $scriptlocation));
}
+ }
+
+ /**
+ * This function, called by validate_platform(), will check whether the installed version of
+ * MySQL meets the minimum required.
+ *
+ * TODO: If multiple dbs are supported check which db is supported and use the appropriate code to validate
+ * the appropriate version.
+ *
+ * @return bool
+ */
+ function db_check_version()
+ {
+ $version = mysql_get_server_info();
+
+ $points = explode('.', $version);
+
+ if ($points[0] < 5)
+ return false;
+
+ return true;
}
/**
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 1358b84fc..8da54f10d 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -195,7 +195,7 @@
} else {
$vars['page_owner'] = -1;
}
- if ($vars['page_owner'] != -1) {
+ if (($vars['page_owner'] != -1) && (is_installed())) {
if (!isset($usercache[$vars['page_owner']])) {
$vars['page_owner_user'] = get_entity($vars['page_owner']);
$usercache[$vars['page_owner']] = $vars['page_owner_user'];
diff --git a/engine/lib/install.php b/engine/lib/install.php
index ca615c473..c0ed7ab91 100644
--- a/engine/lib/install.php
+++ b/engine/lib/install.php
@@ -11,6 +11,40 @@
* @copyright Curverider Ltd 2008
* @link http://elgg.org/
*/
+
+ /**
+ * Check that the installed version of PHP meets the minimum requirements (currently 5.2 or greater).
+ *
+ * @return bool
+ */
+ function php_check_version()
+ {
+ if (version_compare(phpversion(), '5.2.0', '>='))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Validate the platform Elgg is being installed on.
+ *
+ * @throws ConfigurationException if the validation fails.
+ * @return bool
+ */
+ function validate_platform()
+ {
+ // Get database version
+ if (!db_check_version())
+ throw new ConfigurationException(elgg_echo('ConfigurationException:BadDatabaseVersion'));
+
+ // Now check PHP
+ if (!php_check_version())
+ throw new ConfigurationException(elgg_echo('ConfigurationException:BadPHPVersion'));
+
+ // TODO: Consider checking for installed modules etc
+
+ return true;
+ }
/**
* Returns whether or not the database has been installed
diff --git a/install.php b/install.php
index c0abbd228..915824eb9 100644
--- a/install.php
+++ b/install.php
@@ -27,7 +27,8 @@
/**
* Install the database
*/
- if (!is_db_installed()) {
+ if (!is_db_installed()) {
+ validate_platform();
run_sql_script(dirname(__FILE__) . "/engine/schema/mysql.sql");
init_site_secret();
system_message(elgg_echo("installation:success"));
diff --git a/languages/en.php b/languages/en.php
index e43d504b7..be1963046 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -144,7 +144,10 @@
'InvalidParameterException:UnexpectedReturnFormat' => "Call to method '%s' returned an unexpected result.",
'CallException:NotRPCCall' => "Call does not appear to be a valid XML-RPC call",
- 'PluginException:NoPluginName' => "The plugin name could not be found",
+ 'PluginException:NoPluginName' => "The plugin name could not be found",
+
+ 'ConfigurationException:BadDatabaseVersion' => "The database backend you have installed doesn't meet the basic requirements to run Elgg. Please consult your documentation.",
+ 'ConfigurationException:BadPHPVersion' => "You need at least PHP version 5.2 to run Elgg.",
/**
* User details
diff --git a/views/failsafe/messages/exceptions/exception.php b/views/failsafe/messages/exceptions/exception.php
index 5b637ad95..020f4fa08 100644
--- a/views/failsafe/messages/exceptions/exception.php
+++ b/views/failsafe/messages/exceptions/exception.php
@@ -21,19 +21,19 @@
<span title="<?php echo get_class($vars['object']); ?>">
<?php
- echo autop($vars['object']->getMessage());
+ echo nl2br($vars['object']->getMessage());
?>
</span>
</p>
- <?php if ($CONFIG->debug) { ?>
- <!-- <hr /> -->
+ <?php if ($CONFIG->debug) { ?>
+
<p class="messages-exception-detail" style="background:#FDFFC3;display:block;padding:10px;">
<?php
- echo autop(htmlentities(print_r($vars['object'], true), null, 'UTF-8'));
+ echo nl2br(htmlentities(print_r($vars['object'], true), null, 'UTF-8'));
?>
</p>
- <?php } ?> \ No newline at end of file
+ <?php } ?> \ No newline at end of file