@@ -35,48 +35,48 @@ |
||
35 | 35 | |
36 | 36 | class Version011601Date20230522143227 extends SimpleMigrationStep { |
37 | 37 | |
38 | - public function __construct( |
|
39 | - private IDBConnection $connection, |
|
40 | - private ICrypto $crypto, |
|
41 | - ) { |
|
42 | - } |
|
38 | + public function __construct( |
|
39 | + private IDBConnection $connection, |
|
40 | + private ICrypto $crypto, |
|
41 | + ) { |
|
42 | + } |
|
43 | 43 | |
44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
45 | - /** @var ISchemaWrapper $schema */ |
|
46 | - $schema = $schemaClosure(); |
|
44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
45 | + /** @var ISchemaWrapper $schema */ |
|
46 | + $schema = $schemaClosure(); |
|
47 | 47 | |
48 | - if ($schema->hasTable('oauth2_clients')) { |
|
49 | - $table = $schema->getTable('oauth2_clients'); |
|
50 | - if ($table->hasColumn('secret')) { |
|
51 | - $column = $table->getColumn('secret'); |
|
52 | - $column->setLength(512); |
|
53 | - return $schema; |
|
54 | - } |
|
55 | - } |
|
48 | + if ($schema->hasTable('oauth2_clients')) { |
|
49 | + $table = $schema->getTable('oauth2_clients'); |
|
50 | + if ($table->hasColumn('secret')) { |
|
51 | + $column = $table->getColumn('secret'); |
|
52 | + $column->setLength(512); |
|
53 | + return $schema; |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - return null; |
|
58 | - } |
|
57 | + return null; |
|
58 | + } |
|
59 | 59 | |
60 | - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
61 | - $qbUpdate = $this->connection->getQueryBuilder(); |
|
62 | - $qbUpdate->update('oauth2_clients') |
|
63 | - ->set('secret', $qbUpdate->createParameter('updateSecret')) |
|
64 | - ->where( |
|
65 | - $qbUpdate->expr()->eq('id', $qbUpdate->createParameter('updateId')) |
|
66 | - ); |
|
60 | + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
61 | + $qbUpdate = $this->connection->getQueryBuilder(); |
|
62 | + $qbUpdate->update('oauth2_clients') |
|
63 | + ->set('secret', $qbUpdate->createParameter('updateSecret')) |
|
64 | + ->where( |
|
65 | + $qbUpdate->expr()->eq('id', $qbUpdate->createParameter('updateId')) |
|
66 | + ); |
|
67 | 67 | |
68 | - $qbSelect = $this->connection->getQueryBuilder(); |
|
69 | - $qbSelect->select('id', 'secret') |
|
70 | - ->from('oauth2_clients'); |
|
71 | - $req = $qbSelect->executeQuery(); |
|
72 | - while ($row = $req->fetch()) { |
|
73 | - $id = $row['id']; |
|
74 | - $secret = $row['secret']; |
|
75 | - $encryptedSecret = $this->crypto->encrypt($secret); |
|
76 | - $qbUpdate->setParameter('updateSecret', $encryptedSecret, IQueryBuilder::PARAM_STR); |
|
77 | - $qbUpdate->setParameter('updateId', $id, IQueryBuilder::PARAM_INT); |
|
78 | - $qbUpdate->executeStatement(); |
|
79 | - } |
|
80 | - $req->closeCursor(); |
|
81 | - } |
|
68 | + $qbSelect = $this->connection->getQueryBuilder(); |
|
69 | + $qbSelect->select('id', 'secret') |
|
70 | + ->from('oauth2_clients'); |
|
71 | + $req = $qbSelect->executeQuery(); |
|
72 | + while ($row = $req->fetch()) { |
|
73 | + $id = $row['id']; |
|
74 | + $secret = $row['secret']; |
|
75 | + $encryptedSecret = $this->crypto->encrypt($secret); |
|
76 | + $qbUpdate->setParameter('updateSecret', $encryptedSecret, IQueryBuilder::PARAM_STR); |
|
77 | + $qbUpdate->setParameter('updateId', $id, IQueryBuilder::PARAM_INT); |
|
78 | + $qbUpdate->executeStatement(); |
|
79 | + } |
|
80 | + $req->closeCursor(); |
|
81 | + } |
|
82 | 82 | } |
@@ -32,25 +32,25 @@ |
||
32 | 32 | |
33 | 33 | class Version011602Date20230613160650 extends SimpleMigrationStep { |
34 | 34 | |
35 | - public function __construct( |
|
36 | - ) { |
|
37 | - } |
|
38 | - |
|
39 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
40 | - /** @var ISchemaWrapper $schema */ |
|
41 | - $schema = $schemaClosure(); |
|
42 | - |
|
43 | - if ($schema->hasTable('oauth2_clients')) { |
|
44 | - $table = $schema->getTable('oauth2_clients'); |
|
45 | - if ($table->hasColumn('secret')) { |
|
46 | - $column = $table->getColumn('secret'); |
|
47 | - // we still change the column length in case Version011601Date20230522143227 |
|
48 | - // has run before it was changed to set the length to 512 |
|
49 | - $column->setLength(512); |
|
50 | - return $schema; |
|
51 | - } |
|
52 | - } |
|
53 | - |
|
54 | - return null; |
|
55 | - } |
|
35 | + public function __construct( |
|
36 | + ) { |
|
37 | + } |
|
38 | + |
|
39 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
40 | + /** @var ISchemaWrapper $schema */ |
|
41 | + $schema = $schemaClosure(); |
|
42 | + |
|
43 | + if ($schema->hasTable('oauth2_clients')) { |
|
44 | + $table = $schema->getTable('oauth2_clients'); |
|
45 | + if ($table->hasColumn('secret')) { |
|
46 | + $column = $table->getColumn('secret'); |
|
47 | + // we still change the column length in case Version011601Date20230522143227 |
|
48 | + // has run before it was changed to set the length to 512 |
|
49 | + $column->setLength(512); |
|
50 | + return $schema; |
|
51 | + } |
|
52 | + } |
|
53 | + |
|
54 | + return null; |
|
55 | + } |
|
56 | 56 | } |
@@ -31,51 +31,51 @@ |
||
31 | 31 | * @since 28.0.0 |
32 | 32 | */ |
33 | 33 | class BeforeMessageLoggedEvent extends Event { |
34 | - private int $level; |
|
35 | - private string $app; |
|
36 | - private $message; |
|
34 | + private int $level; |
|
35 | + private string $app; |
|
36 | + private $message; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param string $app |
|
40 | - * @param int $level |
|
41 | - * @param array $message |
|
42 | - * @since 28.0.0 |
|
43 | - */ |
|
44 | - public function __construct(string $app, int $level, array $message) { |
|
45 | - $this->level = $level; |
|
46 | - $this->app = $app; |
|
47 | - $this->message = $message; |
|
48 | - } |
|
38 | + /** |
|
39 | + * @param string $app |
|
40 | + * @param int $level |
|
41 | + * @param array $message |
|
42 | + * @since 28.0.0 |
|
43 | + */ |
|
44 | + public function __construct(string $app, int $level, array $message) { |
|
45 | + $this->level = $level; |
|
46 | + $this->app = $app; |
|
47 | + $this->message = $message; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Get the level of the log item |
|
52 | - * |
|
53 | - * @return int |
|
54 | - * @since 28.0.0 |
|
55 | - */ |
|
56 | - public function getLevel(): int { |
|
57 | - return $this->level; |
|
58 | - } |
|
50 | + /** |
|
51 | + * Get the level of the log item |
|
52 | + * |
|
53 | + * @return int |
|
54 | + * @since 28.0.0 |
|
55 | + */ |
|
56 | + public function getLevel(): int { |
|
57 | + return $this->level; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Get the app context of the log item |
|
63 | - * |
|
64 | - * @return string |
|
65 | - * @since 28.0.0 |
|
66 | - */ |
|
67 | - public function getApp(): string { |
|
68 | - return $this->app; |
|
69 | - } |
|
61 | + /** |
|
62 | + * Get the app context of the log item |
|
63 | + * |
|
64 | + * @return string |
|
65 | + * @since 28.0.0 |
|
66 | + */ |
|
67 | + public function getApp(): string { |
|
68 | + return $this->app; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Get the message of the log item |
|
74 | - * |
|
75 | - * @return array |
|
76 | - * @since 28.0.0 |
|
77 | - */ |
|
78 | - public function getMessage(): array { |
|
79 | - return $this->message; |
|
80 | - } |
|
72 | + /** |
|
73 | + * Get the message of the log item |
|
74 | + * |
|
75 | + * @return array |
|
76 | + * @since 28.0.0 |
|
77 | + */ |
|
78 | + public function getMessage(): array { |
|
79 | + return $this->message; |
|
80 | + } |
|
81 | 81 | } |
@@ -32,50 +32,50 @@ |
||
32 | 32 | use Symfony\Component\Console\Output\OutputInterface; |
33 | 33 | |
34 | 34 | class Disable extends Base { |
35 | - public function __construct( |
|
36 | - protected IUserManager $userManager, |
|
37 | - ) { |
|
38 | - parent::__construct(); |
|
39 | - } |
|
35 | + public function __construct( |
|
36 | + protected IUserManager $userManager, |
|
37 | + ) { |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | 40 | |
41 | - protected function configure() { |
|
42 | - $this |
|
43 | - ->setName('user:disable') |
|
44 | - ->setDescription('disables the specified user') |
|
45 | - ->addArgument( |
|
46 | - 'uid', |
|
47 | - InputArgument::REQUIRED, |
|
48 | - 'the username' |
|
49 | - ); |
|
50 | - } |
|
41 | + protected function configure() { |
|
42 | + $this |
|
43 | + ->setName('user:disable') |
|
44 | + ->setDescription('disables the specified user') |
|
45 | + ->addArgument( |
|
46 | + 'uid', |
|
47 | + InputArgument::REQUIRED, |
|
48 | + 'the username' |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | |
52 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | - $user = $this->userManager->get($input->getArgument('uid')); |
|
54 | - if (is_null($user)) { |
|
55 | - $output->writeln('<error>User does not exist</error>'); |
|
56 | - return 1; |
|
57 | - } |
|
52 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | + $user = $this->userManager->get($input->getArgument('uid')); |
|
54 | + if (is_null($user)) { |
|
55 | + $output->writeln('<error>User does not exist</error>'); |
|
56 | + return 1; |
|
57 | + } |
|
58 | 58 | |
59 | - $user->setEnabled(false); |
|
60 | - $output->writeln('<info>The specified user is disabled</info>'); |
|
61 | - return 0; |
|
62 | - } |
|
59 | + $user->setEnabled(false); |
|
60 | + $output->writeln('<info>The specified user is disabled</info>'); |
|
61 | + return 0; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $argumentName |
|
66 | - * @param CompletionContext $context |
|
67 | - * @return string[] |
|
68 | - */ |
|
69 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
70 | - if ($argumentName === 'uid') { |
|
71 | - return array_map( |
|
72 | - static fn (IUser $user) => $user->getUID(), |
|
73 | - array_filter( |
|
74 | - $this->userManager->search($context->getCurrentWord()), |
|
75 | - static fn (IUser $user) => $user->isEnabled() |
|
76 | - ) |
|
77 | - ); |
|
78 | - } |
|
79 | - return []; |
|
80 | - } |
|
64 | + /** |
|
65 | + * @param string $argumentName |
|
66 | + * @param CompletionContext $context |
|
67 | + * @return string[] |
|
68 | + */ |
|
69 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
70 | + if ($argumentName === 'uid') { |
|
71 | + return array_map( |
|
72 | + static fn (IUser $user) => $user->getUID(), |
|
73 | + array_filter( |
|
74 | + $this->userManager->search($context->getCurrentWord()), |
|
75 | + static fn (IUser $user) => $user->isEnabled() |
|
76 | + ) |
|
77 | + ); |
|
78 | + } |
|
79 | + return []; |
|
80 | + } |
|
81 | 81 | } |
@@ -32,50 +32,50 @@ |
||
32 | 32 | use Symfony\Component\Console\Output\OutputInterface; |
33 | 33 | |
34 | 34 | class Enable extends Base { |
35 | - public function __construct( |
|
36 | - protected IUserManager $userManager, |
|
37 | - ) { |
|
38 | - parent::__construct(); |
|
39 | - } |
|
35 | + public function __construct( |
|
36 | + protected IUserManager $userManager, |
|
37 | + ) { |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | 40 | |
41 | - protected function configure() { |
|
42 | - $this |
|
43 | - ->setName('user:enable') |
|
44 | - ->setDescription('enables the specified user') |
|
45 | - ->addArgument( |
|
46 | - 'uid', |
|
47 | - InputArgument::REQUIRED, |
|
48 | - 'the username' |
|
49 | - ); |
|
50 | - } |
|
41 | + protected function configure() { |
|
42 | + $this |
|
43 | + ->setName('user:enable') |
|
44 | + ->setDescription('enables the specified user') |
|
45 | + ->addArgument( |
|
46 | + 'uid', |
|
47 | + InputArgument::REQUIRED, |
|
48 | + 'the username' |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | |
52 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | - $user = $this->userManager->get($input->getArgument('uid')); |
|
54 | - if (is_null($user)) { |
|
55 | - $output->writeln('<error>User does not exist</error>'); |
|
56 | - return 1; |
|
57 | - } |
|
52 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | + $user = $this->userManager->get($input->getArgument('uid')); |
|
54 | + if (is_null($user)) { |
|
55 | + $output->writeln('<error>User does not exist</error>'); |
|
56 | + return 1; |
|
57 | + } |
|
58 | 58 | |
59 | - $user->setEnabled(true); |
|
60 | - $output->writeln('<info>The specified user is enabled</info>'); |
|
61 | - return 0; |
|
62 | - } |
|
59 | + $user->setEnabled(true); |
|
60 | + $output->writeln('<info>The specified user is enabled</info>'); |
|
61 | + return 0; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $argumentName |
|
66 | - * @param CompletionContext $context |
|
67 | - * @return string[] |
|
68 | - */ |
|
69 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
70 | - if ($argumentName === 'uid') { |
|
71 | - return array_map( |
|
72 | - static fn (IUser $user) => $user->getUID(), |
|
73 | - array_filter( |
|
74 | - $this->userManager->search($context->getCurrentWord()), |
|
75 | - static fn (IUser $user) => !$user->isEnabled() |
|
76 | - ) |
|
77 | - ); |
|
78 | - } |
|
79 | - return []; |
|
80 | - } |
|
64 | + /** |
|
65 | + * @param string $argumentName |
|
66 | + * @param CompletionContext $context |
|
67 | + * @return string[] |
|
68 | + */ |
|
69 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
70 | + if ($argumentName === 'uid') { |
|
71 | + return array_map( |
|
72 | + static fn (IUser $user) => $user->getUID(), |
|
73 | + array_filter( |
|
74 | + $this->userManager->search($context->getCurrentWord()), |
|
75 | + static fn (IUser $user) => !$user->isEnabled() |
|
76 | + ) |
|
77 | + ); |
|
78 | + } |
|
79 | + return []; |
|
80 | + } |
|
81 | 81 | } |
@@ -33,61 +33,61 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class MigrateCommand extends Command implements CompletionAwareInterface { |
36 | - public function __construct( |
|
37 | - private Connection $connection, |
|
38 | - ) { |
|
39 | - parent::__construct(); |
|
40 | - } |
|
36 | + public function __construct( |
|
37 | + private Connection $connection, |
|
38 | + ) { |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | - protected function configure() { |
|
43 | - $this |
|
44 | - ->setName('migrations:migrate') |
|
45 | - ->setDescription('Execute a migration to a specified version or the latest available version.') |
|
46 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
47 | - ->addArgument('version', InputArgument::OPTIONAL, 'The version number (YYYYMMDDHHMMSS) or alias (first, prev, next, latest) to migrate to.', 'latest'); |
|
42 | + protected function configure() { |
|
43 | + $this |
|
44 | + ->setName('migrations:migrate') |
|
45 | + ->setDescription('Execute a migration to a specified version or the latest available version.') |
|
46 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
47 | + ->addArgument('version', InputArgument::OPTIONAL, 'The version number (YYYYMMDDHHMMSS) or alias (first, prev, next, latest) to migrate to.', 'latest'); |
|
48 | 48 | |
49 | - parent::configure(); |
|
50 | - } |
|
49 | + parent::configure(); |
|
50 | + } |
|
51 | 51 | |
52 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | - $appName = $input->getArgument('app'); |
|
54 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
55 | - $version = $input->getArgument('version'); |
|
52 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | + $appName = $input->getArgument('app'); |
|
54 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
55 | + $version = $input->getArgument('version'); |
|
56 | 56 | |
57 | - $ms->migrate($version); |
|
58 | - return 0; |
|
59 | - } |
|
57 | + $ms->migrate($version); |
|
58 | + return 0; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param string $optionName |
|
63 | - * @param CompletionContext $context |
|
64 | - * @return string[] |
|
65 | - */ |
|
66 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
67 | - return []; |
|
68 | - } |
|
61 | + /** |
|
62 | + * @param string $optionName |
|
63 | + * @param CompletionContext $context |
|
64 | + * @return string[] |
|
65 | + */ |
|
66 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
67 | + return []; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @param string $argumentName |
|
72 | - * @param CompletionContext $context |
|
73 | - * @return string[] |
|
74 | - */ |
|
75 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
76 | - if ($argumentName === 'app') { |
|
77 | - $allApps = \OC_App::getAllApps(); |
|
78 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
79 | - } |
|
70 | + /** |
|
71 | + * @param string $argumentName |
|
72 | + * @param CompletionContext $context |
|
73 | + * @return string[] |
|
74 | + */ |
|
75 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
76 | + if ($argumentName === 'app') { |
|
77 | + $allApps = \OC_App::getAllApps(); |
|
78 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
79 | + } |
|
80 | 80 | |
81 | - if ($argumentName === 'version') { |
|
82 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
81 | + if ($argumentName === 'version') { |
|
82 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
83 | 83 | |
84 | - $ms = new MigrationService($appName, $this->connection); |
|
85 | - $migrations = $ms->getAvailableVersions(); |
|
84 | + $ms = new MigrationService($appName, $this->connection); |
|
85 | + $migrations = $ms->getAvailableVersions(); |
|
86 | 86 | |
87 | - array_unshift($migrations, 'next', 'latest'); |
|
88 | - return $migrations; |
|
89 | - } |
|
87 | + array_unshift($migrations, 'next', 'latest'); |
|
88 | + return $migrations; |
|
89 | + } |
|
90 | 90 | |
91 | - return []; |
|
92 | - } |
|
91 | + return []; |
|
92 | + } |
|
93 | 93 | } |
@@ -35,78 +35,78 @@ |
||
35 | 35 | use Symfony\Component\Console\Output\OutputInterface; |
36 | 36 | |
37 | 37 | class ExecuteCommand extends Command implements CompletionAwareInterface { |
38 | - public function __construct( |
|
39 | - private Connection $connection, |
|
40 | - private IConfig $config, |
|
41 | - ) { |
|
42 | - parent::__construct(); |
|
43 | - } |
|
38 | + public function __construct( |
|
39 | + private Connection $connection, |
|
40 | + private IConfig $config, |
|
41 | + ) { |
|
42 | + parent::__construct(); |
|
43 | + } |
|
44 | 44 | |
45 | - protected function configure() { |
|
46 | - $this |
|
47 | - ->setName('migrations:execute') |
|
48 | - ->setDescription('Execute a single migration version manually.') |
|
49 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
50 | - ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
45 | + protected function configure() { |
|
46 | + $this |
|
47 | + ->setName('migrations:execute') |
|
48 | + ->setDescription('Execute a single migration version manually.') |
|
49 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
50 | + ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
51 | 51 | |
52 | - parent::configure(); |
|
53 | - } |
|
52 | + parent::configure(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param InputInterface $input |
|
57 | - * @param OutputInterface $output |
|
58 | - * @return int |
|
59 | - */ |
|
60 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | - $appName = $input->getArgument('app'); |
|
62 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
63 | - $version = $input->getArgument('version'); |
|
55 | + /** |
|
56 | + * @param InputInterface $input |
|
57 | + * @param OutputInterface $output |
|
58 | + * @return int |
|
59 | + */ |
|
60 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | + $appName = $input->getArgument('app'); |
|
62 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
63 | + $version = $input->getArgument('version'); |
|
64 | 64 | |
65 | - if ($this->config->getSystemValue('debug', false) === false) { |
|
66 | - $olderVersions = $ms->getMigratedVersions(); |
|
67 | - $olderVersions[] = '0'; |
|
68 | - $olderVersions[] = 'prev'; |
|
69 | - if (in_array($version, $olderVersions, true)) { |
|
70 | - $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
71 | - return 1; |
|
72 | - } |
|
73 | - } |
|
65 | + if ($this->config->getSystemValue('debug', false) === false) { |
|
66 | + $olderVersions = $ms->getMigratedVersions(); |
|
67 | + $olderVersions[] = '0'; |
|
68 | + $olderVersions[] = 'prev'; |
|
69 | + if (in_array($version, $olderVersions, true)) { |
|
70 | + $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
71 | + return 1; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - $ms->executeStep($version); |
|
77 | - return 0; |
|
78 | - } |
|
76 | + $ms->executeStep($version); |
|
77 | + return 0; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param string $optionName |
|
82 | - * @param CompletionContext $context |
|
83 | - * @return string[] |
|
84 | - */ |
|
85 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
86 | - return []; |
|
87 | - } |
|
80 | + /** |
|
81 | + * @param string $optionName |
|
82 | + * @param CompletionContext $context |
|
83 | + * @return string[] |
|
84 | + */ |
|
85 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
86 | + return []; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param string $argumentName |
|
91 | - * @param CompletionContext $context |
|
92 | - * @return string[] |
|
93 | - */ |
|
94 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
95 | - if ($argumentName === 'app') { |
|
96 | - $allApps = \OC_App::getAllApps(); |
|
97 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
98 | - } |
|
89 | + /** |
|
90 | + * @param string $argumentName |
|
91 | + * @param CompletionContext $context |
|
92 | + * @return string[] |
|
93 | + */ |
|
94 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
95 | + if ($argumentName === 'app') { |
|
96 | + $allApps = \OC_App::getAllApps(); |
|
97 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
98 | + } |
|
99 | 99 | |
100 | - if ($argumentName === 'version') { |
|
101 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
100 | + if ($argumentName === 'version') { |
|
101 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
102 | 102 | |
103 | - $ms = new MigrationService($appName, $this->connection); |
|
104 | - $migrations = $ms->getAvailableVersions(); |
|
103 | + $ms = new MigrationService($appName, $this->connection); |
|
104 | + $migrations = $ms->getAvailableVersions(); |
|
105 | 105 | |
106 | - array_unshift($migrations, 'next', 'latest'); |
|
107 | - return $migrations; |
|
108 | - } |
|
106 | + array_unshift($migrations, 'next', 'latest'); |
|
107 | + return $migrations; |
|
108 | + } |
|
109 | 109 | |
110 | - return []; |
|
111 | - } |
|
110 | + return []; |
|
111 | + } |
|
112 | 112 | } |
@@ -34,109 +34,109 @@ |
||
34 | 34 | use Symfony\Component\Console\Output\OutputInterface; |
35 | 35 | |
36 | 36 | class StatusCommand extends Command implements CompletionAwareInterface { |
37 | - public function __construct( |
|
38 | - private Connection $connection, |
|
39 | - ) { |
|
40 | - parent::__construct(); |
|
41 | - } |
|
37 | + public function __construct( |
|
38 | + private Connection $connection, |
|
39 | + ) { |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function configure() { |
|
44 | - $this |
|
45 | - ->setName('migrations:status') |
|
46 | - ->setDescription('View the status of a set of migrations.') |
|
47 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); |
|
48 | - } |
|
43 | + protected function configure() { |
|
44 | + $this |
|
45 | + ->setName('migrations:status') |
|
46 | + ->setDescription('View the status of a set of migrations.') |
|
47 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); |
|
48 | + } |
|
49 | 49 | |
50 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | - $appName = $input->getArgument('app'); |
|
52 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
50 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | + $appName = $input->getArgument('app'); |
|
52 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
53 | 53 | |
54 | - $infos = $this->getMigrationsInfos($ms); |
|
55 | - foreach ($infos as $key => $value) { |
|
56 | - if (is_array($value)) { |
|
57 | - $output->writeln(" <comment>>></comment> $key:"); |
|
58 | - foreach ($value as $subKey => $subValue) { |
|
59 | - $output->writeln(" <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue); |
|
60 | - } |
|
61 | - } else { |
|
62 | - $output->writeln(" <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value); |
|
63 | - } |
|
64 | - } |
|
65 | - return 0; |
|
66 | - } |
|
54 | + $infos = $this->getMigrationsInfos($ms); |
|
55 | + foreach ($infos as $key => $value) { |
|
56 | + if (is_array($value)) { |
|
57 | + $output->writeln(" <comment>>></comment> $key:"); |
|
58 | + foreach ($value as $subKey => $subValue) { |
|
59 | + $output->writeln(" <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue); |
|
60 | + } |
|
61 | + } else { |
|
62 | + $output->writeln(" <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value); |
|
63 | + } |
|
64 | + } |
|
65 | + return 0; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $optionName |
|
70 | - * @param CompletionContext $context |
|
71 | - * @return string[] |
|
72 | - */ |
|
73 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
74 | - return []; |
|
75 | - } |
|
68 | + /** |
|
69 | + * @param string $optionName |
|
70 | + * @param CompletionContext $context |
|
71 | + * @return string[] |
|
72 | + */ |
|
73 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
74 | + return []; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param string $argumentName |
|
79 | - * @param CompletionContext $context |
|
80 | - * @return string[] |
|
81 | - */ |
|
82 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
83 | - if ($argumentName === 'app') { |
|
84 | - $allApps = \OC_App::getAllApps(); |
|
85 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
86 | - } |
|
87 | - return []; |
|
88 | - } |
|
77 | + /** |
|
78 | + * @param string $argumentName |
|
79 | + * @param CompletionContext $context |
|
80 | + * @return string[] |
|
81 | + */ |
|
82 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
83 | + if ($argumentName === 'app') { |
|
84 | + $allApps = \OC_App::getAllApps(); |
|
85 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
86 | + } |
|
87 | + return []; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @param MigrationService $ms |
|
92 | - * @return array associative array of human readable info name as key and the actual information as value |
|
93 | - */ |
|
94 | - public function getMigrationsInfos(MigrationService $ms) { |
|
95 | - $executedMigrations = $ms->getMigratedVersions(); |
|
96 | - $availableMigrations = $ms->getAvailableVersions(); |
|
97 | - $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations)); |
|
90 | + /** |
|
91 | + * @param MigrationService $ms |
|
92 | + * @return array associative array of human readable info name as key and the actual information as value |
|
93 | + */ |
|
94 | + public function getMigrationsInfos(MigrationService $ms) { |
|
95 | + $executedMigrations = $ms->getMigratedVersions(); |
|
96 | + $availableMigrations = $ms->getAvailableVersions(); |
|
97 | + $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations)); |
|
98 | 98 | |
99 | - $numExecutedUnavailableMigrations = count($executedUnavailableMigrations); |
|
100 | - $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations)); |
|
101 | - $pending = $ms->describeMigrationStep('lastest'); |
|
99 | + $numExecutedUnavailableMigrations = count($executedUnavailableMigrations); |
|
100 | + $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations)); |
|
101 | + $pending = $ms->describeMigrationStep('lastest'); |
|
102 | 102 | |
103 | - $infos = [ |
|
104 | - 'App' => $ms->getApp(), |
|
105 | - 'Version Table Name' => $ms->getMigrationsTableName(), |
|
106 | - 'Migrations Namespace' => $ms->getMigrationsNamespace(), |
|
107 | - 'Migrations Directory' => $ms->getMigrationsDirectory(), |
|
108 | - 'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'), |
|
109 | - 'Current Version' => $this->getFormattedVersionAlias($ms, 'current'), |
|
110 | - 'Next Version' => $this->getFormattedVersionAlias($ms, 'next'), |
|
111 | - 'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'), |
|
112 | - 'Executed Migrations' => count($executedMigrations), |
|
113 | - 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, |
|
114 | - 'Available Migrations' => count($availableMigrations), |
|
115 | - 'New Migrations' => $numNewMigrations, |
|
116 | - 'Pending Migrations' => count($pending) ? $pending : 'None' |
|
117 | - ]; |
|
103 | + $infos = [ |
|
104 | + 'App' => $ms->getApp(), |
|
105 | + 'Version Table Name' => $ms->getMigrationsTableName(), |
|
106 | + 'Migrations Namespace' => $ms->getMigrationsNamespace(), |
|
107 | + 'Migrations Directory' => $ms->getMigrationsDirectory(), |
|
108 | + 'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'), |
|
109 | + 'Current Version' => $this->getFormattedVersionAlias($ms, 'current'), |
|
110 | + 'Next Version' => $this->getFormattedVersionAlias($ms, 'next'), |
|
111 | + 'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'), |
|
112 | + 'Executed Migrations' => count($executedMigrations), |
|
113 | + 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, |
|
114 | + 'Available Migrations' => count($availableMigrations), |
|
115 | + 'New Migrations' => $numNewMigrations, |
|
116 | + 'Pending Migrations' => count($pending) ? $pending : 'None' |
|
117 | + ]; |
|
118 | 118 | |
119 | - return $infos; |
|
120 | - } |
|
119 | + return $infos; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * @param MigrationService $migrationService |
|
124 | - * @param string $alias |
|
125 | - * @return mixed|null|string |
|
126 | - */ |
|
127 | - private function getFormattedVersionAlias(MigrationService $migrationService, $alias) { |
|
128 | - $migration = $migrationService->getMigration($alias); |
|
129 | - //No version found |
|
130 | - if ($migration === null) { |
|
131 | - if ($alias === 'next') { |
|
132 | - return 'Already at latest migration step'; |
|
133 | - } |
|
122 | + /** |
|
123 | + * @param MigrationService $migrationService |
|
124 | + * @param string $alias |
|
125 | + * @return mixed|null|string |
|
126 | + */ |
|
127 | + private function getFormattedVersionAlias(MigrationService $migrationService, $alias) { |
|
128 | + $migration = $migrationService->getMigration($alias); |
|
129 | + //No version found |
|
130 | + if ($migration === null) { |
|
131 | + if ($alias === 'next') { |
|
132 | + return 'Already at latest migration step'; |
|
133 | + } |
|
134 | 134 | |
135 | - if ($alias === 'prev') { |
|
136 | - return 'Already at first migration step'; |
|
137 | - } |
|
138 | - } |
|
135 | + if ($alias === 'prev') { |
|
136 | + return 'Already at first migration step'; |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - return $migration; |
|
141 | - } |
|
140 | + return $migration; |
|
141 | + } |
|
142 | 142 | } |
@@ -33,27 +33,27 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class UpdateTheme extends UpdateJS { |
36 | - public function __construct( |
|
37 | - IMimeTypeDetector $mimetypeDetector, |
|
38 | - protected ICacheFactory $cacheFactory, |
|
39 | - ) { |
|
40 | - parent::__construct($mimetypeDetector); |
|
41 | - } |
|
36 | + public function __construct( |
|
37 | + IMimeTypeDetector $mimetypeDetector, |
|
38 | + protected ICacheFactory $cacheFactory, |
|
39 | + ) { |
|
40 | + parent::__construct($mimetypeDetector); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function configure() { |
|
44 | - $this |
|
45 | - ->setName('maintenance:theme:update') |
|
46 | - ->setDescription('Apply custom theme changes'); |
|
47 | - } |
|
43 | + protected function configure() { |
|
44 | + $this |
|
45 | + ->setName('maintenance:theme:update') |
|
46 | + ->setDescription('Apply custom theme changes'); |
|
47 | + } |
|
48 | 48 | |
49 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
50 | - // run mimetypelist.js update since themes might change mimetype icons |
|
51 | - parent::execute($input, $output); |
|
49 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
50 | + // run mimetypelist.js update since themes might change mimetype icons |
|
51 | + parent::execute($input, $output); |
|
52 | 52 | |
53 | - // cleanup image cache |
|
54 | - $c = $this->cacheFactory->createDistributed('imagePath'); |
|
55 | - $c->clear(''); |
|
56 | - $output->writeln('<info>Image cache cleared</info>'); |
|
57 | - return 0; |
|
58 | - } |
|
53 | + // cleanup image cache |
|
54 | + $c = $this->cacheFactory->createDistributed('imagePath'); |
|
55 | + $c->clear(''); |
|
56 | + $output->writeln('<info>Image cache cleared</info>'); |
|
57 | + return 0; |
|
58 | + } |
|
59 | 59 | } |