Skip to content

Commit

Permalink
Fixed issue where the installation failed with Ubuntu OS
Browse files Browse the repository at this point in the history
  • Loading branch information
dengenxp committed Jan 1, 2017
1 parent 3e34850 commit 5445a3e
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions public_html/admin/install/classes/installer.class.php
Expand Up @@ -1920,11 +1920,32 @@ private function writeConfig($dbConfigFilePath, array $db)
}

// Write our changes to db-config.php
$result = (@file_put_contents($dbConfigFilePath, $dbConfigData) !== false);
$result = (@file_put_contents($dbConfigFilePath, $dbConfigData, LOCK_EX) !== false);

return $result;
}

/**
* Make sure to include(require) db-config.php
*
* NOTE: In Ubuntu OS (maybe also in similar Linux distros), when include
* db-config.php right after the writeConfig method is called, the read value is
* equal to the value before being changed by the writeConfig method, and an error
* occurs on installation because it is different from the DB information.
* This method is to make sure to read the value changed by the writeConfig method.
*
* @param string $dbConfigFilePath Full path to db-config.php
*/
private function includeConfig($dbConfigFilePath)
{
global $_DB_host, $_DB_name, $_DB_user, $_DB_pass, $_DB_table_prefix,
$_DB_dbms, $_DB_charset;

$dbConfigData = @file_get_contents($dbConfigFilePath);
$dbConfigData =str_replace('<' . '?php', '', $dbConfigData);
eval($dbConfigData);
}

/**
* Change default character set to UTF-8
* NOTE: Yes, this means that we need to patch siteconfig.php a second time.
Expand Down Expand Up @@ -2803,7 +2824,7 @@ private function doDatabaseUpgrades($currentGlVersion, $checkForMessage = false)
}

require $this->env['siteconfig_path'];
require $this->env['dbconfig_path'];
$this->includeConfig($this->env['dbconfig_path']);
}

// Update the GL configuration with the correct paths.
Expand Down Expand Up @@ -3708,7 +3729,7 @@ private function migrateStep2()
}
}

require_once $this->env['dbconfig_path']; // Not sure if this needs to be included..
$this->includeConfig($this->env['dbconfig_path']); // Not sure if this needs to be included..

switch ($_REQUEST['migration_type']) {
case 'select':
Expand Down Expand Up @@ -3955,7 +3976,7 @@ private function migrateStep4()
$this->env['dbconfig_path'] = $_CONF['path'] . 'db-config.php';
}

require_once $this->env['dbconfig_path'];
$this->includeConfig($this->env['dbconfig_path']);
require_once $_CONF['path_system'] . 'lib-database.php';
require_once $_CONF['path_system'] . 'classes/Autoload.php';
Geeklog\Autoload::initialize();
Expand Down Expand Up @@ -4505,7 +4526,7 @@ private function installEngine($installType, $installStep)
}
}

require $this->env['dbconfig_path'];
$this->includeConfig($this->env['dbconfig_path']);
require_once $this->env['siteconfig_path'];
require_once $_CONF['path_system'] . 'lib-database.php';

Expand Down Expand Up @@ -4622,7 +4643,7 @@ private function installEngine($installType, $installStep)
$utf8 = ($this->post('utf8') === 'true') || ($this->get('utf8') === 'true');

// We need all this just to do one DB query
require_once $this->env['dbconfig_path'];
$this->includeConfig($this->env['dbconfig_path']);
require_once $this->env['siteconfig_path'];
require_once $_CONF['path_system'] . 'lib-database.php';

Expand Down Expand Up @@ -4736,7 +4757,7 @@ private function installEngine($installType, $installStep)
$version = $this->get('version', $this->post('version', ''));

// Let's do this
require_once $this->env['dbconfig_path'];
$this->includeConfig($this->env['dbconfig_path']);
require_once $this->env['siteconfig_path'];
require_once $_CONF['path_system'] . 'lib-database.php';

Expand Down

0 comments on commit 5445a3e

Please sign in to comment.