From 60eb63e35ade1ef53e907a637d746d93ed906feb Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 27 Jun 2013 20:19:51 +0200 Subject: [PATCH] Fix review items --- lib/setup.php | 14 +++++++------- lib/setup/abstractdatabase.php | 4 +++- lib/setup/mssql.php | 2 +- lib/setup/mysql.php | 2 +- lib/setup/oci.php | 2 +- lib/setup/postgresql.php | 2 +- lib/setup/sqlite.php | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 11c6cc76b6..d8f4cbfbcb 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -19,7 +19,7 @@ class DatabaseSetupException extends Exception } class OC_Setup { - static $db_setup_classes = array( + static $dbSetupClasses = array( 'mysql' => '\OC\Setup\MySQL', 'pgsql' => '\OC\Setup\PostgreSQL', 'oci' => '\OC\Setup\OCI', @@ -48,13 +48,13 @@ class OC_Setup { $options['directory'] = OC::$SERVERROOT."/data"; } - if (!isset(self::$db_setup_classes[$dbtype])) { + if (!isset(self::$dbSetupClasses[$dbtype])) { $dbtype = 'sqlite'; } - $class = self::$db_setup_classes[$dbtype]; - $db_setup = new $class(self::getTrans()); - $error = array_merge($error, $db_setup->validate($options)); + $class = self::$dbSetupClasses[$dbtype]; + $dbSetup = new $class(self::getTrans(), 'db_structure.xml'); + $error = array_merge($error, $dbSetup->validate($options)); if(count($error) != 0) { return $error; @@ -83,8 +83,8 @@ class OC_Setup { OC_Config::setValue('dbtype', $dbtype); OC_Config::setValue('version', implode('.', OC_Util::getVersion())); try { - $db_setup->initialize($options); - $db_setup->setupDatabase($username); + $dbSetup->initialize($options); + $dbSetup->setupDatabase($username); } catch (DatabaseSetupException $e) { $error[] = array( 'error' => $e->getMessage(), diff --git a/lib/setup/abstractdatabase.php b/lib/setup/abstractdatabase.php index 66202251e9..0beada7bd2 100644 --- a/lib/setup/abstractdatabase.php +++ b/lib/setup/abstractdatabase.php @@ -4,14 +4,16 @@ namespace OC\Setup; abstract class AbstractDatabase { protected $trans; + protected $dbDefinitionFile; protected $dbuser; protected $dbpassword; protected $dbname; protected $dbhost; protected $tableprefix; - public function __construct($trans) { + public function __construct($trans, $dbDefinitionFile) { $this->trans = $trans; + $this->dbDefinitionFile = $dbDefinitionFile; } public function validate($config) { diff --git a/lib/setup/mssql.php b/lib/setup/mssql.php index 5ed0d030c7..b8329f9907 100644 --- a/lib/setup/mssql.php +++ b/lib/setup/mssql.php @@ -172,7 +172,7 @@ class MSSQL extends AbstractDatabase { \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN); } else { if ($row == null) { - \OC_DB::createDbFromStructure('db_structure.xml'); + \OC_DB::createDbFromStructure($this->dbDefinitionFile); } } } diff --git a/lib/setup/mysql.php b/lib/setup/mysql.php index 1ab1b6ea8a..0cf04fde5a 100644 --- a/lib/setup/mysql.php +++ b/lib/setup/mysql.php @@ -52,7 +52,7 @@ class MySQL extends AbstractDatabase { $row=mysql_fetch_row($result); } if(!$result or $row[0]==0) { - \OC_DB::createDbFromStructure('db_structure.xml'); + \OC_DB::createDbFromStructure($this->dbDefinitionFile); } mysql_close($connection); } diff --git a/lib/setup/oci.php b/lib/setup/oci.php index cda7ff7c50..577948766b 100644 --- a/lib/setup/oci.php +++ b/lib/setup/oci.php @@ -128,7 +128,7 @@ class OCI extends AbstractDatabase { $row = oci_fetch_row($stmt); } if(!$result or $row[0]==0) { - \OC_DB::createDbFromStructure('db_structure.xml'); + \OC_DB::createDbFromStructure($this->dbDefinitionFile); } } diff --git a/lib/setup/postgresql.php b/lib/setup/postgresql.php index d5b135a957..49fcbf0326 100644 --- a/lib/setup/postgresql.php +++ b/lib/setup/postgresql.php @@ -75,7 +75,7 @@ class PostgreSQL extends AbstractDatabase { $row = pg_fetch_row($result); } if(!$result or $row[0]==0) { - \OC_DB::createDbFromStructure('db_structure.xml'); + \OC_DB::createDbFromStructure($this->dbDefinitionFile); } } diff --git a/lib/setup/sqlite.php b/lib/setup/sqlite.php index 4b0a572bb3..fd4df792d6 100644 --- a/lib/setup/sqlite.php +++ b/lib/setup/sqlite.php @@ -21,6 +21,6 @@ class Sqlite extends AbstractDatabase { } //in case of sqlite, we can always fill the database error_log("creating sqlite db"); - \OC_DB::createDbFromStructure('db_structure.xml'); + \OC_DB::createDbFromStructure($this->dbDefinitionFile); } }