diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-05-24 10:37:33 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-05-24 18:03:10 +0200 |
commit | 80cc8d0028413e6825567e7b635369a70a0bf07a (patch) | |
tree | 3302a662dff92cf9b26ec10578dd3123f7852289 /core/Command | |
parent | fd4a7bf72a0c8a69325b1d63e6983021ac6651f8 (diff) | |
download | nextcloud-server-80cc8d0028413e6825567e7b635369a70a0bf07a.tar.gz nextcloud-server-80cc8d0028413e6825567e7b635369a70a0bf07a.zip |
Emit event when running ./occ db:add-missing-indices
This allows apps to listen to this event in order to also update
indecies there.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'core/Command')
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 314bed8ccb1..82099759366 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org> * @@ -27,6 +28,8 @@ use OCP\IDBConnection; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\GenericEvent; /** * Class AddMissingIndices @@ -41,12 +44,14 @@ class AddMissingIndices extends Command { /** @var IDBConnection */ private $connection; - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; + /** @var EventDispatcherInterface */ + private $dispatcher; + + public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) { parent::__construct(); + + $this->connection = $connection; + $this->dispatcher = $dispatcher; } protected function configure() { @@ -58,6 +63,9 @@ class AddMissingIndices extends Command { protected function execute(InputInterface $input, OutputInterface $output) { $this->addShareTableIndicies($output); + // Dispatch event so apps can also update indexes if needed + $event = new GenericEvent($output); + $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event); } /** @@ -73,8 +81,8 @@ class AddMissingIndices extends Command { $schema = new SchemaWrapper($this->connection); $updated = false; - if ($schema->hasTable("share")) { - $table = $schema->getTable("share"); + if ($schema->hasTable('share')) { + $table = $schema->getTable('share'); if (!$table->hasIndex('share_with_index')) { $output->writeln('<info>Adding additional index to the share table, this can take some time...</info>'); $table->addIndex(['share_with'], 'share_with_index'); |