Added the mod to verify if MySQL is version 5.0.51, and also added a verification for strict mode.
This second one was a bit tricky and not easy for me to test since it checks the session.sql_mode variable which will only reset once the session ends so even turning on/off strict mode it will give whaky results. I also have a hard time testing this since my MAMP over writes my edits to my.cnf when I restart the server so I cant turn strict mode on physically, I can only set it to on via a query. There are other ways to test for strict, for example to use the || in a query will fail in strict, and using the auto_increment with a blank value will fail in strict. But for those test a table needs to be created and altered then dropped. Not sure if that is the way to go, then again why not. So if what I cam up with does not work there is an alternative.
So if those of you who have access to a strict mode MySQL server please give this a check and report.
I am attaching the files to test in a zip file. The files affected are action.connection.php and action.summary.php. In action.connection.php I added the check as part of the Test Connection process, and in action.summary.php it is part of the verify db section. I tried my best to code in the same style as the existing code to keep it coherent. For now I have hard coded the messages to make it easy to test.
To test the version check, change the code to check for your current version. I did not make the version check block the installation, it is a warning but the user can continue. Strict mode check is a fail.
Now here is the code added to action.connection.php (adding php tags to get syntax coloring, and make it look cool). I inserted this at about line 34, before the end of the test db section:
<?php
// Mysql version check
$status .= "... Checking MySQL version: ";
if ( version_compare(mysql_get_server_info(), '5.0.51', '=') ) {
$status .= "Atention: The MySQL server version is 5.0.51 ...";
$color = '#ff0000';
} else {
$status .= $_lang['status_passed'];
$color = '#007700';
}
// Mode check
$mysqlmode = @ mysql_query("SELECT @@session.sql_mode");
if (mysql_num_rows($mysqlmode) > 0){
$modes = mysql_fetch_array($mysqlmode, MYSQL_NUM);
foreach ($modes as $mode) {
if (strtoupper($mode) == "STRICT_TRANS_TABLES") {
$mysqlAlert .= "Atention: The MySQL server is in Strict Mode ";
$colorMysql = '#ff0000';
}
}
} else {
$mysqlAlert .= "MySQL server is not in Strict Mode ";
}
?>Also need to make a mod where the error message shows, I kept them apart to keep it clear but they could be displayed together with the others.
And here is the code that was added to action.summary.php, added at @ line 169:
<?php
// check mysql version
if ($conn) {
echo "<p>Checking MySQL version: ";
if ( version_compare(mysql_get_server_info(), '5.0.51', '=') ) {
echo "<span class=\"notok\">" . $_lang['failed'] . "</span></b> 5.0.51</p>";
//$errors += 1; Not an error, just warning?
echo "<p>There are known issues with MySQL 5.0.51. It is recommended that you upgrade before continuing.</p>";
} else {
echo "Your MySQL version is ".mysql_get_server_info()." <span class=\"ok\">" . $_lang['ok'] . "</span></p>";
}
}
// check for strict mode - Edited 250208
if ($conn) {
echo "<p>Checking MySQL for strict mode: ";
$mysqlmode = @ mysql_query("SELECT @@global.sql_mode");
if (mysql_num_rows($mysqlmode) > 0){
$modes = mysql_fetch_array($mysqlmode, MYSQL_NUM);
foreach ($modes as $mode) {
if (strtoupper($mode) == "STRICT_TRANS_TABLES") {
echo "<span class=\"notok\">" . $_lang['failed'] . "</span></b> MySQL is in Strict Mode</p>";
$errors += 1;
echo "<p><span class=\"notok\">MODx requires that strict mode be disabled. You can set the MySQL mode by editing the my.cnf file or contact your server administrator.</span></p>"; // add to lang file
} else {
echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
}
}
} else {
echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
}
}
?>I was not sure about the different $installMode options so may need to tweak this for all options. Uptdate: I tested all options and works as is.
Feel free to toss stones at the code if needed, no ego issues here. I am happy learn from my mistakes
EDIT: Updated the code to fix a bug I found. New files attached