1
0

Application.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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\Core\Notification\RemoveLinkSharesNotifier;
  30. use OC\DB\MissingIndexInformation;
  31. use OC\DB\SchemaWrapper;
  32. use OCP\AppFramework\App;
  33. use OCP\IDBConnection;
  34. use OCP\Util;
  35. use Symfony\Component\EventDispatcher\GenericEvent;
  36. /**
  37. * Class Application
  38. *
  39. * @package OC\Core
  40. */
  41. class Application extends App {
  42. public function __construct() {
  43. parent::__construct('core');
  44. $container = $this->getContainer();
  45. $container->registerService('defaultMailAddress', function () {
  46. return Util::getDefaultEmailAddress('lostpassword-noreply');
  47. });
  48. $server = $container->getServer();
  49. $eventDispatcher = $server->getEventDispatcher();
  50. $notificationManager = $server->getNotificationManager();
  51. $notificationManager->registerNotifier(function() use ($server) {
  52. return new RemoveLinkSharesNotifier(
  53. $server->getL10NFactory()
  54. );
  55. }, function() use ($server) {
  56. return [
  57. 'id' => 'core',
  58. 'name' => 'core',
  59. ];
  60. });
  61. $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
  62. function(GenericEvent $event) use ($container) {
  63. /** @var MissingIndexInformation $subject */
  64. $subject = $event->getSubject();
  65. $schema = new SchemaWrapper($container->query(IDBConnection::class));
  66. if ($schema->hasTable('share')) {
  67. $table = $schema->getTable('share');
  68. if (!$table->hasIndex('share_with_index')) {
  69. $subject->addHintForMissingSubject($table->getName(), 'share_with_index');
  70. }
  71. if (!$table->hasIndex('parent_index')) {
  72. $subject->addHintForMissingSubject($table->getName(), 'parent_index');
  73. }
  74. if (!$table->hasIndex('owner_index')) {
  75. $subject->addHintForMissingSubject($table->getName(), 'owner_index');
  76. }
  77. if (!$table->hasIndex('initiator_index')) {
  78. $subject->addHintForMissingSubject($table->getName(), 'initiator_index');
  79. }
  80. }
  81. if ($schema->hasTable('filecache')) {
  82. $table = $schema->getTable('filecache');
  83. if (!$table->hasIndex('fs_mtime')) {
  84. $subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
  85. }
  86. }
  87. }
  88. );
  89. }
  90. }