Merge pull request #99 from steve-lad/Fix-Installer

Installer failed to update db version
This commit is contained in:
Phantom 2021-02-04 14:29:59 +03:00 committed by GitHub
commit 30ba68d03e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 35 deletions

View file

@ -398,14 +398,14 @@ function CheckSCCPManagerDBTables($table_req)
function CheckSCCPManagerDBVersion()
{
global $db;
outn("<li>" . _("Checking for previw version Sccp_manager..") . "</li>");
outn("<li>" . _("Checking for previous version of Sccp_manager.") . "</li>");
$check = $db->getRow("SELECT data FROM `sccpsettings` where keyword ='sccp_compatible'", DB_FETCHMODE_ASSOC);
if (DB::IsError($check)) {
outn(_("Can't find previw version : "));
outn(_("No previous version found "));
return false;
}
if (!empty($check['data'])) {
outn(_("Find DB Schema : " . $check['data']));
outn(_("Found DB Schema : " . $check['data']));
return $check['data'];
} else {
return false;
@ -472,7 +472,7 @@ function InstallDB_Buttons()
KEY `ref` (`ref`,`reftype`)
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
$check = $db->query($sql);
if (db::IsError($check)) {
if (DB::IsError($check)) {
die_freepbx("Can not create sccpbuttonconfig table, error:$check\n");
}
return true;
@ -490,7 +490,7 @@ function InstallDB_sccpsettings()
PRIMARY KEY (`keyword`,`seq`,`type`)
);";
$check = $db->query($sql);
if (db::IsError($check)) {
if (DB::IsError($check)) {
die_freepbx("Can not create sccpsettings table, error:$check\n");
}
return true;
@ -513,7 +513,7 @@ function InstallDB_sccpdevmodel()
KEY `model` (`model`)
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
$check = $db->query($sql);
if (db::IsError($check)) {
if (DB::IsError($check)) {
die_freepbx("Can not create sccpdevmodel table, error:$check\n");
}
return true;
@ -536,7 +536,7 @@ function InstallDB_sccpuser()
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
$check = $db->query($sql);
if (db::IsError($check)) {
if (DB::IsError($check)) {
die_freepbx("Can not create sccpdevmodel table, error:$check\n");
}
return true;
@ -647,7 +647,7 @@ function InstallDB_updateSchema($db_config)
outn("<li>" . _("Create New table") . "</li>");
$sql_create = "ALTER TABLE `" . $tabl_name . "` " . substr($sql_create, 0, -2);
$check = $db->query($sql_create);
if (db::IsError($check)) {
if (DB::IsError($check)) {
die_freepbx("Can not create " . $tabl_name . " table sql: " . $sql_create . "n");
}
}
@ -656,7 +656,7 @@ function InstallDB_updateSchema($db_config)
$sql_modify = "ALTER TABLE `" . $tabl_name . "` " . substr($sql_modify, 0, -2) . ';';
$check = $db->query($sql_modify);
if (db::IsError($check)) {
if (DB::IsError($check)) {
out("<li>" . print_r($check, 1) . "</li>");
die("Can not modify " . $tabl_name . " table sql: " . $sql_modify . "n");
die_freepbx("Can not modify " . $tabl_name . " table sql: " . $sql_modify . "n");
@ -686,7 +686,7 @@ function InstallDB_fillsccpdevmodel()
"('9951-sip', 'CISCO-SIP', 1, 1, 'sip9951.9-2-2SR1-9', 'loadinformation537', 1, 'SEP0000000000.cnf.xml_99xx_sip_template'),".
"('VGC Virtual', 'CISCO', 1, 1, '', 'loadInformation11', 0, NULL);";
$check = $db->query($sql);
if (db::IsError($check)) {
if (DB::IsError($check)) {
die_freepbx("Can not create sccpdevmodel table, error:$check\n");
}
return true;
@ -742,10 +742,10 @@ function InstallDB_updateDBVer($sccp_compatible)
{
global $db;
outn("<li>" . _("Update DB Ver") . "</li>");
$sql = "REPLACE INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`), VALUES ('SccpDBmodel', '". $sccp_compatible. "','30','0');";
$sql = "REPLACE INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`) VALUES ('SccpDBmodel', '". $sccp_compatible. "','30','0');";
$results = $db->query($sql);
if (DB::IsError($check)) {
die_freepbx(sprintf(_("Error updating sccpdeviceconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage()));
if (DB::IsError($results)) {
die_freepbx(sprintf(_("Error updating sccpsettings. Command was: %s; error was: %s "), $sql, $results->getMessage()));
}
return true;
}
@ -830,7 +830,7 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible)
}
}
$results = $db->query($sql);
if (DB::IsError($check)) {
if (DB::IsError($results)) {
die_freepbx(sprintf(_("Error updating sccpdeviceconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage()));
}
return true;
@ -998,10 +998,10 @@ InstallDB_updateDBVer($sccp_compatible);
if (!$sccp_db_ver) {
Setup_RealTime();
outn("<br>");
outn("Install Complite !");
outn("Install Complete !");
} else {
outn("<br>");
outn("Update Complite !");
outn("Update Complete !");
}
outn("<br>");

View file

@ -37,7 +37,7 @@ if (!defined('FREEPBX_IS_AUTH')) {
global $db;
$version = FreePBX::Config()->get('ASTVERSION');
out('Remove all SCCP tables');
out('Removing all Sccp_manager tables');
$tables = array('sccpdevmodel', 'sccpsettings');
foreach ($tables as $table) {
$sql = "DROP TABLE IF EXISTS {$table}";
@ -52,13 +52,13 @@ if (!empty($version)) {
$check = $db->getRow("SELECT 1 FROM `kvstore` LIMIT 0", DB_FETCHMODE_ASSOC);
if (!(DB::IsError($check))) {
//print_r("none, creating table :". $value);
echo "Deleting key FROM kvstore..";
echo "Deleting keys FROM kvstore..";
sql("DELETE FROM kvstore WHERE module = 'sccpsettings'");
sql("DELETE FROM kvstore WHERE module = 'Sccp_manager'");
}
/* Comment: Maybe save in sccpsettings, if the chan_sccp tables already existed in the database or if they were created by install.php */
/* So that you know if it is save to drop/delete them */
/* So that you know if it is safe to drop/delete them */
/* DROP VIEW IF EXISTS`sccpdeviceconfig`;
DROP TABLE IF EXISTS `sccpbuttonconfig`;