From 95f1703979a751bca8ee5be62806248fb6f9a375 Mon Sep 17 00:00:00 2001 From: sminnee Date: Wed, 13 Oct 2010 02:16:27 +0000 Subject: [PATCH] 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 --- install.php | 60 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/install.php b/install.php index 68b86ba..a020bf6 100644 --- a/install.php +++ b/install.php @@ -15,6 +15,9 @@ * 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); error_reporting(E_ALL ^ E_NOTICE); session_start(); @@ -148,16 +151,55 @@ class InstallRequirements { * Just check that the database configuration is okay */ function checkdatabase($databaseConfig) { - if($this->requireFunction('mysql_connect', array("PHP Configuration", "MySQL support", "MySQL support not included in PHP."))) { - $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")); + if($this->requireFunction( + 'mysql_connect', + array( + "PHP Configuration", + "MySQL support", + "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" + ) + ); } + } }