Index: branches/5.2.x/core/install/install_toolkit.php
===================================================================
diff -u -N -r14842 -r14860
--- branches/5.2.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 14842)
+++ branches/5.2.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 14860)
@@ -1,6 +1,6 @@
setToolkit($this);
+ }
+
+ // some errors possible
+ return $prerequisite_object->$method();
+ }
+
+ /**
* Processes one license, received from server
*
* @param string $file_data
Index: branches/5.2.x/core/install/steps_db.xml
===================================================================
diff -u -N -r14842 -r14860
--- branches/5.2.x/core/install/steps_db.xml (.../steps_db.xml) (revision 14842)
+++ branches/5.2.x/core/install/steps_db.xml (.../steps_db.xml) (revision 14860)
@@ -207,4 +207,7 @@
The characters entered in this field are placed before the names of the tables used by In-Portal.
For example, if you enter "inp_" into the prefix field, the table named Category will be named inp_Category.
]]>
+
+ System Requirements Check option should be used to ensure proper system behavior in the current environment.]]>
+
\ No newline at end of file
Index: branches/5.2.x/core/install/prerequisites.php
===================================================================
diff -u -N -r14699 -r14860
--- branches/5.2.x/core/install/prerequisites.php (.../prerequisites.php) (revision 14699)
+++ branches/5.2.x/core/install/prerequisites.php (.../prerequisites.php) (revision 14860)
@@ -1,6 +1,6 @@
_toolkit->Conn;
+ }
+
+ /**
+ * Checks minimal version, that could be upgradeable
+ *
* @param Array $versions
* @param string $mode when called mode {install, upgrade, standalone)
* @return Array
@@ -54,8 +72,10 @@
$sql = 'SELECT Version
FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "In-Portal"';
- $inportal_version = $this->Conn->GetOne($sql);
+ $conn =& $this->getConnection();
+ $inportal_version = $conn->GetOne($sql);
+
if ($inportal_version === false) {
// only, when In-Portal was installed
return $errors;
@@ -72,4 +92,87 @@
return $errors;
}
+
+ /**
+ * Returns information about system requirements
+ *
+ * @return array
+ */
+ function CheckSystemRequirements()
+ {
+ $ret = Array ();
+ $ret['php_version'] = version_compare(PHP_VERSION, '5.2.0', '>=');
+
+ $ret['url_rewriting'] = function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules());
+ $ret['memcache'] = class_exists('Memcache');
+ $ret['curl'] = function_exists('curl_init');
+ $ret['freetype'] = function_exists('imagettfbbox');
+
+ $ret['gd_version'] = $ret['jpeg'] = false;
+
+ if ( function_exists('gd_info') ) {
+ $gd_info = gd_info();
+
+ $gd_version = preg_replace('/[^\d.]/', '', $gd_info['GD Version']);
+ $ret['gd_version'] = version_compare($gd_version, '1.8', '>=');
+
+ $ret['jpeg'] = isset($gd_info['JPEG Support']) && $gd_info['JPEG Support'];
+ }
+
+ $ret['mysql'] = function_exists('mysql_connect');
+ $ret['json'] = function_exists('json_encode');
+
+ $ret['memory_limit'] = $this->isPhpSettingChangeable('memory_limit', '33M');
+ $ret['date.timezone'] = ini_get('date.timezone') != '';
+
+ $ret['variables_order'] = strpos(ini_get('variables_order'), 'GPC') !== false;
+ $ret['output_buffering'] = ini_get('output_buffering') > 0;
+
+ return $ret;
+ }
+
+ /**
+ * Detects if setting of php.ini can be changed
+ *
+ * @param string $setting_name
+ * @param string $new_value
+ * @return bool
+ */
+ protected function isPhpSettingChangeable($setting_name, $new_value)
+ {
+ $backup_value = ini_get($setting_name);
+ ini_set($setting_name, $new_value);
+
+ if ( ini_get($setting_name) != $backup_value ) {
+ ini_set($setting_name, $backup_value);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns information about DB requirements
+ *
+ * @return array
+ */
+ function CheckDBRequirements()
+ {
+ // check PHP version 5.2+
+ $ret = Array();
+
+ $sql = 'SELECT VERSION()';
+ $conn =& $this->getConnection();
+
+ $db_version = preg_replace('/[^\d.]/', '', $conn->GetOne($sql));
+ $ret['version'] = version_compare($db_version, '5.0', '>=');
+
+ $sql = 'SHOW VARIABLES LIKE "max_allowed_packet"';
+ $db_variables = $conn->Query($sql, 'Variable_name');
+
+ $ret['packet_size'] = $db_variables['max_allowed_packet']['Value'] >= 1048576;
+
+ return $ret;
+ }
}
\ No newline at end of file
Index: branches/5.2.x/core/install/step_templates/install_setup.tpl
===================================================================
diff -u -N -r14842 -r14860
--- branches/5.2.x/core/install/step_templates/install_setup.tpl (.../install_setup.tpl) (revision 14842)
+++ branches/5.2.x/core/install/step_templates/install_setup.tpl (.../install_setup.tpl) (revision 14860)
@@ -32,6 +32,7 @@
$option_tpl = ob_get_clean();
$options = Array (
+ 'sys_requirements' => 'Check System Requirements',
'upgrade' => 'Upgrade In-Portal',
'clean_reinstall' => 'Reinstall In-Portal',
'fresh_install' => 'Install In-Portal to a New Database',
Index: branches/5.2.x/core/install.php
===================================================================
diff -u -N -r14843 -r14860
--- branches/5.2.x/core/install.php (.../install.php) (revision 14843)
+++ branches/5.2.x/core/install.php (.../install.php) (revision 14860)
@@ -1,6 +1,6 @@
Array ('check_paths', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
- 'clean_reinstall' => Array ('check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
+ 'fresh_install' => Array ('sys_requirements', 'check_paths', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
+ 'clean_reinstall' => Array ('install_setup', 'sys_requirements', 'check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'sys_config', 'select_theme', 'security', 'finish'),
'already_installed' => Array ('check_paths', 'install_setup'),
'upgrade' => Array ('check_paths', 'install_setup', 'upgrade_modules', 'skin_upgrade', 'security', 'finish'),
'update_license' => Array ('check_paths', 'install_setup', 'select_license', /*'download_license',*/ 'select_domain', 'security', 'finish'),
'update_config' => Array ('check_paths', 'install_setup', 'sys_config', 'security', 'finish'),
'db_reconfig' => Array ('check_paths', 'install_setup', 'db_reconfig', 'security', 'finish'),
+ 'sys_requirements' => Array ('check_paths', 'install_setup', 'sys_requirements', 'security', 'finish')
);
/**
* Steps, that doesn't required admin to be logged-in to proceed
*
* @var Array
*/
- var $skipLoginSteps = Array ('check_paths', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish', -1);
+ var $skipLoginSteps = Array ('sys_requirements', 'check_paths', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish', -1);
/**
* Steps, on which kApplication should not be initialized, because of missing correct db table structure
*
* @var Array
*/
- var $skipApplicationSteps = Array ('check_paths', 'clean_db', 'db_config', 'db_reconfig' /*, 'install_setup'*/); // remove install_setup when application will work separately from install
+ var $skipApplicationSteps = Array ('sys_requirements', 'check_paths', 'clean_db', 'db_config', 'db_reconfig' /*, 'install_setup'*/); // remove install_setup when application will work separately from install
/**
* Folders that should be writeable to continue installation. $1 - main writeable folder from config.php ("/system" by default)
@@ -277,6 +278,29 @@
}
switch ($this->currentStep) {
+ case 'sys_requirements':
+ $required_checks = Array (
+ 'php_version', 'curl', 'freetype', 'gd_version',
+ 'jpeg', 'mysql', 'date.timezone', 'output_buffering',
+ );
+
+ $check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckSystemRequirements');
+ $required_checks = array_diff($required_checks, array_keys( array_filter($check_results) ));
+
+ if ( $required_checks ) {
+ // php-based checks failed - show error
+ $this->errorMessage = ' Installation can not continue until all required environment parameters are set correctly';
+ }
+ elseif ( $this->GetVar('js_enabled') === false ) {
+ // can't check JS without form submit - set some fake error, so user stays on this step
+ $this->errorMessage = ' ';
+ }
+ elseif ( !$this->GetVar('js_enabled') || !$this->GetVar('cookies_enabled') ) {
+ // js/cookies disabled
+ $this->errorMessage = ' Installation can not continue until all required environment parameters are set correctly';
+ }
+ break;
+
case 'check_paths':
$writeable_base = $this->toolkit->getSystemConfig('Misc', 'WriteablePath');
foreach ($this->writeableFolders as $folder_path) {
@@ -509,8 +533,11 @@
break;
}
}
- if (!$status) break;
+ if ( !$status ) {
+ break;
+ }
+
// 2. check permissions, that use have in this database
$status = $this->CheckDatabase(($this->currentStep == 'db_config') && !$this->GetVar('UseExistingSetup'));
break;
@@ -1318,8 +1345,8 @@
// perform various check type to database specified
// 1. user is allowed to connect to database
// 2. user has all types of permissions in database
+ // 3. database environment settings met minimum requirements
-
if (mb_strlen($this->toolkit->getSystemConfig('Database', 'TablePrefix')) > 7) {
$this->errorMessage = 'Table prefix should not be longer than 7 characters';
return false;
@@ -1354,6 +1381,22 @@
$this->errorMessage = 'An In-Portal Database already exists at this location';
return false;
}
+
+ $requirements_error = Array ();
+ $db_check_results = $this->toolkit->CallPrerequisitesMethod('core/', 'CheckDBRequirements');
+
+ if ( !$db_check_results['version'] ) {
+ $requirements_error[] = '- MySQL Version is below 5.0';
+ }
+
+ if ( !$db_check_results['packet_size'] ) {
+ $requirements_error[] = '- MySQL Packet Size is below 1 MB';
+ }
+
+ if ( $requirements_error ) {
+ $this->errorMessage = 'Connection successful, but following system requirements were not met: ' . implode(' ', $requirements_error);
+ return false;
+ }
}
else {
// user has insufficient permissions in database specified
@@ -1691,7 +1734,7 @@
{
$button_visibility = Array (
'continue' => $this->GetNextStep() != -1 || ($this->stepsPreset == 'already_installed'),
- 'refresh' => in_array($this->currentStep, Array ('check_paths', 'security')),
+ 'refresh' => in_array($this->currentStep, Array ('sys_requirements', 'check_paths', 'security')),
'back' => in_array($this->currentStep, Array (/*'select_license',*/ 'download_license', 'select_domain')),
);
Index: branches/5.2.x/core/install/step_templates/sys_requirements.tpl
===================================================================
diff -u -N
--- branches/5.2.x/core/install/step_templates/sys_requirements.tpl (revision 0)
+++ branches/5.2.x/core/install/step_templates/sys_requirements.tpl (revision 14860)
@@ -0,0 +1,73 @@
+
+