@@ -42,50 +42,50 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | class Application extends App { |
| 44 | 44 | |
| 45 | - public function __construct() { |
|
| 46 | - parent::__construct('core'); |
|
| 45 | + public function __construct() { |
|
| 46 | + parent::__construct('core'); |
|
| 47 | 47 | |
| 48 | - $container = $this->getContainer(); |
|
| 48 | + $container = $this->getContainer(); |
|
| 49 | 49 | |
| 50 | - $container->registerService('defaultMailAddress', function () { |
|
| 51 | - return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
| 52 | - }); |
|
| 50 | + $container->registerService('defaultMailAddress', function () { |
|
| 51 | + return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
| 52 | + }); |
|
| 53 | 53 | |
| 54 | - $server = $container->getServer(); |
|
| 55 | - $eventDispatcher = $server->getEventDispatcher(); |
|
| 54 | + $server = $container->getServer(); |
|
| 55 | + $eventDispatcher = $server->getEventDispatcher(); |
|
| 56 | 56 | |
| 57 | - $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
|
| 58 | - function(GenericEvent $event) use ($container) { |
|
| 59 | - /** @var MissingIndexInformation $subject */ |
|
| 60 | - $subject = $event->getSubject(); |
|
| 57 | + $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
|
| 58 | + function(GenericEvent $event) use ($container) { |
|
| 59 | + /** @var MissingIndexInformation $subject */ |
|
| 60 | + $subject = $event->getSubject(); |
|
| 61 | 61 | |
| 62 | - $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
|
| 62 | + $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
|
| 63 | 63 | |
| 64 | - if ($schema->hasTable('share')) { |
|
| 65 | - $table = $schema->getTable('share'); |
|
| 64 | + if ($schema->hasTable('share')) { |
|
| 65 | + $table = $schema->getTable('share'); |
|
| 66 | 66 | |
| 67 | - if (!$table->hasIndex('share_with_index')) { |
|
| 68 | - $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
|
| 69 | - } |
|
| 70 | - if (!$table->hasIndex('parent_index')) { |
|
| 71 | - $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
|
| 72 | - } |
|
| 73 | - if (!$table->hasIndex('owner_index')) { |
|
| 74 | - $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
|
| 75 | - } |
|
| 76 | - if (!$table->hasIndex('initiator_index')) { |
|
| 77 | - $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
|
| 78 | - } |
|
| 79 | - } |
|
| 67 | + if (!$table->hasIndex('share_with_index')) { |
|
| 68 | + $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
|
| 69 | + } |
|
| 70 | + if (!$table->hasIndex('parent_index')) { |
|
| 71 | + $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
|
| 72 | + } |
|
| 73 | + if (!$table->hasIndex('owner_index')) { |
|
| 74 | + $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
|
| 75 | + } |
|
| 76 | + if (!$table->hasIndex('initiator_index')) { |
|
| 77 | + $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if ($schema->hasTable('filecache')) { |
|
| 82 | - $table = $schema->getTable('filecache'); |
|
| 81 | + if ($schema->hasTable('filecache')) { |
|
| 82 | + $table = $schema->getTable('filecache'); |
|
| 83 | 83 | |
| 84 | - if (!$table->hasIndex('fs_mtime')) { |
|
| 85 | - $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - ); |
|
| 90 | - } |
|
| 84 | + if (!$table->hasIndex('fs_mtime')) { |
|
| 85 | + $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -41,94 +41,94 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | class AddMissingIndices extends Command { |
| 43 | 43 | |
| 44 | - /** @var IDBConnection */ |
|
| 45 | - private $connection; |
|
| 46 | - |
|
| 47 | - /** @var EventDispatcherInterface */ |
|
| 48 | - private $dispatcher; |
|
| 49 | - |
|
| 50 | - public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) { |
|
| 51 | - parent::__construct(); |
|
| 52 | - |
|
| 53 | - $this->connection = $connection; |
|
| 54 | - $this->dispatcher = $dispatcher; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - protected function configure() { |
|
| 58 | - $this |
|
| 59 | - ->setName('db:add-missing-indices') |
|
| 60 | - ->setDescription('Add missing indices to the database tables'); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 64 | - $this->addShareTableIndicies($output); |
|
| 65 | - |
|
| 66 | - // Dispatch event so apps can also update indexes if needed |
|
| 67 | - $event = new GenericEvent($output); |
|
| 68 | - $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * add missing indices to the share table |
|
| 73 | - * |
|
| 74 | - * @param OutputInterface $output |
|
| 75 | - * @throws \Doctrine\DBAL\Schema\SchemaException |
|
| 76 | - */ |
|
| 77 | - private function addShareTableIndicies(OutputInterface $output) { |
|
| 78 | - |
|
| 79 | - $output->writeln('<info>Check indices of the share table.</info>'); |
|
| 80 | - |
|
| 81 | - $schema = new SchemaWrapper($this->connection); |
|
| 82 | - $updated = false; |
|
| 83 | - |
|
| 84 | - if ($schema->hasTable('share')) { |
|
| 85 | - $table = $schema->getTable('share'); |
|
| 86 | - if (!$table->hasIndex('share_with_index')) { |
|
| 87 | - $output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>'); |
|
| 88 | - $table->addIndex(['share_with'], 'share_with_index'); |
|
| 89 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 90 | - $updated = true; |
|
| 91 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (!$table->hasIndex('parent_index')) { |
|
| 95 | - $output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>'); |
|
| 96 | - $table->addIndex(['parent'], 'parent_index'); |
|
| 97 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 98 | - $updated = true; |
|
| 99 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - if (!$table->hasIndex('owner_index')) { |
|
| 103 | - $output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>'); |
|
| 104 | - $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 105 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 106 | - $updated = true; |
|
| 107 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - if (!$table->hasIndex('initiator_index')) { |
|
| 111 | - $output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>'); |
|
| 112 | - $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 113 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 114 | - $updated = true; |
|
| 115 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($schema->hasTable('filecache')) { |
|
| 120 | - $table = $schema->getTable('filecache'); |
|
| 121 | - if (!$table->hasIndex('fs_mtime')) { |
|
| 122 | - $output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>'); |
|
| 123 | - $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 124 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 125 | - $updated = true; |
|
| 126 | - $output->writeln('<info>Filecache table updated successfully.</info>'); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if (!$updated) { |
|
| 131 | - $output->writeln('<info>Done.</info>'); |
|
| 132 | - } |
|
| 133 | - } |
|
| 44 | + /** @var IDBConnection */ |
|
| 45 | + private $connection; |
|
| 46 | + |
|
| 47 | + /** @var EventDispatcherInterface */ |
|
| 48 | + private $dispatcher; |
|
| 49 | + |
|
| 50 | + public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) { |
|
| 51 | + parent::__construct(); |
|
| 52 | + |
|
| 53 | + $this->connection = $connection; |
|
| 54 | + $this->dispatcher = $dispatcher; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + protected function configure() { |
|
| 58 | + $this |
|
| 59 | + ->setName('db:add-missing-indices') |
|
| 60 | + ->setDescription('Add missing indices to the database tables'); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 64 | + $this->addShareTableIndicies($output); |
|
| 65 | + |
|
| 66 | + // Dispatch event so apps can also update indexes if needed |
|
| 67 | + $event = new GenericEvent($output); |
|
| 68 | + $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * add missing indices to the share table |
|
| 73 | + * |
|
| 74 | + * @param OutputInterface $output |
|
| 75 | + * @throws \Doctrine\DBAL\Schema\SchemaException |
|
| 76 | + */ |
|
| 77 | + private function addShareTableIndicies(OutputInterface $output) { |
|
| 78 | + |
|
| 79 | + $output->writeln('<info>Check indices of the share table.</info>'); |
|
| 80 | + |
|
| 81 | + $schema = new SchemaWrapper($this->connection); |
|
| 82 | + $updated = false; |
|
| 83 | + |
|
| 84 | + if ($schema->hasTable('share')) { |
|
| 85 | + $table = $schema->getTable('share'); |
|
| 86 | + if (!$table->hasIndex('share_with_index')) { |
|
| 87 | + $output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>'); |
|
| 88 | + $table->addIndex(['share_with'], 'share_with_index'); |
|
| 89 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 90 | + $updated = true; |
|
| 91 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (!$table->hasIndex('parent_index')) { |
|
| 95 | + $output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>'); |
|
| 96 | + $table->addIndex(['parent'], 'parent_index'); |
|
| 97 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 98 | + $updated = true; |
|
| 99 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + if (!$table->hasIndex('owner_index')) { |
|
| 103 | + $output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>'); |
|
| 104 | + $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 105 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 106 | + $updated = true; |
|
| 107 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + if (!$table->hasIndex('initiator_index')) { |
|
| 111 | + $output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>'); |
|
| 112 | + $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 113 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 114 | + $updated = true; |
|
| 115 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($schema->hasTable('filecache')) { |
|
| 120 | + $table = $schema->getTable('filecache'); |
|
| 121 | + if (!$table->hasIndex('fs_mtime')) { |
|
| 122 | + $output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>'); |
|
| 123 | + $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 124 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 125 | + $updated = true; |
|
| 126 | + $output->writeln('<info>Filecache table updated successfully.</info>'); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if (!$updated) { |
|
| 131 | + $output->writeln('<info>Done.</info>'); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | } |