diff --git a/3dparty/MDB2/Schema.php b/3dparty/MDB2/Schema.php index a25a625440..25818460a6 100644 --- a/3dparty/MDB2/Schema.php +++ b/3dparty/MDB2/Schema.php @@ -1338,15 +1338,15 @@ class MDB2_Schema extends PEAR if ($dbExists) { $this->db->debug('Database already exists: ' . $db_name, __FUNCTION__); - if (!empty($dbOptions)) { - $errorcodes = array(MDB2_ERROR_UNSUPPORTED, MDB2_ERROR_NO_PERMISSION); - $this->db->expectError($errorcodes); - $result = $this->db->manager->alterDatabase($db_name, $dbOptions); - $this->db->popExpect(); - if (PEAR::isError($result) && !MDB2::isError($result, $errorcodes)) { - return $result; - } - } +// if (!empty($dbOptions)) { +// $errorcodes = array(MDB2_ERROR_UNSUPPORTED, MDB2_ERROR_NO_PERMISSION); +// $this->db->expectError($errorcodes); +// $result = $this->db->manager->alterDatabase($db_name, $dbOptions); +// $this->db->popExpect(); +// if (PEAR::isError($result) && !MDB2::isError($result, $errorcodes)) { +// return $result; +// } +// } $create = false; } else { $this->db->expectError(MDB2_ERROR_UNSUPPORTED); diff --git a/lib/database.php b/lib/database.php index 970e43c122..97651ccf50 100644 --- a/lib/database.php +++ b/lib/database.php @@ -239,7 +239,7 @@ class OC_DB { // read file $content = file_get_contents( $file ); - + // Make changes and save them to a temporary file $file2 = tempnam( sys_get_temp_dir(), 'oc_db_scheme_' ); $content = str_replace( '*dbname*', $CONFIG_DBNAME, $content ); @@ -247,8 +247,8 @@ class OC_DB { file_put_contents( $file2, $content ); // Try to create tables - $definition = @self::$schema->parseDatabaseDefinitionFile( $file2 ); - + $definition = self::$schema->parseDatabaseDefinitionFile( $file2 ); + // Delete our temporary file unlink( $file2 ); @@ -256,7 +256,10 @@ class OC_DB { if( $definition instanceof MDB2_Schema_Error ){ die( $definition->getMessage().': '.$definition->getUserInfo()); } - $ret=@self::$schema->createDatabase( $definition ); + if(OC_CONFIG::getValue('dbtype','sqlite')=='sqlite'){ + $definition['overwrite']=true;//always overwrite for sqlite + } + $ret=self::$schema->createDatabase( $definition ); // Die in case something went wrong if( $ret instanceof MDB2_Error ){ diff --git a/lib/installer.php b/lib/installer.php index 3be3cb44f2..14e2be6600 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -25,19 +25,19 @@ class OC_INSTALLER{ }; if($dbtype=='mysql'){//mysql needs more config options if(empty($options['dbuser'])){ - $error[]=array('error'=>'database user directory not set'); + $error[]=array('error'=>'database user not set'); }; if(empty($options['dbpass'])){ - $error[]=array('error'=>'database password directory not set'); + $error[]=array('error'=>'database password not set'); }; if(empty($options['dbname'])){ - $error[]=array('error'=>'database name directory not set'); + $error[]=array('error'=>'database name not set'); }; if(empty($options['dbhost'])){ - $error[]=array('error'=>'database host directory not set'); + $error[]=array('error'=>'database host not set'); }; if(!isset($options['dbtableprefix'])){ - $error[]=array('error'=>'database table prefix directory not set'); + $error[]=array('error'=>'database table prefix not set'); }; } if(count($error)==0){ //no errors, good @@ -59,9 +59,9 @@ class OC_INSTALLER{ OC_CONFIG::setValue('dbtableprefix',$dbtableprefix); //check if the database user has admin right - $connection=mysql_connect($dbhost, $dbuser, $dbpass); + $connection=@mysql_connect($dbhost, $dbuser, $dbpass); if(!$connection) { - $error[]=array('error'=>'mysql username and/or password not valid','you need to enter either an existing account, or the administrative account if you wish to create a new user for ownCloud'); + $error[]=array('error'=>'mysql username and/or password not valid','hint'=>'you need to enter either an existing account, or the administrative account if you wish to create a new user for ownCloud'); }else{ $query="SELECT user FROM mysql.user WHERE user='$dbuser'";//this should be enough to check for admin rights in mysql if(mysql_query($query,$connection)){ @@ -79,26 +79,27 @@ class OC_INSTALLER{ //create the database self::createDatabase($dbname,$dbuser,$connection); } + //fill the database if needed + $query="SELECT * FROM $dbname.{$dbtableprefix}users"; + $result = mysql_query($query,$connection); + if (!$result) { + OC_DB::createDbFromStructure('db_structure.xml'); + } + mysql_close($connection); } - //fill the database if needed - $query="SELECT * FROM $dbname.{$dbtableprefix}users"; - $result = mysql_query($query,$connection); - if (!$result) { - OC_DB::createDbFromStructure('db_structure.xml'); - } - mysql_close($connection); }else{ //in case of sqlite, we can always fill the database OC_DB::createDbFromStructure('db_structure.xml'); } - - //create the user and group - OC_USER::createUser($username,$password); - OC_GROUP::createGroup('admin'); - OC_GROUP::addToGroup($username,'admin'); - - //and we are done - OC_CONFIG::setValue('installed',true); + if(count($error)==0){ + //create the user and group + OC_USER::createUser($username,$password); + OC_GROUP::createGroup('admin'); + OC_GROUP::addToGroup($username,'admin'); + + //and we are done + OC_CONFIG::setValue('installed',true); + } } return $error; }