Fix copyRows() return value. Generate app info and oc info on return
This commit is contained in:
parent
9c032ecc33
commit
1cdb4396a4
|
@ -50,7 +50,7 @@ if (isset($_POST['user_migrate'])) {
|
||||||
// Call to OC_Migrate for the xml file.
|
// Call to OC_Migrate for the xml file.
|
||||||
|
|
||||||
// Create migration.db
|
// Create migration.db
|
||||||
var_dump(OC_Migrate::export(OC_User::getUser()));
|
OC_Migrate::export(OC_User::getUser());
|
||||||
// Add export db to zip
|
// Add export db to zip
|
||||||
$zip->addFile($root.'data/'.$user.'/migration.db', "migration.db");
|
$zip->addFile($root.'data/'.$user.'/migration.db', "migration.db");
|
||||||
|
|
||||||
|
|
|
@ -65,21 +65,43 @@ class OC_Migrate{
|
||||||
|
|
||||||
// Foreach provider
|
// Foreach provider
|
||||||
foreach( self::$providers as $provider ){
|
foreach( self::$providers as $provider ){
|
||||||
// Check for database.xml
|
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
// Does this app use the database?
|
||||||
if(file_exists(OC::$SERVERROOT.'/apps/'.$provider->id.'/appinfo/database.xml')){
|
if(file_exists(OC::$SERVERROOT.'/apps/'.$provider->id.'/appinfo/database.xml')){
|
||||||
$ok = self::createAppTables( $provider->id );
|
// Create some app tables
|
||||||
|
$tables = self::createAppTables( $provider->id );
|
||||||
|
if( is_array( $tables ) ){
|
||||||
|
// Save the table names
|
||||||
|
foreach($tables as $table){
|
||||||
|
$return['app'][$provider->id]['tables'][] = $table;
|
||||||
}
|
}
|
||||||
if($ok){
|
|
||||||
// Run the export function provided by the providor
|
|
||||||
$return[$provider->id]['success'] = $provider->export( $uid );
|
|
||||||
} else {
|
} else {
|
||||||
// Log the error
|
// It failed to create the tables
|
||||||
OC_Log::write('migration','failed to create migration tables for: '.$provider->id,OC_Log::INFO);
|
$failed = true;
|
||||||
$return[$provider->id]['success'] = 'false';
|
|
||||||
$return[$provider->id]['message'] = 'failed to create the app tables';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run the import function?
|
||||||
|
if( !$failed ){
|
||||||
|
$return['app'][$provider->id]['success'] = $provider->export( $uid );
|
||||||
|
} else {
|
||||||
|
$return['app'][$provider->id]['success'] = false;
|
||||||
|
$return['app'][$provider->id]['message'] = 'failed to create the app tables';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now add some app info the the return array
|
||||||
|
$appinfo = OC_App::getAppInfo( $provider->id );
|
||||||
|
$return['app'][$provider->id]['version'] = $appinfo['version'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add some general info to the return array
|
||||||
|
$return['migrateinfo']['uid'] = $uid;
|
||||||
|
$return['migrateinfo']['ocversion'] = OC_Util::getVersionString();
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -289,20 +311,23 @@ class OC_Migrate{
|
||||||
// @param $appid string id of the app
|
// @param $appid string id of the app
|
||||||
// @return bool whether the operation was successful
|
// @return bool whether the operation was successful
|
||||||
private static function createAppTables( $appid ){
|
private static function createAppTables( $appid ){
|
||||||
$file = OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/database.xml';
|
|
||||||
if(file_exists( $file )){
|
|
||||||
|
|
||||||
if(!self::connectScheme()){
|
if(!self::connectScheme()){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is a database.xml file
|
// There is a database.xml file
|
||||||
$content = file_get_contents( $file );
|
$content = file_get_contents( OC::$SERVERROOT . '/apps/' . $appid . '/appinfo/database.xml' );
|
||||||
|
|
||||||
$file2 = 'static://db_scheme';
|
$file2 = 'static://db_scheme';
|
||||||
$content = str_replace( '*dbname*', self::$uid.'/migration', $content );
|
$content = str_replace( '*dbname*', self::$uid.'/migration', $content );
|
||||||
$content = str_replace( '*dbprefix*', '', $content );
|
$content = str_replace( '*dbprefix*', '', $content );
|
||||||
|
|
||||||
|
$xml = new SimpleXMLElement($content);
|
||||||
|
foreach($xml->table as $table){
|
||||||
|
$tables[] = (string)$table->name;
|
||||||
|
}
|
||||||
|
|
||||||
file_put_contents( $file2, $content );
|
file_put_contents( $file2, $content );
|
||||||
|
|
||||||
// Try to create tables
|
// Try to create tables
|
||||||
|
@ -327,12 +352,8 @@ class OC_Migrate{
|
||||||
OC_Log::write('migration',$ret->getMessage().': '.$ret->getUserInfo(),OC_Log::FATAL);
|
OC_Log::write('migration',$ret->getMessage().': '.$ret->getUserInfo(),OC_Log::FATAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return $tables;
|
||||||
|
|
||||||
} else {
|
|
||||||
// No database.xml
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue