ENHANCEMENT #4742 Set lower timeout for mysql_connect to avoid long timeouts when mysql_connect can't find a MySQL server locally during SS install, and only do certain MySQL checks if the server can be found, greatly improving install performance (from r93106)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@112081 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
sminnee 2010-10-13 02:16:27 +00:00
parent be07c8ca3f
commit 95f1703979

View File

@ -15,6 +15,9 @@
* It's also PHP4 syntax compatable * It's also PHP4 syntax compatable
*/ */
// speed up mysql_connect timeout if the server can't be found
ini_set('mysql.connect_timeout', 5);
ini_set('max_execution_time', 0); ini_set('max_execution_time', 0);
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL ^ E_NOTICE);
session_start(); session_start();
@ -148,15 +151,54 @@ class InstallRequirements {
* Just check that the database configuration is okay * Just check that the database configuration is okay
*/ */
function checkdatabase($databaseConfig) { function checkdatabase($databaseConfig) {
if($this->requireFunction('mysql_connect', array("PHP Configuration", "MySQL support", "MySQL support not included in PHP."))) { if($this->requireFunction(
$this->requireMySQLServer($databaseConfig['server'], array("MySQL Configuration", "Does the server exist", 'mysql_connect',
"I couldn't find a MySQL server on '$databaseConfig[server]'", $databaseConfig['server'])); array(
if($this->requireMysqlConnection($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], "PHP Configuration",
array("MySQL Configuration", "Are the access credentials correct", "That username/password doesn't work"))) { "MySQL support",
@$this->requireMySQLVersion("4.1", array("MySQL Configuration", "MySQL version at least 4.1", "MySQL version 4.1 is required, you only have ", "MySQL " . mysql_get_server_info())); "MySQL support not included in PHP.")
)
) {
if($this->requireMySQLServer(
$databaseConfig['server'],
array(
"MySQL Configuration",
"Does the server exist",
"I couldn't find a MySQL server on '$databaseConfig[server]'", $databaseConfig['server']
)
)) {
if($this->requireMysqlConnection(
$databaseConfig['server'],
$databaseConfig['username'],
$databaseConfig['password'],
array(
"MySQL Configuration",
"Are the access credentials correct",
"That username/password doesn't work"
)
)) {
@$this->requireMySQLVersion(
"4.1",
array(
"MySQL Configuration",
"MySQL version at least 4.1",
"MySQL version 4.1 is required, you only have ",
"MySQL " . mysql_get_server_info()
)
);
}
$this->requireDatabaseOrCreatePermissions(
$databaseConfig['server'],
$databaseConfig['username'],
$databaseConfig['password'],
$databaseConfig['database'],
array(
"MySQL Configuration",
"Can I access/create the database",
"I can't create new databases and the database '$databaseConfig[database]' doesn't exist"
)
);
} }
$this->requireDatabaseOrCreatePermissions($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'],
array("MySQL Configuration", "Can I access/create the database", "I can't create new databases and the database '$databaseConfig[database]' doesn't exist"));
} }
} }