You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Application.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  7. * @author Christoph Wurst <christoph@owncloud.com>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. namespace OC\Core;
  29. use OC\DB\MissingIndexInformation;
  30. use OC\DB\SchemaWrapper;
  31. use OCP\AppFramework\App;
  32. use OCP\IDBConnection;
  33. use OCP\Util;
  34. use Symfony\Component\EventDispatcher\GenericEvent;
  35. /**
  36. * Class Application
  37. *
  38. * @package OC\Core
  39. */
  40. class Application extends App {
  41. public function __construct() {
  42. parent::__construct('core');
  43. $container = $this->getContainer();
  44. $container->registerService('defaultMailAddress', function () {
  45. return Util::getDefaultEmailAddress('lostpassword-noreply');
  46. });
  47. $server = $container->getServer();
  48. $eventDispatcher = $server->getEventDispatcher();
  49. $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
  50. function(GenericEvent $event) use ($container) {
  51. /** @var MissingIndexInformation $subject */
  52. $subject = $event->getSubject();
  53. $schema = new SchemaWrapper($container->query(IDBConnection::class));
  54. if ($schema->hasTable('share')) {
  55. $table = $schema->getTable('share');
  56. if (!$table->hasIndex('share_with_index')) {
  57. $subject->addHintForMissingSubject($table->getName(), 'share_with_index');
  58. }
  59. if (!$table->hasIndex('parent_index')) {
  60. $subject->addHintForMissingSubject($table->getName(), 'parent_index');
  61. }
  62. if (!$table->hasIndex('owner_index')) {
  63. $subject->addHintForMissingSubject($table->getName(), 'owner_index');
  64. }
  65. if (!$table->hasIndex('initiator_index')) {
  66. $subject->addHintForMissingSubject($table->getName(), 'initiator_index');
  67. }
  68. }
  69. if ($schema->hasTable('filecache')) {
  70. $table = $schema->getTable('filecache');
  71. if (!$table->hasIndex('fs_mtime')) {
  72. $subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
  73. }
  74. }
  75. if ($schema->hasTable('twofactor_providers')) {
  76. $table = $schema->getTable('twofactor_providers');
  77. if (!$table->hasIndex('twofactor_providers_uid')) {
  78. $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid');
  79. }
  80. }
  81. }
  82. );
  83. }
  84. }