1515use OC \IntegrityCheck \Helpers \AppLocator ;
1616use OC \Migration \SimpleOutput ;
1717use OCP \AppFramework \App ;
18- use OCP \AppFramework \QueryException ;
1918use OCP \DB \ISchemaWrapper ;
2019use OCP \DB \Types ;
20+ use OCP \IConfig ;
2121use OCP \IDBConnection ;
2222use OCP \Migration \IMigrationStep ;
2323use OCP \Migration \IOutput ;
2424use OCP \Server ;
25+ use Psr \Container \NotFoundExceptionInterface ;
2526use Psr \Log \LoggerInterface ;
2627
2728class MigrationService {
@@ -40,6 +41,7 @@ class MigrationService {
4041 */
4142 public function __construct (string $ appName , Connection $ connection , ?IOutput $ output = null , ?AppLocator $ appLocator = null , ?LoggerInterface $ logger = null ) {
4243 $ this ->appName = $ appName ;
44+ $ this ->checkOracle = false ;
4345 $ this ->connection = $ connection ;
4446 if ($ logger === null ) {
4547 $ this ->logger = Server::get (LoggerInterface::class);
@@ -98,7 +100,7 @@ private function createMigrationTable(): bool {
98100 return false ;
99101 }
100102
101- if ($ this ->connection ->tableExists ('migrations ' ) && \OC :: $ server -> getConfig ( )->getAppValue ('core ' , 'vendor ' , '' ) !== 'owncloud ' ) {
103+ if ($ this ->connection ->tableExists ('migrations ' ) && \OCP \Server:: get (IConfig::class )->getAppValue ('core ' , 'vendor ' , '' ) !== 'owncloud ' ) {
102104 $ this ->migrationTableCreated = true ;
103105 return false ;
104106 }
@@ -277,7 +279,7 @@ private function shallBeExecuted($m, $knownMigrations) {
277279 /**
278280 * @param string $version
279281 */
280- private function markAsExecuted ($ version ) {
282+ private function markAsExecuted ($ version ): void {
281283 $ this ->connection ->insertIfNotExist ('*PREFIX*migrations ' , [
282284 'app ' => $ this ->appName ,
283285 'version ' => $ version
@@ -338,7 +340,7 @@ private function getRelativeVersion(string $version, int $delta): ?string {
338340
339341 $ versions = $ this ->getAvailableVersions ();
340342 array_unshift ($ versions , '0 ' );
341- /** @var int $offset */
343+ /** @var int|false $offset */
342344 $ offset = array_search ($ version , $ versions , true );
343345 if ($ offset === false || !isset ($ versions [$ offset + $ delta ])) {
344346 // Unknown version or delta out of bounds.
@@ -353,8 +355,7 @@ private function getCurrentVersion(): string {
353355 if (count ($ m ) === 0 ) {
354356 return '0 ' ;
355357 }
356- $ migrations = array_values ($ m );
357- return @end ($ migrations );
358+ return @end ($ m );
358359 }
359360
360361 /**
@@ -468,21 +469,21 @@ public function describeMigrationStep($to = 'latest') {
468469 * @throws \InvalidArgumentException
469470 */
470471 public function createInstance ($ version ) {
472+ /** @psalm-var class-string<IMigrationStep> $class */
471473 $ class = $ this ->getClass ($ version );
472474 try {
473475 $ s = \OCP \Server::get ($ class );
474-
475- if (!$ s instanceof IMigrationStep) {
476- throw new \InvalidArgumentException ('Not a valid migration ' );
477- }
478- } catch (QueryException $ e ) {
476+ } catch (NotFoundExceptionInterface ) {
479477 if (class_exists ($ class )) {
480478 $ s = new $ class ();
481479 } else {
482480 throw new \InvalidArgumentException ("Migration step ' $ class' is unknown " );
483481 }
484482 }
485483
484+ if (!$ s instanceof IMigrationStep) {
485+ throw new \InvalidArgumentException ('Not a valid migration ' );
486+ }
486487 return $ s ;
487488 }
488489
@@ -493,7 +494,7 @@ public function createInstance($version) {
493494 * @param bool $schemaOnly
494495 * @throws \InvalidArgumentException
495496 */
496- public function executeStep ($ version , $ schemaOnly = false ) {
497+ public function executeStep ($ version , $ schemaOnly = false ): void {
497498 $ instance = $ this ->createInstance ($ version );
498499
499500 if (!$ schemaOnly ) {
@@ -790,7 +791,7 @@ protected function logErrorOrWarning(string $log): void {
790791 }
791792 }
792793
793- private function ensureMigrationsAreLoaded () {
794+ private function ensureMigrationsAreLoaded (): void {
794795 if (empty ($ this ->migrations )) {
795796 $ this ->migrations = $ this ->findMigrations ();
796797 }
0 commit comments