]> source.dussan.org Git - nextcloud-server.git/commitdiff
improve error handeling for first run dialog
authorRobin Appelman <icewind1991@gmail.com>
Sun, 17 Apr 2011 09:59:15 +0000 (11:59 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 17 Apr 2011 09:59:15 +0000 (11:59 +0200)
3dparty/MDB2/Schema.php
lib/database.php
lib/installer.php

index a25a6254403ebddc20eebdb7dde6fcf0ac03ca53..25818460a629b6a37f9d5c884429c2bbbb08d34b 100644 (file)
@@ -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);
index 970e43c12272164caf76e39977ee554707337cc1..97651ccf50ad6567f3a8a093fc8cd66c29c909b5 100644 (file)
@@ -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 ){
index 3be3cb44f22a39a6ba6a6a520ffa7760e5823902..14e2be6600f01cbb6781efb0643f9cc0c9b2f73b 100644 (file)
@@ -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;
        }