$results = array(
'title' => 'CiviCRM MySQL check',
'severity' => $this::REQUIREMENT_OK,
- 'details' => 'Function mysql_connect() found',
+ 'details' => 'Function mysqli_connect() found',
);
- if (!function_exists('mysql_connect')) {
+ if (!function_exists('mysqli_connect')) {
$results['severity'] = $this::REQUIREMENT_ERROR;
- $results['details'] = 'Function mysql_connect() does not exist';
+ $results['details'] = 'Function mysqli_connect() does not exist';
}
return $results;
'details' => "Connected",
);
- $conn = @mysql_connect($db_config['host'], $db_config['username'], $db_config['password']);
+ $conn = @mysqli_connect($db_config['host'], $db_config['username'], $db_config['password']);
if (!$conn) {
- $results['details'] = mysql_error();
+ $results['details'] = mysqli_connect_error();
$results['severity'] = $this::REQUIREMENT_ERROR;
return $results;
}
- if (!@mysql_select_db($db_config['database'], $conn)) {
- $results['details'] = mysql_error();
+ if (!@mysqli_select_db($conn, $db_config['database'])) {
+ $results['details'] = mysqli_error($conn);
$results['severity'] = $this::REQUIREMENT_ERROR;
return $results;
}
'severity' => $this::REQUIREMENT_OK,
);
- $conn = @mysql_connect($db_config['host'], $db_config['username'], $db_config['password']);
- if (!$conn || !($info = mysql_get_server_info($conn))) {
+ $conn = @mysqli_connect($db_config['host'], $db_config['username'], $db_config['password']);
+ if (!$conn || !($info = mysqli_get_server_info($conn))) {
$results['severity'] = $this::REQUIREMENT_WARNING;
$results['details'] = "Cannot determine the version of MySQL installed. Please ensure at least version {$min} is installed.";
return $results;
'details' => 'Could not determine if MySQL has InnoDB support. Assuming none.',
);
- $conn = @mysql_connect($db_config['host'], $db_config['username'], $db_config['password']);
+ $conn = @mysqli_connect($db_config['host'], $db_config['username'], $db_config['password']);
if (!$conn) {
return $results;
}
$innodb_support = FALSE;
- $result = mysql_query("SHOW ENGINES", $conn);
- while ($values = mysql_fetch_array($result)) {
+ $result = mysqli_query($conn, "SHOW ENGINES");
+ while ($values = mysqli_fetch_array($result)) {
if ($values['Engine'] == 'InnoDB') {
if (strtolower($values['Support']) == 'yes' || strtolower($values['Support']) == 'default') {
$innodb_support = TRUE;
'details' => 'MySQL server supports temporary tables',
);
- $conn = @mysql_connect($db_config['host'], $db_config['username'], $db_config['password']);
+ $conn = @mysqli_connect($db_config['host'], $db_config['username'], $db_config['password']);
if (!$conn) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = "Could not connect to database";
return $results;
}
- if (!@mysql_select_db($db_config['database'], $conn)) {
+ if (!@mysqli_select_db($conn, $db_config['database'])) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = "Could not select the database";
return $results;
}
- $r = mysql_query('CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)', $conn);
+ $r = mysqli_query($conn, 'CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)');
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = "Database does not support creation of temporary tables";
return $results;
}
- mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
+ mysqli_query($conn, 'DROP TEMPORARY TABLE civicrm_install_temp_table_test');
return $results;
}
'details' => 'Database supports MySQL triggers',
);
- $conn = @mysql_connect($db_config['host'], $db_config['username'], $db_config['password']);
+ $conn = @mysqli_connect($db_config['host'], $db_config['username'], $db_config['password']);
if (!$conn) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not connect to database';
return $results;
}
- if (!@mysql_select_db($db_config['database'], $conn)) {
+ if (!@mysqli_select_db($conn, $db_config['database'])) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = "Could not select the database";
return $results;
}
- $r = mysql_query('CREATE TABLE civicrm_install_temp_table_test (test text)', $conn);
+ $r = mysqli_query($conn, 'CREATE TABLE civicrm_install_temp_table_test (test text)');
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not create a table to run test';
return $results;
}
- $r = mysql_query('CREATE TRIGGER civicrm_install_temp_table_test_trigger BEFORE INSERT ON civicrm_install_temp_table_test FOR EACH ROW BEGIN END');
+ $r = mysqli_query($conn, 'CREATE TRIGGER civicrm_install_temp_table_test_trigger BEFORE INSERT ON civicrm_install_temp_table_test FOR EACH ROW BEGIN END');
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Database does not support creation of triggers';
}
else {
- mysql_query('DROP TRIGGER civicrm_install_temp_table_test_trigger');
+ mysqli_query($conn, 'DROP TRIGGER civicrm_install_temp_table_test_trigger');
}
- mysql_query('DROP TABLE civicrm_install_temp_table_test');
+ mysqli_query($conn, 'DROP TABLE civicrm_install_temp_table_test');
return $results;
}
'details' => 'MySQL server auto_increment_increment is 1',
);
- $conn = @mysql_connect($db_config['host'], $db_config['username'], $db_config['password']);
+ $conn = @mysqli_connect($db_config['host'], $db_config['username'], $db_config['password']);
if (!$conn) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not connect to database';
return $results;
}
- $r = mysql_query("SHOW variables like 'auto_increment_increment'", $conn);
+ $r = mysqli_query($conn, "SHOW variables like 'auto_increment_increment'");
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not query database server variables';
return $results;
}
- $values = mysql_fetch_row($r);
+ $values = mysqli_fetch_row($r);
if ($values[1] != 1) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'MySQL server auto_increment_increment is not 1';
'details' => 'MySQL thread_stack is OK',
);
- $conn = @mysql_connect($db_config['server'], $db_config['username'], $db_config['password']);
+ $conn = @mysqli_connect($db_config['server'], $db_config['username'], $db_config['password']);
if (!$conn) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not connect to database';
return $results;
}
- if (!@mysql_select_db($db_config['database'], $conn)) {
+ if (!@mysqli_select_db($conn, $db_config['database'])) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not select the database';
return $results;
}
- $r = mysql_query("SHOW VARIABLES LIKE 'thread_stack'", $conn); // bytes => kb
+ $r = mysqli_query($conn, "SHOW VARIABLES LIKE 'thread_stack'"); // bytes => kb
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not query thread_stack value';
}
else {
- $values = mysql_fetch_row($r);
+ $values = mysqli_fetch_row($r);
if ($values[1] < (1024 * $min_thread_stack)) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'MySQL thread_stack is ' . ($values[1] / 1024) . "kb (minimum required is {$min_thread_stack} kb";
'details' => 'Can successfully lock and unlock tables',
);
- $conn = @mysql_connect($db_config['server'], $db_config['username'], $db_config['password']);
+ $conn = @mysqli_connect($db_config['server'], $db_config['username'], $db_config['password']);
if (!$conn) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not connect to database';
return $results;
}
- if (!@mysql_select_db($db_config['database'], $conn)) {
+ if (!@mysqli_select_db($conn, $db_config['database'])) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not select the database';
- mysql_close($conn);
+ mysqli_close($conn);
return $results;
}
- $r = mysql_query('CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)', $conn);
+ $r = mysqli_query($conn, 'CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)');
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not create a table';
- mysql_close($conn);
+ mysqli_close($conn);
return $results;
}
- $r = mysql_query('LOCK TABLES civicrm_install_temp_table_test WRITE', $conn);
+ $r = mysqli_query($conn, 'LOCK TABLES civicrm_install_temp_table_test WRITE');
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not obtain a write lock';
- mysql_close($conn);
+ mysqli_close($conn);
return $results;
}
- $r = mysql_query('UNLOCK TABLES', $conn);
+ $r = mysqli_query($conn, 'UNLOCK TABLES');
if (!$r) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Could not release table lock';
}
- mysql_close($conn);
+ mysqli_close($conn);
return $results;
}
* $description[2] - The test error to show, if it goes wrong
*/
class InstallRequirements {
- var $errors, $warnings, $tests;
+ var $errors, $warnings, $tests, $conn;
// @see CRM_Upgrade_Form::MINIMUM_THREAD_STACK
const MINIMUM_THREAD_STACK = 192;
* @param $dbName
*/
public function checkdatabase($databaseConfig, $dbName) {
- if ($this->requireFunction('mysql_connect',
+ if ($this->requireFunction('mysqli_connect',
array(
ts("PHP Configuration"),
ts("MySQL support"),
array(
ts("MySQL %1 Configuration", array(1 => $dbName)),
ts("MySQL version at least %1", array(1 => '5.1')),
- ts("MySQL version %1 or higher is required, you are running MySQL %2.", array(1 => '5.1', 2 => mysql_get_server_info())),
- ts("MySQL %1", array(1 => mysql_get_server_info())),
+ ts("MySQL version %1 or higher is required, you are running MySQL %2.", array(1 => '5.1', 2 => mysqli_get_server_info($this->conn))),
+ ts("MySQL %1", array(1 => mysqli_get_server_info($this->conn))),
)
);
$this->requireMySQLAutoIncrementIncrementOne($databaseConfig['server'],
));
// Check for MySQL support
- $this->requireFunction('mysql_connect', array(
+ $this->requireFunction('mysqli_connect', array(
ts("PHP Configuration"),
ts("MySQL support"),
ts("MySQL support not included in PHP."),
*/
public function requireMysqlConnection($server, $username, $password, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $this->conn = @mysqli_connect($server, $username, $password);
- if ($conn) {
+ if ($this->conn) {
return TRUE;
}
else {
- $testDetails[2] .= ": " . mysql_error();
+ $testDetails[2] .= ": " . mysqli_connect_error();
$this->error($testDetails);
}
}
*/
public function requireMySQLServer($server, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, NULL, NULL);
+ $conn = @mysqli_connect($server, NULL, NULL);
- if ($conn || mysql_errno() < 2000) {
+ if ($conn || mysqli_connect_errno() < 2000) {
return TRUE;
}
else {
- $testDetails[2] .= ": " . mysql_error();
+ $testDetails[2] .= ": " . mysqli_connect_error();
$this->error($testDetails);
}
}
public function requireMySQLVersion($version, $testDetails) {
$this->testing($testDetails);
- if (!mysql_get_server_info()) {
+ if (!mysqli_get_server_info($this->conn)) {
$testDetails[2] = ts('Cannot determine the version of MySQL installed. Please ensure at least version %1 is installed.', array(1 => $version));
$this->warning($testDetails);
}
else {
list($majorRequested, $minorRequested) = explode('.', $version);
- list($majorHas, $minorHas) = explode('.', mysql_get_server_info());
+ list($majorHas, $minorHas) = explode('.', mysqli_get_server_info($this->conn));
if (($majorHas > $majorRequested) || ($majorHas == $majorRequested && $minorHas >= $minorRequested)) {
return TRUE;
*/
public function requireMySQLInnoDB($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
if (!$conn) {
$testDetails[2] .= ' ' . ts("Could not determine if MySQL has InnoDB support. Assuming no.");
$this->error($testDetails);
}
$innodb_support = FALSE;
- $result = mysql_query("SHOW ENGINES", $conn);
- while ($values = mysql_fetch_array($result)) {
+ $result = mysqli_query($conn, "SHOW ENGINES");
+ while ($values = mysqli_fetch_array($result)) {
if ($values['Engine'] == 'InnoDB') {
if (strtolower($values['Support']) == 'yes' ||
strtolower($values['Support']) == 'default'
*/
public function requireMySQLTempTables($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not login to the database.');
$this->error($testDetails);
return;
}
- if (!@mysql_select_db($database, $conn)) {
+ if (!@mysqli_select_db($conn, $database)) {
$testDetails[2] = ts('Could not select the database.');
$this->error($testDetails);
return;
}
- $result = mysql_query('CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)', $conn);
+ $result = mysqli_query($conn, 'CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)');
if (!$result) {
$testDetails[2] = ts('Could not create a temp table.');
$this->error($testDetails);
}
- $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
+ $result = mysqli_query($conn, 'DROP TEMPORARY TABLE civicrm_install_temp_table_test');
}
/**
*/
public function requireMySQLTrigger($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not login to the database.');
$this->error($testDetails);
return;
}
- if (!@mysql_select_db($database, $conn)) {
+ if (!@mysqli_select_db($conn, $database)) {
$testDetails[2] = ts('Could not select the database.');
$this->error($testDetails);
return;
}
- $result = mysql_query('CREATE TABLE civicrm_install_temp_table_test (test text)', $conn);
+ $result = mysqli_query($conn, 'CREATE TABLE civicrm_install_temp_table_test (test text)');
if (!$result) {
$testDetails[2] = ts('Could not create a table in the database.');
$this->error($testDetails);
}
- $result = mysql_query('CREATE TRIGGER civicrm_install_temp_table_test_trigger BEFORE INSERT ON civicrm_install_temp_table_test FOR EACH ROW BEGIN END');
+ $result = mysqli_query($conn, 'CREATE TRIGGER civicrm_install_temp_table_test_trigger BEFORE INSERT ON civicrm_install_temp_table_test FOR EACH ROW BEGIN END');
if (!$result) {
- mysql_query('DROP TABLE civicrm_install_temp_table_test');
+ mysqli_query($conn, 'DROP TABLE civicrm_install_temp_table_test');
$testDetails[2] = ts('Could not create a database trigger.');
$this->error($testDetails);
}
- mysql_query('DROP TRIGGER civicrm_install_temp_table_test_trigger');
- mysql_query('DROP TABLE civicrm_install_temp_table_test');
+ mysqli_query($conn, 'DROP TRIGGER civicrm_install_temp_table_test_trigger');
+ mysqli_query($conn, 'DROP TABLE civicrm_install_temp_table_test');
}
*/
public function requireMySQLLockTables($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not connect to the database server.');
$this->error($testDetails);
return;
}
- if (!@mysql_select_db($database, $conn)) {
+ if (!@mysqli_select_db($conn, $database)) {
$testDetails[2] = ts('Could not select the database.');
$this->error($testDetails);
return;
}
- $result = mysql_query('CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)', $conn);
+ $result = mysqli_query($conn, 'CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)');
if (!$result) {
$testDetails[2] = ts('Could not create a table in the database.');
$this->error($testDetails);
return;
}
- $result = mysql_query('LOCK TABLES civicrm_install_temp_table_test WRITE', $conn);
+ $result = mysqli_query($conn, 'LOCK TABLES civicrm_install_temp_table_test WRITE');
if (!$result) {
$testDetails[2] = ts('Could not obtain a write lock for the database table.');
$this->error($testDetails);
- $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
+ $result = mysqli_query($conn, 'DROP TEMPORARY TABLE civicrm_install_temp_table_test');
return;
}
- $result = mysql_query('UNLOCK TABLES', $conn);
+ $result = mysqli_query($conn, 'UNLOCK TABLES');
if (!$result) {
$testDetails[2] = ts('Could not release the lock for the database table.');
$this->error($testDetails);
- $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
+ $result = mysqli_query($conn, 'DROP TEMPORARY TABLE civicrm_install_temp_table_test');
return;
}
- $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
+ $result = mysqli_query($conn, 'DROP TEMPORARY TABLE civicrm_install_temp_table_test');
}
/**
*/
public function requireMySQLAutoIncrementIncrementOne($server, $username, $password, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not connect to the database server.');
$this->error($testDetails);
return;
}
- $result = mysql_query("SHOW variables like 'auto_increment_increment'", $conn);
+ $result = mysqli_query($conn, "SHOW variables like 'auto_increment_increment'");
if (!$result) {
$testDetails[2] = ts('Could not query database server variables.');
$this->error($testDetails);
return;
}
else {
- $values = mysql_fetch_row($result);
+ $values = mysqli_fetch_row($result);
if ($values[1] == 1) {
$testDetails[3] = ts('MySQL server auto_increment_increment is 1');
}
*/
public function requireMySQLThreadStack($server, $username, $password, $database, $minValueKB, $testDetails) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not connect to the database server.');
$this->error($testDetails);
return;
}
- if (!@mysql_select_db($database, $conn)) {
+ if (!@mysqli_select_db($conn, $database)) {
$testDetails[2] = ts('Could not select the database.');
$this->error($testDetails);
return;
}
- $result = mysql_query("SHOW VARIABLES LIKE 'thread_stack'", $conn); // bytes => kb
+ $result = mysqli_query($conn, "SHOW VARIABLES LIKE 'thread_stack'"); // bytes => kb
if (!$result) {
$testDetails[2] = ts('Could not get information about the thread_stack of the database.');
$this->error($testDetails);
}
else {
- $values = mysql_fetch_row($result);
+ $values = mysqli_fetch_row($result);
if ($values[1] < (1024 * $minValueKB)) {
$testDetails[2] = ts('MySQL "thread_stack" is %1 kb', array(1 => ($values[1] / 1024)));
$this->error($testDetails);
$onlyRequire = FALSE
) {
$this->testing($testDetails);
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
$okay = NULL;
- if (@mysql_select_db($database)) {
+ if (@mysqli_select_db($conn, $database)) {
$okay = "Database '$database' exists";
}
elseif ($onlyRequire) {
return;
}
else {
- $query = sprintf("CREATE DATABASE %s", mysql_real_escape_string($database));
- if (@mysql_query($query)) {
+ $query = sprintf("CREATE DATABASE %s", mysqli_real_escape_string($conn, $database));
+ if (@mysqli_query($conn, $query)) {
$okay = ts("Able to create a new database.");
}
else {
* @param $database
*/
public function createDatabaseIfNotExists($server, $username, $password, $database) {
- $conn = @mysql_connect($server, $username, $password);
+ $conn = @mysqli_connect($server, $username, $password);
- if (@mysql_select_db($database)) {
+ if (@mysqli_select_db($conn, $database)) {
// skip if database already present
return;
}
- $query = sprintf("CREATE DATABASE %s", mysql_real_escape_string($database));
- if (@mysql_query($query)) {
+ $query = sprintf("CREATE DATABASE %s", mysqli_real_escape_string($conn, $database));
+ if (@mysqli_query($conn, $query)) {
}
else {
$errorTitle = ts("Oops! Could not create database %1", array(1 => $database));