Permalink
Browse files

* [#MODX-185] Improvements to installation with errors when SET CHARA…

…CTER SET is used and collation does not match database.

* [#MODX-346] Fixed additional errors on advanced upgrades.
  • Loading branch information...
1 parent c9c649f commit 8ba0788d526b051732786b33d12c306fa7eb4507 opengeek committed Oct 30, 2008
View
@@ -1,40 +1,45 @@
<?php
$installMode = intval($_POST['installmode']);
-if ($installMode == 0) {
- $_POST['database_connection_charset'] = substr($_POST['database_collation'], 0, strpos($_POST['database_collation'], '_'));
+if ($installMode == 0 || $installMode == 2) {
+ $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci';
+ $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
+ $_POST['database_connection_charset'] = $database_charset;
}
-elseif ($installMode > 0) {
- include "../manager/includes/config.inc.php";
+elseif ($installMode == 1) {
+ include "../manager/includes/config.inc.php";
- if (!isset ($database_connection_charset) || empty($database_connection_charset)) {
if (@ $conn = mysql_connect($database_server, $database_user, $database_password)) {
- if (@ mysql_query("USE {$dbase}")) {
- if (!$rs = @ mysql_query("show session variables like 'collation_database'")) {
- $rs = @ mysql_query("show session variables like 'collation_server'");
- }
- if ($rs && $collation = mysql_fetch_row($rs)) {
- $database_collation = trim($collation[1]);
+ if (@ mysql_query("USE {$dbase}")) {
+ if (!$rs = @ mysql_query("show session variables like 'collation_database'")) {
+ $rs = @ mysql_query("show session variables like 'collation_server'");
+ }
+ if ($rs && $collation = mysql_fetch_row($rs)) {
+ $database_collation = trim($collation[1]);
+ }
}
- }
}
if (empty ($database_collation)) {
- $database_collation = 'utf8_unicode_ci';
+ $database_collation = 'utf8_unicode_ci';
}
$database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
- $database_connection_charset = $database_charset;
- }
+ if (!isset ($database_connection_charset) || empty ($database_connection_charset)) {
+ $database_connection_charset = $database_charset;
+ }
- if (!isset($database_connection_method) || empty($database_connection_method)) {
- $database_connection_method = 'SET CHARACTER SET';
- }
+ if (!isset ($database_connection_method) || empty ($database_connection_method)) {
+ $database_connection_method = 'SET CHARACTER SET';
+ }
+ if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) {
+ $database_connection_method = 'SET NAMES';
+ }
- $_POST['database_name']= $dbase;
- $_POST['tableprefix']= $table_prefix;
- $_POST['database_connection_charset']= $database_connection_charset;
- $_POST['database_connection_method']= $database_connection_method;
- $_POST['databasehost']= $database_server;
- $_POST['databaseloginname']= $database_user;
- $_POST['databaseloginpassword']= $database_password;
+ $_POST['database_name'] = $dbase;
+ $_POST['tableprefix'] = $table_prefix;
+ $_POST['database_connection_charset'] = $database_connection_charset;
+ $_POST['database_connection_method'] = $database_connection_method;
+ $_POST['databasehost'] = $database_server;
+ $_POST['databaseloginname'] = $database_user;
+ $_POST['databaseloginpassword'] = $database_password;
}
?>
@@ -59,6 +64,7 @@
<?php
+
# load setup information file
$setupPath = realpath(dirname(__FILE__));
include "{$setupPath}/setup.info.php";
@@ -70,70 +76,69 @@
echo "<h1>&nbsp;" . $_lang['sample_web_site'] . "</h1>";
echo "&nbsp;<input type=\"checkbox\" name=\"installdata\" value=\"1\" $chk />" . $_lang['install_overwrite'] . " <span class=\"comname\">" . $_lang['sample_web_site'] . "</span> <br /><span><i>&nbsp;" . $_lang['sample_web_site_note'] . "</i></span><hr size=\"1\" style=\"border:1px dotted silver;\" /><br />";
-
// toggle options
echo "<h4>" . $_lang['checkbox_select_options'] . "</h4><p class=\"actions\"><a href=\"javascript:Checkboxes.checkAll('toggle');\">" . $_lang['all'] . "</a> <a href=\"javascript:Checkboxes.uncheckAll('toggle');\">" . $_lang['none'] . "</a> <a href=\"javascript:Checkboxes.toggle('toggle');\">" . $_lang['toggle'] . "</a></p><br class=\"clear\" />";
-$options_selected= isset ($_POST['options_selected']);
+$options_selected = isset ($_POST['options_selected']);
// display templates
$templates = isset ($_POST['template']) ? $_POST['template'] : array ();
$limit = count($moduleTemplates);
if ($limit > 0) {
- echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['templates'] . '" />';
- echo "<h1>" . $_lang['templates'] . "</h1><br />";
- for ($i = 0; $i < $limit; $i++) {
- $chk = in_array($i, $templates) || (!$options_selected) ? 'checked="checked"' : "";
- echo "&nbsp;<input type=\"checkbox\" name=\"template[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleTemplates[$i][0] . "</span> - " . $moduleTemplates[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
- }
+ echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['templates'] . '" />';
+ echo "<h1>" . $_lang['templates'] . "</h1><br />";
+ for ($i = 0; $i < $limit; $i++) {
+ $chk = in_array($i, $templates) || (!$options_selected) ? 'checked="checked"' : "";
+ echo "&nbsp;<input type=\"checkbox\" name=\"template[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleTemplates[$i][0] . "</span> - " . $moduleTemplates[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
+ }
}
// display chunks
$chunks = isset ($_POST['chunk']) ? $_POST['chunk'] : array ();
$limit = count($moduleChunks);
if ($limit > 0) {
- echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['chunks'] . '" />';
- echo "<h1>" . $_lang['chunks'] . "</h1>";
- for ($i = 0; $i < $limit; $i++) {
- $chk = in_array($i, $chunks) || (!$options_selected) ? 'checked="checked"' : "";
- echo "&nbsp;<input type=\"checkbox\" name=\"chunk[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleChunks[$i][0] . "</span> - " . $moduleChunks[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
- }
+ echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['chunks'] . '" />';
+ echo "<h1>" . $_lang['chunks'] . "</h1>";
+ for ($i = 0; $i < $limit; $i++) {
+ $chk = in_array($i, $chunks) || (!$options_selected) ? 'checked="checked"' : "";
+ echo "&nbsp;<input type=\"checkbox\" name=\"chunk[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleChunks[$i][0] . "</span> - " . $moduleChunks[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
+ }
}
// display modules
$modules = isset ($_POST['module']) ? $_POST['module'] : array ();
$limit = count($moduleModules);
if ($limit > 0) {
- echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['modules'] . '" />';
- echo "<h1>" . $_lang['modules'] . "</h1>";
- for ($i = 0; $i < $limit; $i++) {
- $chk = in_array($i, $modules) || (!$options_selected) ? 'checked="checked"' : "";
- echo "&nbsp;<input type=\"checkbox\" name=\"module[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleModules[$i][0] . "</span> - " . $moduleModules[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
- }
+ echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['modules'] . '" />';
+ echo "<h1>" . $_lang['modules'] . "</h1>";
+ for ($i = 0; $i < $limit; $i++) {
+ $chk = in_array($i, $modules) || (!$options_selected) ? 'checked="checked"' : "";
+ echo "&nbsp;<input type=\"checkbox\" name=\"module[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleModules[$i][0] . "</span> - " . $moduleModules[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
+ }
}
// display plugins
$plugins = isset ($_POST['plugin']) ? $_POST['plugin'] : array ();
$limit = count($modulePlugins);
if ($limit > 0) {
- echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['plugins'] . '" />';
- echo "<h1>" . $_lang['plugins'] . "</h1>";
- for ($i = 0; $i < $limit; $i++) {
- $chk = in_array($i, $plugins) || (!$options_selected) ? 'checked="checked"' : "";
- echo "&nbsp;<input type=\"checkbox\" name=\"plugin[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $modulePlugins[$i][0] . "</span> - " . $modulePlugins[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
- }
+ echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['plugins'] . '" />';
+ echo "<h1>" . $_lang['plugins'] . "</h1>";
+ for ($i = 0; $i < $limit; $i++) {
+ $chk = in_array($i, $plugins) || (!$options_selected) ? 'checked="checked"' : "";
+ echo "&nbsp;<input type=\"checkbox\" name=\"plugin[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $modulePlugins[$i][0] . "</span> - " . $modulePlugins[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
+ }
}
// display snippets
$snippets = isset ($_POST['snippet']) ? $_POST['snippet'] : array ();
$limit = count($moduleSnippets);
if ($limit > 0) {
- echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['snippets'] . '" />';
- echo "<h1>" . $_lang['snippets'] . "</h1>";
- for ($i = 0; $i < $limit; $i++) {
- $chk = in_array($i, $snippets) || (!$options_selected) ? 'checked="checked"' : "";
- echo "&nbsp;<input type=\"checkbox\" name=\"snippet[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleSnippets[$i][0] . "</span> - " . $moduleSnippets[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
- }
+ echo '<br/><img src="im_resources.gif" align="left" width="15" height="15" hspace="5" alt="' . $_lang['snippets'] . '" />';
+ echo "<h1>" . $_lang['snippets'] . "</h1>";
+ for ($i = 0; $i < $limit; $i++) {
+ $chk = in_array($i, $snippets) || (!$options_selected) ? 'checked="checked"' : "";
+ echo "&nbsp;<input type=\"checkbox\" name=\"snippet[]\" value=\"$i\" class=\"toggle\" $chk />" . $_lang['install_update'] . " <span class=\"comname\">" . $moduleSnippets[$i][0] . "</span> - " . $moduleSnippets[$i][1] . "<hr size=\"1\" style=\"border:1px dotted silver;\" />";
+ }
}
?>
View
@@ -2,8 +2,10 @@
This file shows the changes in recent releases of MODx. The most current release is usually the
development release, and is only shown to give an idea of what's currently in the pipeline.
-MODx 0.9.6.3-RC2 (rev 4367 - October 23, 2008)
+MODx 0.9.6.3-RC2 (rev 4377 - October 30, 2008)
===================================
+* [#MODX-185] Improvements to installation with errors when SET CHARACTER SET is used and collation does not match database.
+* [#MODX-346] Fixed additional errors on advanced upgrades.
* Add to ht.access template to prevent Apache internal dummy connections breaking hostname [(site_url)]
* [#MODX-455] Have messageQuit() set a 500 error response to avoid indexing pages with PHP parse errors.
* [#MODX-346] Fixed error with $database_connection_charset being empty after "Advanced Upgrade Install".
@@ -16,6 +16,7 @@
$database_name = str_replace("`", "", $database_name);
$tableprefix = $_POST['tableprefix'];
$database_collation = $_POST['database_collation'];
+ $database_connection_method = $_POST['database_connection_method'];
if (!@ mysql_select_db($database_name, $conn)) {
// create database
@@ -32,6 +33,9 @@
elseif (($installMode == 0) && (@ mysql_query("SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) {
$output .= '<span style="color:#FF0000;">'.$_lang['status_failed_table_prefix_already_in_use'].'</span>';
}
+ elseif (($database_connection_method != 'SET NAMES') && ($rs = @ mysql_query("show variables like 'collation_database'")) && ($row = @ mysql_fetch_row($rs)) && ($row[1] != $database_collation)) {
+ $output .= '<span style="color:#FF0000;">'.sprintf($_lang['status_failed_database_collation_does_not_match'], $row[1]).'</span>';
+ }
else {
$output .= '<span style="color:#9CCD00;">'.$_lang['status_passed'].'</span>';
}
View
@@ -10,13 +10,15 @@ window.addEvent('domready', function(){
uid = $('databaseloginname').value;
pwd = $('databaseloginpassword').value;
database_collation = $('database_collation').value;
+ database_connection_method = $('database_connection_method').value;
var pars = Object.toQueryString({
q: url,
host: host,
uid: uid,
pwd: pwd,
database_collation: database_collation,
+ database_connection_method: database_connection_method,
language: language
});
@@ -35,6 +37,7 @@ window.addEvent('domready', function(){
database_name = $('database_name').value;
tableprefix = $('tableprefix').value;
database_collation = $('database_collation').value;
+ database_connection_method = $('database_connection_method').value;
var pars = Object.toQueryString({
q: url,
@@ -44,6 +47,7 @@ window.addEvent('domready', function(){
database_name: database_name,
tableprefix: tableprefix,
database_collation: database_collation,
+ database_connection_method: database_connection_method,
language: language,
installMode: installMode
});
@@ -73,6 +73,7 @@
$_lang["status_checking_database"] = 'Checking database: ';
$_lang["status_failed_could_not_select_database"] = 'failed - could not select database';
$_lang["status_failed_could_not_create_database"] = 'failed - could not create database';
+$_lang["status_failed_database_collation_does_not_match"] = 'failed - database collation mismatch; use SET NAMES or choose %s';
$_lang["status_failed_table_prefix_already_in_use"] = 'failed - table prefix already in use!';
$_lang["welcome_message_welcome"] = 'Welcome to the MODx installation program.';
$_lang["welcome_message_text"] = 'This program will guide you through the rest of the installation.';
@@ -1,6 +1,6 @@
<?php
$version = '0.9.6.3-RC2'; // Current version
-$code_name = 'rev 4367'; // SVN version number
+$code_name = 'rev 4377'; // SVN version number
$full_appname = 'MODx'.' '.$version.($code_name ? " ($code_name)":"");
$small_version = '0';
$patch_level = '0';

0 comments on commit 8ba0788

Please sign in to comment.