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 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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\Authentication\Notifications\Notifier as AuthenticationNotifier;
  30. use OC\Core\Notification\RemoveLinkSharesNotifier;
  31. use OC\DB\MissingIndexInformation;
  32. use OC\DB\SchemaWrapper;
  33. use OCP\AppFramework\App;
  34. use OCP\IDBConnection;
  35. use OCP\Util;
  36. use Symfony\Component\EventDispatcher\GenericEvent;
  37. /**
  38. * Class Application
  39. *
  40. * @package OC\Core
  41. */
  42. class Application extends App {
  43. public function __construct() {
  44. parent::__construct('core');
  45. $container = $this->getContainer();
  46. $container->registerService('defaultMailAddress', function () {
  47. return Util::getDefaultEmailAddress('lostpassword-noreply');
  48. });
  49. $server = $container->getServer();
  50. $eventDispatcher = $server->getEventDispatcher();
  51. $notificationManager = $server->getNotificationManager();
  52. $notificationManager->registerNotifier(function() use ($server) {
  53. return new RemoveLinkSharesNotifier(
  54. $server->getL10NFactory()
  55. );
  56. }, function() {
  57. return [
  58. 'id' => 'core',
  59. 'name' => 'core',
  60. ];
  61. });
  62. $notificationManager->registerNotifier(function() use ($server) {
  63. return $server->query(AuthenticationNotifier::class);
  64. }, function() {
  65. return [
  66. 'id' => 'auth',
  67. 'name' => 'authentication notifier',
  68. ];
  69. });
  70. $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
  71. function(GenericEvent $event) use ($container) {
  72. /** @var MissingIndexInformation $subject */
  73. $subject = $event->getSubject();
  74. $schema = new SchemaWrapper($container->query(IDBConnection::class));
  75. if ($schema->hasTable('share')) {
  76. $table = $schema->getTable('share');
  77. if (!$table->hasIndex('share_with_index')) {
  78. $subject->addHintForMissingSubject($table->getName(), 'share_with_index');
  79. }
  80. if (!$table->hasIndex('parent_index')) {
  81. $subject->addHintForMissingSubject($table->getName(), 'parent_index');
  82. }
  83. if (!$table->hasIndex('owner_index')) {
  84. $subject->addHintForMissingSubject($table->getName(), 'owner_index');
  85. }
  86. if (!$table->hasIndex('initiator_index')) {
  87. $subject->addHintForMissingSubject($table->getName(), 'initiator_index');
  88. }
  89. }
  90. if ($schema->hasTable('filecache')) {
  91. $table = $schema->getTable('filecache');
  92. if (!$table->hasIndex('fs_mtime')) {
  93. $subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
  94. }
  95. }
  96. if ($schema->hasTable('twofactor_providers')) {
  97. $table = $schema->getTable('twofactor_providers');
  98. if (!$table->hasIndex('twofactor_providers_uid')) {
  99. $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid');
  100. }
  101. }
  102. if ($schema->hasTable('login_flow_v2')) {
  103. $table = $schema->getTable('login_flow_v2');
  104. if (!$table->hasIndex('poll_token')) {
  105. $subject->addHintForMissingSubject($table->getName(), 'poll_token');
  106. }
  107. if (!$table->hasIndex('login_token')) {
  108. $subject->addHintForMissingSubject($table->getName(), 'login_token');
  109. }
  110. if (!$table->hasIndex('timestamp')) {
  111. $subject->addHintForMissingSubject($table->getName(), 'timestamp');
  112. }
  113. }
  114. if ($schema->hasTable('whats_new')) {
  115. $table = $schema->getTable('whats_new');
  116. if (!$table->hasIndex('version')) {
  117. $subject->addHintForMissingSubject($table->getName(), 'version');
  118. }
  119. }
  120. if ($schema->hasTable('cards')) {
  121. $table = $schema->getTable('cards');
  122. if (!$table->hasIndex('cards_abid')) {
  123. $subject->addHintForMissingSubject($table->getName(), 'cards_abid');
  124. }
  125. }
  126. if ($schema->hasTable('cards_properties')) {
  127. $table = $schema->getTable('cards_properties');
  128. if (!$table->hasIndex('cards_prop_abid')) {
  129. $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid');
  130. }
  131. }
  132. }
  133. );
  134. }
  135. }