Fix review items
This commit is contained in:
parent
e93ce26f27
commit
60eb63e35a
|
@ -19,7 +19,7 @@ class DatabaseSetupException extends Exception
|
||||||
}
|
}
|
||||||
|
|
||||||
class OC_Setup {
|
class OC_Setup {
|
||||||
static $db_setup_classes = array(
|
static $dbSetupClasses = array(
|
||||||
'mysql' => '\OC\Setup\MySQL',
|
'mysql' => '\OC\Setup\MySQL',
|
||||||
'pgsql' => '\OC\Setup\PostgreSQL',
|
'pgsql' => '\OC\Setup\PostgreSQL',
|
||||||
'oci' => '\OC\Setup\OCI',
|
'oci' => '\OC\Setup\OCI',
|
||||||
|
@ -48,13 +48,13 @@ class OC_Setup {
|
||||||
$options['directory'] = OC::$SERVERROOT."/data";
|
$options['directory'] = OC::$SERVERROOT."/data";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(self::$db_setup_classes[$dbtype])) {
|
if (!isset(self::$dbSetupClasses[$dbtype])) {
|
||||||
$dbtype = 'sqlite';
|
$dbtype = 'sqlite';
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = self::$db_setup_classes[$dbtype];
|
$class = self::$dbSetupClasses[$dbtype];
|
||||||
$db_setup = new $class(self::getTrans());
|
$dbSetup = new $class(self::getTrans(), 'db_structure.xml');
|
||||||
$error = array_merge($error, $db_setup->validate($options));
|
$error = array_merge($error, $dbSetup->validate($options));
|
||||||
|
|
||||||
if(count($error) != 0) {
|
if(count($error) != 0) {
|
||||||
return $error;
|
return $error;
|
||||||
|
@ -83,8 +83,8 @@ class OC_Setup {
|
||||||
OC_Config::setValue('dbtype', $dbtype);
|
OC_Config::setValue('dbtype', $dbtype);
|
||||||
OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
|
OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
|
||||||
try {
|
try {
|
||||||
$db_setup->initialize($options);
|
$dbSetup->initialize($options);
|
||||||
$db_setup->setupDatabase($username);
|
$dbSetup->setupDatabase($username);
|
||||||
} catch (DatabaseSetupException $e) {
|
} catch (DatabaseSetupException $e) {
|
||||||
$error[] = array(
|
$error[] = array(
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
|
|
|
@ -4,14 +4,16 @@ namespace OC\Setup;
|
||||||
|
|
||||||
abstract class AbstractDatabase {
|
abstract class AbstractDatabase {
|
||||||
protected $trans;
|
protected $trans;
|
||||||
|
protected $dbDefinitionFile;
|
||||||
protected $dbuser;
|
protected $dbuser;
|
||||||
protected $dbpassword;
|
protected $dbpassword;
|
||||||
protected $dbname;
|
protected $dbname;
|
||||||
protected $dbhost;
|
protected $dbhost;
|
||||||
protected $tableprefix;
|
protected $tableprefix;
|
||||||
|
|
||||||
public function __construct($trans) {
|
public function __construct($trans, $dbDefinitionFile) {
|
||||||
$this->trans = $trans;
|
$this->trans = $trans;
|
||||||
|
$this->dbDefinitionFile = $dbDefinitionFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate($config) {
|
public function validate($config) {
|
||||||
|
|
|
@ -172,7 +172,7 @@ class MSSQL extends AbstractDatabase {
|
||||||
\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
|
\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
|
||||||
} else {
|
} else {
|
||||||
if ($row == null) {
|
if ($row == null) {
|
||||||
\OC_DB::createDbFromStructure('db_structure.xml');
|
\OC_DB::createDbFromStructure($this->dbDefinitionFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class MySQL extends AbstractDatabase {
|
||||||
$row=mysql_fetch_row($result);
|
$row=mysql_fetch_row($result);
|
||||||
}
|
}
|
||||||
if(!$result or $row[0]==0) {
|
if(!$result or $row[0]==0) {
|
||||||
\OC_DB::createDbFromStructure('db_structure.xml');
|
\OC_DB::createDbFromStructure($this->dbDefinitionFile);
|
||||||
}
|
}
|
||||||
mysql_close($connection);
|
mysql_close($connection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class OCI extends AbstractDatabase {
|
||||||
$row = oci_fetch_row($stmt);
|
$row = oci_fetch_row($stmt);
|
||||||
}
|
}
|
||||||
if(!$result or $row[0]==0) {
|
if(!$result or $row[0]==0) {
|
||||||
\OC_DB::createDbFromStructure('db_structure.xml');
|
\OC_DB::createDbFromStructure($this->dbDefinitionFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ class PostgreSQL extends AbstractDatabase {
|
||||||
$row = pg_fetch_row($result);
|
$row = pg_fetch_row($result);
|
||||||
}
|
}
|
||||||
if(!$result or $row[0]==0) {
|
if(!$result or $row[0]==0) {
|
||||||
\OC_DB::createDbFromStructure('db_structure.xml');
|
\OC_DB::createDbFromStructure($this->dbDefinitionFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,6 @@ class Sqlite extends AbstractDatabase {
|
||||||
}
|
}
|
||||||
//in case of sqlite, we can always fill the database
|
//in case of sqlite, we can always fill the database
|
||||||
error_log("creating sqlite db");
|
error_log("creating sqlite db");
|
||||||
\OC_DB::createDbFromStructure('db_structure.xml');
|
\OC_DB::createDbFromStructure($this->dbDefinitionFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue