installer: missing files

This commit is contained in:
Taras Machyshyn
2014-08-15 17:12:26 +03:00
parent 4ca099afc4
commit 1dbe2d9eac
2 changed files with 52 additions and 11 deletions
+27 -8
View File
@@ -148,7 +148,7 @@ class Installer
*/
public function saveData($database, $language)
{
$initData = include('install/core/init/config.php');
$initData = include('install/core/afterInstall/config.php');
$siteUrl = $this->getSystemHelper()->getBaseUrl();
@@ -194,9 +194,7 @@ class Installer
if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) {
$preferences['currencyList'] = array($preferences['defaultCurrency']);
$preferences['currency'] = $this->getConfig()->get('currency');
$preferences['currency']['base'] = $preferences['defaultCurrency'];
$preferences['baseCurrency'] = $preferences['defaultCurrency'];
}
$res = $this->saveConfig($preferences);
@@ -210,7 +208,7 @@ class Installer
protected function createRecords()
{
$records = include('install/core/init/records.php');
$records = include('install/core/afterInstall/records.php');
$result = true;
foreach ($records as $entityName => $recordList) {
@@ -271,8 +269,6 @@ class Installer
$result = $this->createRecord('User', $user);
$result &= $this->createRecords();
return $result;
}
@@ -315,9 +311,16 @@ class Installer
public function setSuccess()
{
$this->auth();
/** afterInstall scripts */
$result = $this->createRecords();
$result &= $this->executeQueries();
/** END: afterInstall scripts */
$config = $this->app->getContainer()->get('config');
$config->set('isInstalled', true);
$result = $config->save();
$result &= $config->save();
return $result;
}
@@ -379,5 +382,21 @@ class Installer
return $this->getContainer()->get('scheduledJob')->getSetupMessage();
}
protected function executeQueries()
{
$queries = include('install/core/afterInstall/queries.php');
$pdo = $this->getEntityManager()->getPDO();
$result = true;
foreach ($queries as $query) {
$sth = $pdo->prepare($query);
$result =& $sth->execute();
}
return $result;
}
}
+25 -3
View File
@@ -76,7 +76,7 @@ class SystemHelper extends \Espo\Core\Utils\System
return $result;
}
public function checkDbConnection($hostName, $port ,$dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql')
public function checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver = 'pdo_mysql', $isCreateDatabase = true)
{
$result['success'] = true;
@@ -104,6 +104,28 @@ class SystemHelper extends \Espo\Core\Utils\System
$result['errors']['dbConnect']['errorMsg'] = $e->getMessage();
$result['success'] = false;
}
/** try to create a database */
if ($isCreateDatabase && !$result['success'] && $result['errors']['dbConnect']['errorCode'] == '1049') {
$dsn = "mysql:host={$hostName};" . ((!empty($port)) ? "port={$port}" : '');
$pdo = new PDO($dsn, $dbUserName, $dbUserPass);
$isCreated = true;
try {
$pdo->query("CREATE DATABASE IF NOT EXISTS `$dbName`");
} catch (PDOException $e) {
$isCreated = false;
}
if ($isCreated) {
return $this->checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName, $dbDriver, false);
}
}
/** END: try to create a database */
break;
}
@@ -185,8 +207,8 @@ class SystemHelper extends \Espo\Core\Utils\System
$commands[] = $this->getCd();
}
$commands[] = 'find '.$path.' -type f -exec ' .$sudoStr.'chmod '.$bufPerm[0].' {} +';
$commands[] = 'find '.$path.' -type d -exec ' .$sudoStr. 'chmod '.$bufPerm[1].' {} +';
$commands[] = 'find '.$path.' -type f -exec ' .$sudoStr.'chmod '.$bufPerm[0].' {} +';//.'chmod '.$bufPerm[0].' $(find '.$path.' -type f)';
$commands[] = 'find '.$path.' -type d -exec ' .$sudoStr. 'chmod '.$bufPerm[1].' {} +';//.'chmod '.$bufPerm[1].' $(find '.$path.' -type d)';
if (count($permissions) >= 2) {
return implode(' ' . $this->combineOperator . ' ', $commands);