@@ -36,47 +36,47 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class OwncloudGuestShareType implements IRepairStep { |
| 38 | 38 | |
| 39 | - /** @var IDBConnection */ |
|
| 40 | - private $connection; |
|
| 39 | + /** @var IDBConnection */ |
|
| 40 | + private $connection; |
|
| 41 | 41 | |
| 42 | - /** @var IConfig */ |
|
| 43 | - private $config; |
|
| 42 | + /** @var IConfig */ |
|
| 43 | + private $config; |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - public function __construct(IDBConnection $connection, IConfig $config) { |
|
| 47 | - $this->connection = $connection; |
|
| 48 | - $this->config = $config; |
|
| 49 | - } |
|
| 46 | + public function __construct(IDBConnection $connection, IConfig $config) { |
|
| 47 | + $this->connection = $connection; |
|
| 48 | + $this->config = $config; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Returns the step's name |
|
| 53 | - * |
|
| 54 | - * @return string |
|
| 55 | - * @since 9.1.0 |
|
| 56 | - */ |
|
| 57 | - public function getName() { |
|
| 58 | - return 'Fix the share type of guest shares when migrating from ownCloud'; |
|
| 59 | - } |
|
| 51 | + /** |
|
| 52 | + * Returns the step's name |
|
| 53 | + * |
|
| 54 | + * @return string |
|
| 55 | + * @since 9.1.0 |
|
| 56 | + */ |
|
| 57 | + public function getName() { |
|
| 58 | + return 'Fix the share type of guest shares when migrating from ownCloud'; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @param IOutput $output |
|
| 63 | - */ |
|
| 64 | - public function run(IOutput $output) { |
|
| 65 | - if (!$this->shouldRun()) { |
|
| 66 | - return; |
|
| 67 | - } |
|
| 61 | + /** |
|
| 62 | + * @param IOutput $output |
|
| 63 | + */ |
|
| 64 | + public function run(IOutput $output) { |
|
| 65 | + if (!$this->shouldRun()) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $query = $this->connection->getQueryBuilder(); |
|
| 70 | - $query->update('share') |
|
| 71 | - ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
| 72 | - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
|
| 73 | - $query->execute(); |
|
| 74 | - } |
|
| 69 | + $query = $this->connection->getQueryBuilder(); |
|
| 70 | + $query->update('share') |
|
| 71 | + ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
| 72 | + ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
|
| 73 | + $query->execute(); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - protected function shouldRun() { |
|
| 77 | - $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
| 78 | - return in_array($appVersion, ['0.10.0']) || |
|
| 79 | - $this->config->getAppValue('core', 'vendor', '') === 'owncloud'; |
|
| 80 | - } |
|
| 76 | + protected function shouldRun() { |
|
| 77 | + $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
| 78 | + return in_array($appVersion, ['0.10.0']) || |
|
| 79 | + $this->config->getAppValue('core', 'vendor', '') === 'owncloud'; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | |
| 69 | 69 | $query = $this->connection->getQueryBuilder(); |
| 70 | 70 | $query->update('share') |
| 71 | - ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
| 71 | + ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
| 72 | 72 | ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
| 73 | 73 | $query->execute(); |
| 74 | 74 | } |
@@ -36,62 +36,62 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class SetPasswordColumn implements IRepairStep { |
| 38 | 38 | |
| 39 | - /** @var IDBConnection */ |
|
| 40 | - private $connection; |
|
| 41 | - |
|
| 42 | - /** @var IConfig */ |
|
| 43 | - private $config; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - public function __construct(IDBConnection $connection, IConfig $config) { |
|
| 47 | - $this->connection = $connection; |
|
| 48 | - $this->config = $config; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Returns the step's name |
|
| 53 | - * |
|
| 54 | - * @return string |
|
| 55 | - * @since 9.1.0 |
|
| 56 | - */ |
|
| 57 | - public function getName() { |
|
| 58 | - return 'Copy the share password into the dedicated column'; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param IOutput $output |
|
| 63 | - */ |
|
| 64 | - public function run(IOutput $output) { |
|
| 65 | - if (!$this->shouldRun()) { |
|
| 66 | - return; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $query = $this->connection->getQueryBuilder(); |
|
| 70 | - $query |
|
| 71 | - ->update('share') |
|
| 72 | - ->set('password', 'share_with') |
|
| 73 | - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) |
|
| 74 | - ->andWhere($query->expr()->isNotNull('share_with')); |
|
| 75 | - $result = $query->execute(); |
|
| 76 | - |
|
| 77 | - if ($result === 0) { |
|
| 78 | - // No link updated, no need to run the second query |
|
| 79 | - return; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - $clearQuery = $this->connection->getQueryBuilder(); |
|
| 83 | - $clearQuery |
|
| 84 | - ->update('share') |
|
| 85 | - ->set('share_with', $clearQuery->createNamedParameter(null)) |
|
| 86 | - ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); |
|
| 87 | - |
|
| 88 | - $clearQuery->execute(); |
|
| 89 | - |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - protected function shouldRun() { |
|
| 93 | - $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
| 94 | - return version_compare($appVersion, '1.4.0', '<'); |
|
| 95 | - } |
|
| 39 | + /** @var IDBConnection */ |
|
| 40 | + private $connection; |
|
| 41 | + |
|
| 42 | + /** @var IConfig */ |
|
| 43 | + private $config; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + public function __construct(IDBConnection $connection, IConfig $config) { |
|
| 47 | + $this->connection = $connection; |
|
| 48 | + $this->config = $config; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Returns the step's name |
|
| 53 | + * |
|
| 54 | + * @return string |
|
| 55 | + * @since 9.1.0 |
|
| 56 | + */ |
|
| 57 | + public function getName() { |
|
| 58 | + return 'Copy the share password into the dedicated column'; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param IOutput $output |
|
| 63 | + */ |
|
| 64 | + public function run(IOutput $output) { |
|
| 65 | + if (!$this->shouldRun()) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $query = $this->connection->getQueryBuilder(); |
|
| 70 | + $query |
|
| 71 | + ->update('share') |
|
| 72 | + ->set('password', 'share_with') |
|
| 73 | + ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) |
|
| 74 | + ->andWhere($query->expr()->isNotNull('share_with')); |
|
| 75 | + $result = $query->execute(); |
|
| 76 | + |
|
| 77 | + if ($result === 0) { |
|
| 78 | + // No link updated, no need to run the second query |
|
| 79 | + return; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + $clearQuery = $this->connection->getQueryBuilder(); |
|
| 83 | + $clearQuery |
|
| 84 | + ->update('share') |
|
| 85 | + ->set('share_with', $clearQuery->createNamedParameter(null)) |
|
| 86 | + ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); |
|
| 87 | + |
|
| 88 | + $clearQuery->execute(); |
|
| 89 | + |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + protected function shouldRun() { |
|
| 93 | + $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
| 94 | + return version_compare($appVersion, '1.4.0', '<'); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | } |