Added a PDO check in the install routine and cleaned it up

This commit is contained in:
Michael 2017-04-25 05:55:20 +00:00
parent 772825690f
commit 49ba2f9d6d

View file

@ -43,26 +43,7 @@ function install_post(App $a) {
require_once("include/dba.php");
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
/*if(get_db_errno()) {
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, '', true);
if(! get_db_errno()) {
$r = q("CREATE DATABASE '%s' DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci",
dbesc($dbdata)
);
if ($r) {
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
} else {
$a->data['db_create_failed']=true;
}
} else {
$a->data['db_conn_failed']=true;
return;
}
}*/
if (get_db_errno()) {
if (!$db->connected) {
$a->data['db_conn_failed'] = true;
}
@ -117,14 +98,6 @@ function install_post(App $a) {
}
}
function get_db_errno() {
if (class_exists('mysqli')) {
return mysqli_connect_errno();
} else {
return mysql_errno();
}
}
function install_content(App $a) {
global $install_wizard_pass, $db;
@ -342,7 +315,7 @@ function check_php(&$phpath, &$checks) {
$help = "";
if (!$passed) {
$help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL;
$help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run background polling via cron. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-poller'>'Setup the poller'</a>") . EOL ;
$help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-poller'>'Setup the poller'</a>") . EOL;
$help .= EOL . EOL;
$tpl = get_markup_template('field_input.tpl');
$help .= replace_macros($tpl, array(
@ -413,7 +386,7 @@ function check_funcs(&$checks) {
check_add($ck_funcs, t('libCurl PHP module'), true, true, "");
check_add($ck_funcs, t('GD graphics PHP module'), true, true, "");
check_add($ck_funcs, t('OpenSSL PHP module'), true, true, "");
check_add($ck_funcs, t('mysqli PHP module'), true, true, "");
check_add($ck_funcs, t('PDO or MySQLi PHP module'), true, true, "");
check_add($ck_funcs, t('mb_string PHP module'), true, true, "");
check_add($ck_funcs, t('XML PHP module'), true, true, "");
check_add($ck_funcs, t('iconv module'), true, true, "");
@ -438,9 +411,9 @@ function check_funcs(&$checks) {
$ck_funcs[2]['status'] = false;
$ck_funcs[2]['help'] = t('Error: openssl PHP module required but not installed.');
}
if (! function_exists('mysqli_connect')){
if (! function_exists('mysqli_connect') && !class_exists('pdo')) {
$ck_funcs[3]['status'] = false;
$ck_funcs[3]['help']= t('Error: mysqli PHP module required but not installed.');
$ck_funcs[3]['help'] = t('Error: PDO or MySQLi PHP module required but not installed.');
}
if (! function_exists('mb_strlen')) {
$ck_funcs[4]['status'] = false;
@ -559,18 +532,6 @@ function load_database($db) {
require_once("include/dbstructure.php");
$errors = update_structure(false, true);
/* $str = file_get_contents('database.sql');
$arr = explode(';',$str);
$errors = false;
foreach($arr as $a) {
if(strlen(trim($a))) {
$r = @$db->q(trim($a));
if(false === $r) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL;
}
}
}*/
return $errors;
}
@ -584,5 +545,3 @@ function what_next() {
.t("Go to your new Friendica node <a href='$baseurl/register'>registration page</a> and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.")
."</p>";
}