diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-30 13:03:49 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-11-01 15:02:50 +0100 |
commit | d89edb28c4218eeadc5c2c5bbea6253dfc599a5f (patch) | |
tree | e01ab8d131f5d66c0b8f6bf94b456390ac6cdfc6 /lib | |
parent | 644686c0ec74f619a42c5274cd8422861df97127 (diff) | |
download | nextcloud-server-d89edb28c4218eeadc5c2c5bbea6253dfc599a5f.tar.gz nextcloud-server-d89edb28c4218eeadc5c2c5bbea6253dfc599a5f.zip |
move migration
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/Repair/NC15/SetVcardDatabaseUID.php | 28 |
3 files changed, 17 insertions, 13 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index dc20789576b..d7523d52caa 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -670,7 +670,6 @@ return array( 'OC\\Core\\Migrations\\Version14000Date20180710092004' => $baseDir . '/core/Migrations/Version14000Date20180710092004.php', 'OC\\Core\\Migrations\\Version14000Date20180712153140' => $baseDir . '/core/Migrations/Version14000Date20180712153140.php', 'OC\\Core\\Migrations\\Version15000Date20180926101451' => $baseDir . '/core/Migrations/Version15000Date20180926101451.php', - 'OC\\Core\\Migrations\\Version15000Date20180927120000' => $baseDir . '/core/Migrations/Version15000Date20180927120000.php', 'OC\\Core\\Migrations\\Version15000Date20181015062942' => $baseDir . '/core/Migrations/Version15000Date20181015062942.php', 'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php', 'OC\\DB\\AdapterMySQL' => $baseDir . '/lib/private/DB/AdapterMySQL.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index fe2ff5d760e..cf2fef4282d 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -700,7 +700,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Migrations\\Version14000Date20180710092004' => __DIR__ . '/../../..' . '/core/Migrations/Version14000Date20180710092004.php', 'OC\\Core\\Migrations\\Version14000Date20180712153140' => __DIR__ . '/../../..' . '/core/Migrations/Version14000Date20180712153140.php', 'OC\\Core\\Migrations\\Version15000Date20180926101451' => __DIR__ . '/../../..' . '/core/Migrations/Version15000Date20180926101451.php', - 'OC\\Core\\Migrations\\Version15000Date20180927120000' => __DIR__ . '/../../..' . '/core/Migrations/Version15000Date20180927120000.php', 'OC\\Core\\Migrations\\Version15000Date20181015062942' => __DIR__ . '/../../..' . '/core/Migrations/Version15000Date20181015062942.php', 'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php', 'OC\\DB\\AdapterMySQL' => __DIR__ . '/../../..' . '/lib/private/DB/AdapterMySQL.php', diff --git a/lib/private/Repair/NC15/SetVcardDatabaseUID.php b/lib/private/Repair/NC15/SetVcardDatabaseUID.php index 4d2805247bf..ccf6c47cbc8 100644 --- a/lib/private/Repair/NC15/SetVcardDatabaseUID.php +++ b/lib/private/Repair/NC15/SetVcardDatabaseUID.php @@ -27,6 +27,7 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Sabre\VObject\Reader; class SetVcardDatabaseUID implements IRepairStep { const MAX_ROWS = 1000; @@ -70,20 +71,27 @@ class SetVcardDatabaseUID implements IRepairStep { } while (count($rows) > 0); } - private function getUid($carddata) { - preg_match('/UID:(.*)$/m', $carddata, $matches); - if (count($matches) > 1) { - return $matches[1]; + /** + * Extract UID from vcard + * + * @param string $cardData the vcard raw data + * @return string the uid or empty if none + */ + private function getUID(string $cardData): string { + $vCard = Reader::read($cardData); + if ($vCard->UID) { + $uid = $vCard->UID->getValue(); + return $uid; } - return false; + return ''; } /** * @param int $id * @param string $uid */ - private function update($id, $uid) { + private function update(int $id, string $uid) { if (!$this->updateQuery) { $builder = $this->connection->getQueryBuilder(); @@ -98,16 +106,14 @@ class SetVcardDatabaseUID implements IRepairStep { $this->updateQuery->execute(); } - private function repair() { + private function repair(): int { $this->connection->beginTransaction(); $entries = $this->getInvalidEntries(); $count = 0; foreach ($entries as $entry) { $count++; - $uid = $this->getUid($entry['carddata']); - if ($uid !== false) { - $this->update($entry['id'], $uid); - } + $uid = $this->getUID($entry['carddata']); + $this->update($entry['id'], $uid); } $this->connection->commit(); |