diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-04-22 15:35:39 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-04-25 15:01:13 +0200 |
commit | c7542c02dbc997d818e984dae23bdf1780843559 (patch) | |
tree | eaa5e6b7230b531a4e5f494544be41449a0100f5 /lib/private | |
parent | a4b1d9feee79218268abcb0c20ed16bec82c993c (diff) | |
download | nextcloud-server-c7542c02dbc997d818e984dae23bdf1780843559.tar.gz nextcloud-server-c7542c02dbc997d818e984dae23bdf1780843559.zip |
Introduce OCP\Migration\IRepairStep and adopt all repair steps to this new interface - refs #24198
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Repair/AssetCache.php | 12 | ||||
-rw-r--r-- | lib/private/Repair/CleanTags.php | 27 | ||||
-rw-r--r-- | lib/private/Repair/Collation.php | 11 | ||||
-rw-r--r-- | lib/private/Repair/DropOldJobs.php | 8 | ||||
-rw-r--r-- | lib/private/Repair/DropOldTables.php | 12 | ||||
-rw-r--r-- | lib/private/Repair/FillETags.php | 9 | ||||
-rw-r--r-- | lib/private/Repair/InnoDB.php | 11 | ||||
-rw-r--r-- | lib/private/Repair/OldGroupMembershipShares.php | 11 | ||||
-rw-r--r-- | lib/private/Repair/Preview.php | 9 | ||||
-rw-r--r-- | lib/private/Repair/RemoveGetETagEntries.php | 13 | ||||
-rw-r--r-- | lib/private/Repair/RepairInvalidShares.php | 27 | ||||
-rw-r--r-- | lib/private/Repair/RepairLegacyStorages.php | 27 | ||||
-rw-r--r-- | lib/private/Repair/RepairMimeTypes.php | 33 | ||||
-rw-r--r-- | lib/private/Repair/SearchLuceneTables.php | 11 | ||||
-rw-r--r-- | lib/private/Repair/SharePropagation.php | 8 | ||||
-rw-r--r-- | lib/private/Repair/SqliteAutoincrement.php | 7 | ||||
-rw-r--r-- | lib/private/Repair/UpdateCertificateStore.php | 8 | ||||
-rw-r--r-- | lib/private/Repair/UpdateOutdatedOcsIds.php | 14 | ||||
-rw-r--r-- | lib/private/repair.php | 59 | ||||
-rw-r--r-- | lib/private/repairstep.php | 43 |
20 files changed, 172 insertions, 188 deletions
diff --git a/lib/private/Repair/AssetCache.php b/lib/private/Repair/AssetCache.php index 72fe99bbe1a..e4787bab95f 100644 --- a/lib/private/Repair/AssetCache.php +++ b/lib/private/Repair/AssetCache.php @@ -23,23 +23,23 @@ namespace OC\Repair; -use Doctrine\DBAL\Platforms\MySqlPlatform; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class AssetCache extends BasicEmitter implements \OC\RepairStep { +class AssetCache implements IRepairStep { public function getName() { return 'Clear asset cache after upgrade'; } - public function run() { + public function run(IOutput $output) { if (!\OC_Template::isAssetPipelineEnabled()) { - $this->emit('\OC\Repair', 'info', array('Asset pipeline disabled -> nothing to do')); + $output->info('Asset pipeline disabled -> nothing to do'); return; } $assetDir = \OC::$server->getConfig()->getSystemValue('assetdirectory', \OC::$SERVERROOT) . '/assets'; \OC_Helper::rmdirr($assetDir, false); - $this->emit('\OC\Repair', 'info', array('Asset cache cleared.')); + $output->info('Asset cache cleared.'); } } diff --git a/lib/private/Repair/CleanTags.php b/lib/private/Repair/CleanTags.php index 537c4da78aa..2607151cd9c 100644 --- a/lib/private/Repair/CleanTags.php +++ b/lib/private/Repair/CleanTags.php @@ -22,17 +22,17 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; -use OC\RepairStep; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; /** * Class RepairConfig * * @package OC\Repair */ -class CleanTags extends BasicEmitter implements RepairStep { +class CleanTags implements IRepairStep { /** @var IDBConnection */ protected $connection; @@ -54,17 +54,18 @@ class CleanTags extends BasicEmitter implements RepairStep { /** * Updates the configuration after running an update */ - public function run() { - $this->deleteOrphanFileEntries(); - $this->deleteOrphanTagEntries(); - $this->deleteOrphanCategoryEntries(); + public function run(IOutput $output) { + $this->deleteOrphanFileEntries($output); + $this->deleteOrphanTagEntries($output); + $this->deleteOrphanCategoryEntries($output); } /** * Delete tag entries for deleted files */ - protected function deleteOrphanFileEntries() { + protected function deleteOrphanFileEntries(IOutput $output) { $this->deleteOrphanEntries( + $output, '%d tags for delete files have been removed.', 'vcategory_to_object', 'objid', 'filecache', 'fileid', 'path_hash' @@ -74,8 +75,9 @@ class CleanTags extends BasicEmitter implements RepairStep { /** * Delete tag entries for deleted tags */ - protected function deleteOrphanTagEntries() { + protected function deleteOrphanTagEntries(IOutput $output) { $this->deleteOrphanEntries( + $output, '%d tag entries for deleted tags have been removed.', 'vcategory_to_object', 'categoryid', 'vcategory', 'id', 'uid' @@ -85,8 +87,9 @@ class CleanTags extends BasicEmitter implements RepairStep { /** * Delete tags that have no entries */ - protected function deleteOrphanCategoryEntries() { + protected function deleteOrphanCategoryEntries(IOutput $output) { $this->deleteOrphanEntries( + $output, '%d tags with no entries have been removed.', 'vcategory', 'id', 'vcategory_to_object', 'categoryid', 'type' @@ -108,7 +111,7 @@ class CleanTags extends BasicEmitter implements RepairStep { * @param string $sourceNullColumn If this column is null in the source table, * the entry is deleted in the $deleteTable */ - protected function deleteOrphanEntries($repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) { + protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) { $qb = $this->connection->getQueryBuilder(); $qb->select('d.' . $deleteId) @@ -141,7 +144,7 @@ class CleanTags extends BasicEmitter implements RepairStep { } if ($repairInfo) { - $this->emit('\OC\Repair', 'info', array(sprintf($repairInfo, sizeof($orphanItems)))); + $output->info(sprintf($repairInfo, sizeof($orphanItems))); } } } diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php index 48035f8d331..1376785e17d 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -23,9 +23,10 @@ namespace OC\Repair; use Doctrine\DBAL\Platforms\MySqlPlatform; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class Collation extends BasicEmitter implements \OC\RepairStep { +class Collation implements IRepairStep { /** * @var \OCP\IConfig */ @@ -52,15 +53,15 @@ class Collation extends BasicEmitter implements \OC\RepairStep { /** * Fix mime types */ - public function run() { + public function run(IOutput $output) { if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) { - $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to no')); + $output->info('Not a mysql database -> nothing to no'); return; } $tables = $this->getAllNonUTF8BinTables($this->connection); foreach ($tables as $table) { - $this->emit('\OC\Repair', 'info', array("Change collation for $table ...")); + $output->info("Change collation for $table ..."); $query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;'); $query->execute(); } diff --git a/lib/private/Repair/DropOldJobs.php b/lib/private/Repair/DropOldJobs.php index 594af83e511..489b89d0869 100644 --- a/lib/private/Repair/DropOldJobs.php +++ b/lib/private/Repair/DropOldJobs.php @@ -22,11 +22,11 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; -use OC\RepairStep; use OCP\BackgroundJob\IJobList; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class DropOldJobs extends BasicEmitter implements RepairStep { +class DropOldJobs implements IRepairStep { /** @var IJobList */ protected $jobList; @@ -53,7 +53,7 @@ class DropOldJobs extends BasicEmitter implements RepairStep { * * @throws \Exception in case of failure */ - public function run() { + public function run(IOutput $output) { $oldJobs = $this->oldJobs(); foreach($oldJobs as $job) { if($this->jobList->has($job['class'], $job['arguments'])) { diff --git a/lib/private/Repair/DropOldTables.php b/lib/private/Repair/DropOldTables.php index 67eafaa930e..15d5b9a3577 100644 --- a/lib/private/Repair/DropOldTables.php +++ b/lib/private/Repair/DropOldTables.php @@ -23,11 +23,11 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; -use OC\RepairStep; use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class DropOldTables extends BasicEmitter implements RepairStep { +class DropOldTables implements IRepairStep { /** @var IDBConnection */ protected $connection; @@ -54,12 +54,10 @@ class DropOldTables extends BasicEmitter implements RepairStep { * * @throws \Exception in case of failure */ - public function run() { + public function run(IOutput $output) { foreach ($this->oldDatabaseTables() as $tableName) { if ($this->connection->tableExists($tableName)){ - $this->emit('\OC\Repair', 'info', [ - sprintf('Table %s has been deleted', $tableName) - ]); + $output->info(sprintf('Table %s has been deleted', $tableName)); $this->connection->dropTable($tableName); } } diff --git a/lib/private/Repair/FillETags.php b/lib/private/Repair/FillETags.php index dc2ffdcbc36..7ed55f20ac1 100644 --- a/lib/private/Repair/FillETags.php +++ b/lib/private/Repair/FillETags.php @@ -23,9 +23,10 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class FillETags extends BasicEmitter implements \OC\RepairStep { +class FillETags implements IRepairStep { /** @var \OCP\IDBConnection */ protected $connection; @@ -41,7 +42,7 @@ class FillETags extends BasicEmitter implements \OC\RepairStep { return 'Generate ETags for file where no ETag is present.'; } - public function run() { + public function run(IOutput $output) { $qb = $this->connection->getQueryBuilder(); $qb->update('filecache') ->set('etag', $qb->expr()->literal('xxx')) @@ -49,7 +50,7 @@ class FillETags extends BasicEmitter implements \OC\RepairStep { ->orWhere($qb->expr()->isNull('etag')); $result = $qb->execute(); - $this->emit('\OC\Repair', 'info', array("ETags have been fixed for $result files/folders.")); + $output->info("ETags have been fixed for $result files/folders."); } } diff --git a/lib/private/Repair/InnoDB.php b/lib/private/Repair/InnoDB.php index 4e157e66045..ed119dcc032 100644 --- a/lib/private/Repair/InnoDB.php +++ b/lib/private/Repair/InnoDB.php @@ -25,9 +25,10 @@ namespace OC\Repair; use Doctrine\DBAL\Platforms\MySqlPlatform; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class InnoDB extends BasicEmitter implements \OC\RepairStep { +class InnoDB implements IRepairStep { public function getName() { return 'Repair MySQL database engine'; @@ -36,10 +37,10 @@ class InnoDB extends BasicEmitter implements \OC\RepairStep { /** * Fix mime types */ - public function run() { + public function run(IOutput $output) { $connection = \OC::$server->getDatabaseConnection(); if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) { - $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to do')); + $output->info('Not a mysql database -> nothing to do'); return; } @@ -47,7 +48,7 @@ class InnoDB extends BasicEmitter implements \OC\RepairStep { if (is_array($tables)) { foreach ($tables as $table) { $connection->exec("ALTER TABLE $table ENGINE=InnoDB;"); - $this->emit('\OC\Repair', 'info', array("Fixed $table")); + $output->info("Fixed $table"); } } } diff --git a/lib/private/Repair/OldGroupMembershipShares.php b/lib/private/Repair/OldGroupMembershipShares.php index 627645b116d..e982dd81f3b 100644 --- a/lib/private/Repair/OldGroupMembershipShares.php +++ b/lib/private/Repair/OldGroupMembershipShares.php @@ -21,14 +21,13 @@ namespace OC\Repair; - -use OC\Hooks\BasicEmitter; -use OC\RepairStep; use OCP\IDBConnection; use OCP\IGroupManager; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; use OCP\Share; -class OldGroupMembershipShares extends BasicEmitter implements RepairStep { +class OldGroupMembershipShares implements IRepairStep { /** @var \OCP\IDBConnection */ protected $connection; @@ -65,7 +64,7 @@ class OldGroupMembershipShares extends BasicEmitter implements RepairStep { * * @throws \Exception in case of failure */ - public function run() { + public function run(IOutput $output) { $deletedEntries = 0; $query = $this->connection->getQueryBuilder(); @@ -92,7 +91,7 @@ class OldGroupMembershipShares extends BasicEmitter implements RepairStep { $result->closeCursor(); if ($deletedEntries) { - $this->emit('\OC\Repair', 'info', array('Removed ' . $deletedEntries . ' shares where user is not a member of the group anymore')); + $output->info('Removed ' . $deletedEntries . ' shares where user is not a member of the group anymore'); } } diff --git a/lib/private/Repair/Preview.php b/lib/private/Repair/Preview.php index 481e98b42d1..7e26e45cb80 100644 --- a/lib/private/Repair/Preview.php +++ b/lib/private/Repair/Preview.php @@ -21,15 +21,16 @@ namespace OC\Repair; use OC\Files\View; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class Preview extends BasicEmitter implements \OC\RepairStep { +class Preview implements IRepairStep { public function getName() { return 'Cleaning-up broken previews'; } - public function run() { + public function run(IOutput $out) { $view = new View('/'); $children = $view->getDirectoryContent('/'); @@ -42,4 +43,4 @@ class Preview extends BasicEmitter implements \OC\RepairStep { } } } -}
\ No newline at end of file +} diff --git a/lib/private/Repair/RemoveGetETagEntries.php b/lib/private/Repair/RemoveGetETagEntries.php index e118da7973a..67bfb53bf14 100644 --- a/lib/private/Repair/RemoveGetETagEntries.php +++ b/lib/private/Repair/RemoveGetETagEntries.php @@ -21,10 +21,11 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class RemoveGetETagEntries extends BasicEmitter { +class RemoveGetETagEntries implements IRepairStep { /** * @var IDBConnection @@ -45,15 +46,11 @@ class RemoveGetETagEntries extends BasicEmitter { /** * Removes all entries with the key "{DAV:}getetag" from the table properties */ - public function run() { + public function run(IOutput $out) { $sql = 'DELETE FROM `*PREFIX*properties`' . ' WHERE `propertyname` = ?'; $deletedRows = $this->connection->executeUpdate($sql, ['{DAV:}getetag']); - $this->emit( - '\OC\Repair', - 'info', - ['Removed ' . $deletedRows . ' unneeded "{DAV:}getetag" entries from properties table.'] - ); + $out->info('Removed ' . $deletedRows . ' unneeded "{DAV:}getetag" entries from properties table.'); } } diff --git a/lib/private/Repair/RepairInvalidShares.php b/lib/private/Repair/RepairInvalidShares.php index beef5e37798..e30b4ab0d31 100644 --- a/lib/private/Repair/RepairInvalidShares.php +++ b/lib/private/Repair/RepairInvalidShares.php @@ -23,23 +23,20 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; /** * Repairs shares with invalid data */ -class RepairInvalidShares extends BasicEmitter implements \OC\RepairStep { +class RepairInvalidShares implements IRepairStep { const CHUNK_SIZE = 200; - /** - * @var \OCP\IConfig - */ + /** @var \OCP\IConfig */ protected $config; - /** - * @var \OCP\IDBConnection - */ + /** @var \OCP\IDBConnection */ protected $connection; /** @@ -59,7 +56,7 @@ class RepairInvalidShares extends BasicEmitter implements \OC\RepairStep { * Past bugs would make it possible to set an expiration date on user shares even * though it is not supported. This functions removes the expiration date from such entries. */ - private function removeExpirationDateFromNonLinkShares() { + private function removeExpirationDateFromNonLinkShares(IOutput $out) { $builder = $this->connection->getQueryBuilder(); $builder ->update('share') @@ -69,14 +66,14 @@ class RepairInvalidShares extends BasicEmitter implements \OC\RepairStep { $updatedEntries = $builder->execute(); if ($updatedEntries > 0) { - $this->emit('\OC\Repair', 'info', array('Removed invalid expiration date from ' . $updatedEntries . ' shares')); + $out->info('Removed invalid expiration date from ' . $updatedEntries . ' shares'); } } /** * Remove shares where the parent share does not exist anymore */ - private function removeSharesNonExistingParent() { + private function removeSharesNonExistingParent(IOutput $out) { $deletedEntries = 0; $query = $this->connection->getQueryBuilder(); @@ -105,17 +102,17 @@ class RepairInvalidShares extends BasicEmitter implements \OC\RepairStep { } if ($deletedEntries) { - $this->emit('\OC\Repair', 'info', array('Removed ' . $deletedEntries . ' shares where the parent did not exist')); + $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); } } - public function run() { + public function run(IOutput $out) { $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); if (version_compare($ocVersionFromBeforeUpdate, '8.2.0.7', '<')) { // this situation was only possible before 8.2 - $this->removeExpirationDateFromNonLinkShares(); + $this->removeExpirationDateFromNonLinkShares($out); } - $this->removeSharesNonExistingParent(); + $this->removeSharesNonExistingParent($out); } } diff --git a/lib/private/Repair/RepairLegacyStorages.php b/lib/private/Repair/RepairLegacyStorages.php index ee189110a87..9582629b1a3 100644 --- a/lib/private/Repair/RepairLegacyStorages.php +++ b/lib/private/Repair/RepairLegacyStorages.php @@ -24,10 +24,11 @@ namespace OC\Repair; use OC\Files\Cache\Storage; -use OC\Hooks\BasicEmitter; use OC\RepairException; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class RepairLegacyStorages extends BasicEmitter { +class RepairLegacyStorages implements IRepairStep{ /** * @var \OCP\IConfig */ @@ -149,7 +150,7 @@ class RepairLegacyStorages extends BasicEmitter { * Converts legacy home storage ids in the format * "local::/data/dir/path/userid/" to the new format "home::userid" */ - public function run() { + public function run(IOutput $out) { // only run once if ($this->config->getAppValue('core', 'repairlegacystoragesdone') === 'yes') { return; @@ -186,11 +187,7 @@ class RepairLegacyStorages extends BasicEmitter { } catch (RepairException $e) { $hasWarnings = true; - $this->emit( - '\OC\Repair', - 'warning', - array('Could not repair legacy storage ' . $currentId . ' automatically.') - ); + $out->warning('Could not repair legacy storage ' . $currentId . ' automatically.'); } } @@ -233,11 +230,7 @@ class RepairLegacyStorages extends BasicEmitter { } catch (RepairException $e) { $hasWarnings = true; - $this->emit( - '\OC\Repair', - 'warning', - array('Could not repair legacy storage ' . $storageId . ' automatically.') - ); + $out->warning('Could not repair legacy storage ' . $storageId . ' automatically.'); } } } @@ -245,16 +238,12 @@ class RepairLegacyStorages extends BasicEmitter { } while (count($results) >= $limit); } - $this->emit('\OC\Repair', 'info', array('Updated ' . $count . ' legacy home storage ids')); + $out->info('Updated ' . $count . ' legacy home storage ids'); $this->connection->commit(); if ($hasWarnings) { - $this->emit( - '\OC\Repair', - 'warning', - array('Some legacy storages could not be repaired. Please manually fix them then re-run ./occ maintenance:repair') - ); + $out->warning('Some legacy storages could not be repaired. Please manually fix them then re-run ./occ maintenance:repair'); } else { // if all were done, no need to redo the repair during next upgrade $this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes'); diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php index c5180302443..0d56245312a 100644 --- a/lib/private/Repair/RepairMimeTypes.php +++ b/lib/private/Repair/RepairMimeTypes.php @@ -28,9 +28,10 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { +class RepairMimeTypes implements IRepairStep { /** * @var \OCP\IConfig */ @@ -308,7 +309,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { /** * Fix mime types */ - public function run() { + public function run(IOutput $out) { $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); @@ -318,60 +319,60 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { // only update mime types if necessary as it can be expensive if (version_compare($ocVersionFromBeforeUpdate, '8.2.0', '<')) { if ($this->fixOfficeMimeTypes()) { - $this->emit('\OC\Repair', 'info', array('Fixed office mime types')); + $out->info('Fixed office mime types'); } if ($this->fixApkMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed APK mime type')); + $out->info('Fixed APK mime type'); } if ($this->fixFontsMimeTypes()) { - $this->emit('\OC\Repair', 'info', array('Fixed fonts mime types')); + $out->info('Fixed fonts mime types'); } if ($this->fixPostscriptMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed Postscript mime types')); + $out->info('Fixed Postscript mime types'); } if ($this->introduceRawMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed Raw mime types')); + $out->info('Fixed Raw mime types'); } if ($this->introduce3dImagesMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed 3D images mime types')); + $out->info('Fixed 3D images mime types'); } if ($this->introduceConfMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed Conf/cnf mime types')); + $out->info('Fixed Conf/cnf mime types'); } if ($this->introduceYamlMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed Yaml/Yml mime types')); + $out->info('Fixed Yaml/Yml mime types'); } } // Mimetype updates from #19272 if (version_compare($ocVersionFromBeforeUpdate, '8.2.0.8', '<')) { if ($this->introduceJavaMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed java/class mime types')); + $out->info('Fixed java/class mime types'); } if ($this->introduceHppMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed hpp mime type')); + $out->info('Fixed hpp mime type'); } if ($this->introduceRssMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed rss mime type')); + $out->info('Fixed rss mime type'); } if ($this->introduceRtfMimeType()) { - $this->emit('\OC\Repair', 'info', array('Fixed rtf mime type')); + $out->info('Fixed rtf mime type'); } } if (version_compare($ocVersionFromBeforeUpdate, '9.0.0.10', '<')) { if ($this->introduceRichDocumentsMimeTypes()) { - $this->emit('\OC\Repair', 'info', array('Fixed richdocuments additional office mime types')); + $out->info('Fixed richdocuments additional office mime types'); } } } diff --git a/lib/private/Repair/SearchLuceneTables.php b/lib/private/Repair/SearchLuceneTables.php index 9f3601eeb03..56bae6ff655 100644 --- a/lib/private/Repair/SearchLuceneTables.php +++ b/lib/private/Repair/SearchLuceneTables.php @@ -22,9 +22,10 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; -class SearchLuceneTables extends BasicEmitter implements \OC\RepairStep { +class SearchLuceneTables implements IRepairStep { public function getName() { return 'Repair duplicate entries in oc_lucene_status'; @@ -51,10 +52,10 @@ class SearchLuceneTables extends BasicEmitter implements \OC\RepairStep { * * search_lucene will then reindex the fileids without a status when the next indexing job is executed */ - public function run() { + public function run(IOutput $out) { $connection = \OC::$server->getDatabaseConnection(); if ($connection->tableExists('lucene_status')) { - $this->emit('\OC\Repair', 'info', array('removing duplicate entries from lucene_status')); + $out->info('removing duplicate entries from lucene_status'); $query = $connection->prepare(' DELETE FROM `*PREFIX*lucene_status` @@ -69,7 +70,7 @@ class SearchLuceneTables extends BasicEmitter implements \OC\RepairStep { )'); $query->execute(); } else { - $this->emit('\OC\Repair', 'info', array('lucene_status table does not exist -> nothing to do')); + $out->info('lucene_status table does not exist -> nothing to do'); } } diff --git a/lib/private/Repair/SharePropagation.php b/lib/private/Repair/SharePropagation.php index 26d7a9e128c..cd0c091b325 100644 --- a/lib/private/Repair/SharePropagation.php +++ b/lib/private/Repair/SharePropagation.php @@ -20,10 +20,12 @@ */ namespace OC\Repair; -use OC\Hooks\BasicEmitter; use OCP\IConfig; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; + +class SharePropagation implements IRepairStep { -class SharePropagation extends BasicEmitter implements \OC\RepairStep { /** @var IConfig */ private $config; @@ -40,7 +42,7 @@ class SharePropagation extends BasicEmitter implements \OC\RepairStep { return 'Remove old share propagation app entries'; } - public function run() { + public function run(IOutput $out ) { $keys = $this->config->getAppKeys('files_sharing'); foreach ($keys as $key) { diff --git a/lib/private/Repair/SqliteAutoincrement.php b/lib/private/Repair/SqliteAutoincrement.php index d7cac57229d..e6f90dcece3 100644 --- a/lib/private/Repair/SqliteAutoincrement.php +++ b/lib/private/Repair/SqliteAutoincrement.php @@ -26,13 +26,14 @@ use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\SchemaDiff; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\ColumnDiff; -use OC\Hooks\BasicEmitter; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; /** * Fixes Sqlite autoincrement by forcing the SQLite table schemas to be * altered in order to retrigger SQL schema generation through OCSqlitePlatform. */ -class SqliteAutoincrement extends BasicEmitter implements \OC\RepairStep { +class SqliteAutoincrement implements IRepairStep { /** * @var \OC\DB\Connection */ @@ -52,7 +53,7 @@ class SqliteAutoincrement extends BasicEmitter implements \OC\RepairStep { /** * Fix mime types */ - public function run() { + public function run(IOutput $out) { if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) { return; } diff --git a/lib/private/Repair/UpdateCertificateStore.php b/lib/private/Repair/UpdateCertificateStore.php index ae7585f07f6..9397fc77bce 100644 --- a/lib/private/Repair/UpdateCertificateStore.php +++ b/lib/private/Repair/UpdateCertificateStore.php @@ -22,10 +22,10 @@ namespace OC\Repair; use OC\Files\View; -use OC\Hooks\BasicEmitter; -use OC\RepairStep; use OC\Server; use OCP\IConfig; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; /** * Class UpdateCertificateStore rewrites the user specific certificate store after @@ -34,7 +34,7 @@ use OCP\IConfig; * * @package OC\Repair */ -class UpdateCertificateStore extends BasicEmitter implements RepairStep { +class UpdateCertificateStore implements IRepairStep { /** * FIXME: The certificate manager does only allow specifying the user * within the constructor. This makes DI impossible. @@ -60,7 +60,7 @@ class UpdateCertificateStore extends BasicEmitter implements RepairStep { } /** {@inheritDoc} */ - public function run() { + public function run(IOutput $out) { $rootView = new View(); $dataDirectory = $this->config->getSystemValue('datadirectory', null); if(is_null($dataDirectory)) { diff --git a/lib/private/Repair/UpdateOutdatedOcsIds.php b/lib/private/Repair/UpdateOutdatedOcsIds.php index 60024b3055c..4c768e93bd6 100644 --- a/lib/private/Repair/UpdateOutdatedOcsIds.php +++ b/lib/private/Repair/UpdateOutdatedOcsIds.php @@ -21,9 +21,9 @@ namespace OC\Repair; -use OC\Hooks\BasicEmitter; -use OC\RepairStep; use OCP\IConfig; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; /** * Class UpdateOutdatedOcsIds is used to update invalid outdated OCS IDs, this is @@ -33,7 +33,7 @@ use OCP\IConfig; * * @package OC\Repair */ -class UpdateOutdatedOcsIds extends BasicEmitter implements RepairStep { +class UpdateOutdatedOcsIds implements IRepairStep { /** @var IConfig */ private $config; @@ -71,7 +71,7 @@ class UpdateOutdatedOcsIds extends BasicEmitter implements RepairStep { /** * {@inheritdoc} */ - public function run() { + public function run(IOutput $output) { $appsToUpdate = [ 'contacts' => [ 'old' => '166044', @@ -97,11 +97,7 @@ class UpdateOutdatedOcsIds extends BasicEmitter implements RepairStep { foreach($appsToUpdate as $appName => $ids) { if ($this->fixOcsId($appName, $ids['old'], $ids['new'])) { - $this->emit( - '\OC\Repair', - 'info', - [sprintf('Fixed invalid %s OCS id', $appName)] - ); + $output->info("Fixed invalid $appName OCS id"); } } } diff --git a/lib/private/repair.php b/lib/private/repair.php index 28fe993db07..586e4e42b13 100644 --- a/lib/private/repair.php +++ b/lib/private/repair.php @@ -46,11 +46,13 @@ use OC\Repair\RepairMimeTypes; use OC\Repair\SearchLuceneTables; use OC\Repair\UpdateOutdatedOcsIds; use OC\Repair\RepairInvalidShares; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\GenericEvent; -class Repair extends BasicEmitter { - /* @var RepairStep[] */ +class Repair extends BasicEmitter implements IOutput{ + /* @var IRepairStep[] */ private $repairSteps; /** @var EventDispatcher */ private $dispatcher; @@ -58,7 +60,7 @@ class Repair extends BasicEmitter { /** * Creates a new repair step runner * - * @param RepairStep[] $repairSteps array of RepairStep instances + * @param IRepairStep[] $repairSteps array of RepairStep instances * @param EventDispatcher $dispatcher */ public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) { @@ -88,24 +90,24 @@ class Repair extends BasicEmitter { }); } - $step->run(); + $step->run($this); } } /** * Add repair step * - * @param RepairStep|string $repairStep repair step + * @param IRepairStep|string $repairStep repair step * @throws \Exception */ public function addStep($repairStep) { if (is_string($repairStep)) { if (class_exists($repairStep)) { $s = new $repairStep(); - if ($s instanceof RepairStep) { + if ($s instanceof IRepairStep) { $this->repairSteps[] = $s; } else { - throw new \Exception("Repair step '$repairStep' is not of type \\OC\\RepairStep"); + throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep"); } } else { throw new \Exception("Repair step '$repairStep' is unknown"); @@ -119,7 +121,7 @@ class Repair extends BasicEmitter { * Returns the default repair steps to be run on the * command line or after an upgrade. * - * @return array of RepairStep instances + * @return IRepairStep[] */ public static function getRepairSteps() { return [ @@ -141,7 +143,7 @@ class Repair extends BasicEmitter { * Returns expensive repair steps to be run on the * command line with a special option. * - * @return array of RepairStep instances + * @return IRepairStep[] */ public static function getExpensiveRepairSteps() { return [ @@ -153,7 +155,7 @@ class Repair extends BasicEmitter { * Returns the repair steps to be run before an * upgrade. * - * @return array of RepairStep instances + * @return IRepairStep[] */ public static function getBeforeUpgradeRepairSteps() { $connection = \OC::$server->getDatabaseConnection(); @@ -185,4 +187,41 @@ class Repair extends BasicEmitter { new GenericEvent("$scope::$method", $arguments)); } } + + public function info($string) { + // for now just emit as we did in the past + $this->emit('\OC\Repair', 'info', array($string)); + } + + /** + * @param string $message + */ + public function warning($message) { + // for now just emit as we did in the past + $this->emit('\OC\Repair', 'warning', [$message]); + } + + /** + * @param int $max + */ + public function startProgress($max = 0) { + // for now just emit as we did in the past + $this->emit('\OC\Repair', 'startProgress', [$max]); + } + + /** + * @param int $step + */ + public function advance($step = 1) { + // for now just emit as we did in the past + $this->emit('\OC\Repair', 'advance', [$step]); + } + + /** + * @param int $max + */ + public function finishProgress() { + // for now just emit as we did in the past + $this->emit('\OC\Repair', 'finishProgress', []); + } } diff --git a/lib/private/repairstep.php b/lib/private/repairstep.php deleted file mode 100644 index e1b8442fb8a..00000000000 --- a/lib/private/repairstep.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/** - * @author Vincent Petry <pvince81@owncloud.com> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -namespace OC; - -/** - * Repair step - */ -interface RepairStep { - - /** - * Returns the step's name - * - * @return string - */ - public function getName(); - - /** - * Run repair step. - * Must throw exception on error. - * - * @throws \Exception in case of failure - */ - public function run(); - -} |