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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. }
  63. }
  64. );
  65. }
  66. }