Application.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. }
  76. );
  77. }
  78. }