removegetetagentries.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OC\Repair;
  22. use OC\Hooks\BasicEmitter;
  23. use OCP\IDBConnection;
  24. class RemoveGetETagEntries extends BasicEmitter {
  25. /**
  26. * @var IDBConnection
  27. */
  28. protected $connection;
  29. /**
  30. * @param IDBConnection $connection
  31. */
  32. public function __construct(IDBConnection $connection) {
  33. $this->connection = $connection;
  34. }
  35. public function getName() {
  36. return 'Remove getetag entries in properties table';
  37. }
  38. /**
  39. * Removes all entries with the key "{DAV:}getetag" from the table properties
  40. */
  41. public function run() {
  42. $sql = 'DELETE FROM `*PREFIX*properties`'
  43. . ' WHERE `propertyname` = ?';
  44. $deletedRows = $this->connection->executeUpdate($sql, ['{DAV:}getetag']);
  45. $this->emit(
  46. '\OC\Repair',
  47. 'info',
  48. ['Removed ' . $deletedRows . ' unneeded "{DAV:}getetag" entries from properties table.']
  49. );
  50. }
  51. }