diff options
-rw-r--r-- | core/Command/Db/ConvertType.php | 18 | ||||
-rw-r--r-- | lib/private/Installer.php | 36 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 13 |
3 files changed, 25 insertions, 42 deletions
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index d826b6a6c50..907cfc7d331 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -247,17 +247,13 @@ class ConvertType extends Command implements CompletionAwareInterface { $apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps(); foreach ($apps as $app) { $output->writeln('<info> - '.$app.'</info>'); - if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) { - $schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml'); - } else { - // Make sure autoloading works... - \OC_App::loadApp($app); - $fromMS = new MigrationService($app, $fromDB); - $currentMigration = $fromMS->getMigration('current'); - if ($currentMigration !== '0') { - $toMS = new MigrationService($app, $toDB); - $toMS->migrate($currentMigration, true); - } + // Make sure autoloading works... + \OC_App::loadApp($app); + $fromMS = new MigrationService($app, $fromDB); + $currentMigration = $fromMS->getMigration('current'); + if ($currentMigration !== '0') { + $toMS = new MigrationService($app, $toDB); + $toMS->migrate($currentMigration, true); } } } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 2a0fdab87ff..fdf9af7446b 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -46,8 +46,8 @@ use OC\App\AppStore\Fetcher\AppFetcher; use OC\AppFramework\Bootstrap\Coordinator; use OC\Archive\TAR; use OC\DB\Connection; +use OC\DB\MigrationService; use OC_App; -use OC_DB; use OC_Helper; use OCP\Http\Client\IClientService; use OCP\IConfig; @@ -114,6 +114,11 @@ class Installer { } $basedir = $app['path'].'/'.$appId; + + if (is_file($basedir . '/appinfo/database.xml')) { + throw new \Exception('The appinfo/database.xml file is not longer supported. Used in ' . $appId); + } + $info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true); $l = \OC::$server->getL10N('core'); @@ -152,16 +157,9 @@ class Installer { } //install the database - if (is_file($basedir.'/appinfo/database.xml')) { - if (\OC::$server->getConfig()->getAppValue($info['id'], 'installed_version') === null) { - OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml'); - } else { - OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml'); - } - } else { - $ms = new \OC\DB\MigrationService($info['id'], \OC::$server->get(Connection::class)); - $ms->migrate('latest', true); - } + $ms = new MigrationService($info['id'], \OC::$server->get(Connection::class)); + $ms->migrate('latest', true); + if ($previousVersion) { OC_App::executeRepairSteps($appId, $info['repair-steps']['post-migration']); } @@ -601,20 +599,8 @@ class Installer { $appPath = OC_App::getAppPath($app); \OC_App::registerAutoloading($app, $appPath); - if (is_file("$appPath/appinfo/database.xml")) { - try { - OC_DB::createDbFromStructure("$appPath/appinfo/database.xml"); - } catch (TableExistsException $e) { - throw new HintException( - 'Failed to enable app ' . $app, - 'Please ask for help via one of our <a href="https://nextcloud.com/support/" target="_blank" rel="noreferrer noopener">support channels</a>.', - 0, $e - ); - } - } else { - $ms = new \OC\DB\MigrationService($app, \OC::$server->get(Connection::class)); - $ms->migrate('latest', true); - } + $ms = new MigrationService($app, \OC::$server->get(Connection::class)); + $ms->migrate('latest', true); //run appinfo/install.php self::includeAppScript("$appPath/appinfo/install.php"); diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index aeaaf3bf1ea..65365c85e36 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -972,6 +972,11 @@ class OC_App { return false; } + if (is_file($appPath . '/appinfo/database.xml')) { + \OC::$server->getLogger()->error('The appinfo/database.xml file is not longer supported. Used in ' . $appId); + return false; + } + \OC::$server->getAppManager()->clearAppsCache(); $appData = self::getAppInfo($appId); @@ -987,12 +992,8 @@ class OC_App { self::registerAutoloading($appId, $appPath, true); self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); - if (file_exists($appPath . '/appinfo/database.xml')) { - OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); - } else { - $ms = new MigrationService($appId, \OC::$server->get(\OC\DB\Connection::class)); - $ms->migrate(); - } + $ms = new MigrationService($appId, \OC::$server->get(\OC\DB\Connection::class)); + $ms->migrate(); self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']); self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']); |