diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-06-04 16:20:01 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-06-06 16:55:01 +0200 |
commit | 393d9aae74862e14e80223e44880f4f706c88d6f (patch) | |
tree | 37e2db4534c2c5f3f29672228e88543d1895c74f /core/Application.php | |
parent | f13c2b20b6fa2048b30687aa3a85e706b70f2500 (diff) | |
download | nextcloud-server-393d9aae74862e14e80223e44880f4f706c88d6f.tar.gz nextcloud-server-393d9aae74862e14e80223e44880f4f706c88d6f.zip |
Add a hint that some indexes are not added yet
* gives the admin a chance to discover the missing indexes and improve the performance of the instance without digging through the manual
* nicely integrated in the setup checks where this kind of hints belong to
* also adds an option to integrate this from an app based on events
* fix style of setting warnings
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'core/Application.php')
-rw-r--r-- | core/Application.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/Application.php b/core/Application.php index 9a29b4bcdff..400d86f5991 100644 --- a/core/Application.php +++ b/core/Application.php @@ -28,8 +28,12 @@ namespace OC\Core; +use OC\DB\MissingIndexInformation; +use OC\DB\SchemaWrapper; use OCP\AppFramework\App; +use OCP\IDBConnection; use OCP\Util; +use Symfony\Component\EventDispatcher\GenericEvent; /** * Class Application @@ -46,5 +50,28 @@ class Application extends App { $container->registerService('defaultMailAddress', function () { return Util::getDefaultEmailAddress('lostpassword-noreply'); }); + + $server = $container->getServer(); + $eventDispatcher = $server->getEventDispatcher(); + + $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, + function(GenericEvent $event) use ($container) { + /** @var MissingIndexInformation $subject */ + $subject = $event->getSubject(); + + $schema = new SchemaWrapper($container->query(IDBConnection::class)); + + if ($schema->hasTable('share')) { + $table = $schema->getTable('share'); + + if (!$table->hasIndex('share_with_index')) { + $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); + } + if (!$table->hasIndex('parent_index')) { + $subject->addHintForMissingSubject($table->getName(), 'parent_index'); + } + } + } + ); } } |