diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-26 18:27:39 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-30 13:05:10 +0100 |
commit | 9fbe6774f7e337384f09f40aa90e9b0bc6602a13 (patch) | |
tree | f006ae9d429d140bd0a46803174c71c644b84f4b /lib/private/Repair | |
parent | 4dee1e06a3ecc0acafd369a1bb557c051cd4e7de (diff) | |
download | nextcloud-server-9fbe6774f7e337384f09f40aa90e9b0bc6602a13.tar.gz nextcloud-server-9fbe6774f7e337384f09f40aa90e9b0bc6602a13.zip |
Repair registration and autoload bump
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/Repair')
-rw-r--r-- | lib/private/Repair/NC15/SetVcardDatabaseUID.php | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/private/Repair/NC15/SetVcardDatabaseUID.php b/lib/private/Repair/NC15/SetVcardDatabaseUID.php index 2fe50c79471..e82a0aad18a 100644 --- a/lib/private/Repair/NC15/SetVcardDatabaseUID.php +++ b/lib/private/Repair/NC15/SetVcardDatabaseUID.php @@ -21,10 +21,8 @@ * */ -namespace OC\Repair\NC13; +namespace OC\Repair\NC15; - -use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; @@ -35,13 +33,17 @@ class SetVcardDatabaseUID implements IRepairStep { /** @var IDBConnection */ private $connection; + + /** @var IConfig */ + private $config; + private $updateQuery; - public function __construct(IDBConnection $connection) { + public function __construct(IDBConnection $connection, IConfig $config) { $this->connection = $connection; + $this->config = $config; } - public function getName() { return 'Extract the vcard uid and store it in the db'; } @@ -54,13 +56,13 @@ class SetVcardDatabaseUID implements IRepairStep { $builder = $this->connection->getQueryBuilder(); $builder->select('id', 'carddata') - ->from('cards') - ->where($builder->expr()->isNull('uid')) - ->setMaxResults(self::MAX_ROWS); + ->from('cards') + ->where($builder->expr()->isNull('uid')) + ->setMaxResults(self::MAX_ROWS); do { $result = $builder->execute(); - $rows = $result->fetchAll(); + $rows = $result->fetchAll(); foreach ($rows as $row) { yield $row; } @@ -70,9 +72,10 @@ class SetVcardDatabaseUID implements IRepairStep { private function getUid($carddata) { preg_match('/^UID:(.*)$/m', $carddata, $matches); - if (count($matches > 1)) { - return $matches[1][0]; + if (count($matches) > 1) { + return $matches[1]; } + return false; } @@ -85,8 +88,8 @@ class SetVcardDatabaseUID implements IRepairStep { $builder = $this->connection->getQueryBuilder(); $this->updateQuery = $builder->update('cards') - ->set('uid', $builder->createParameter('uid')) - ->where($builder->expr()->eq('id', $builder->createParameter('id'))); + ->set('uid', $builder->createParameter('uid')) + ->where($builder->expr()->eq('id', $builder->createParameter('id'))); } $this->updateQuery->setParameter('id', $id); @@ -98,23 +101,24 @@ class SetVcardDatabaseUID implements IRepairStep { private function repair() { $this->connection->beginTransaction(); $entries = $this->getInvalidEntries(); - $count = 0; + $count = 0; foreach ($entries as $entry) { $count++; - $uid = $this->getUid($entry['id']); + $uid = $this->getUid($entry['carddata']); if ($uid !== false) { $this->update($entry['id'], $uid); } } $this->connection->commit(); + return $count; } private function shouldRun() { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); - // was added to 15.0.0.0 - return version_compare($versionFromBeforeUpdate, '15.0.0.0', '<='); + // was added to 15.0.0.2 + return version_compare($versionFromBeforeUpdate, '15.0.0.2', '<='); } public function run(IOutput $output) { |