@@ -64,7 +64,7 @@ |
||
| 64 | 64 | $this->manager->invalidateTokenById($uid, $token->getId()); |
| 65 | 65 | } |
| 66 | 66 | } catch (Throwable $e) { |
| 67 | - $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
| 67 | + $this->logger->error('Could not clean up auth tokens after user deletion: '.$e->getMessage(), [ |
|
| 68 | 68 | 'exception' => $e, |
| 69 | 69 | ]); |
| 70 | 70 | } |
@@ -19,38 +19,38 @@ |
||
| 19 | 19 | * @template-implements IEventListener<\OCP\User\Events\UserDeletedEvent> |
| 20 | 20 | */ |
| 21 | 21 | class UserDeletedTokenCleanupListener implements IEventListener { |
| 22 | - /** @var Manager */ |
|
| 23 | - private $manager; |
|
| 24 | - |
|
| 25 | - /** @var LoggerInterface */ |
|
| 26 | - private $logger; |
|
| 27 | - |
|
| 28 | - public function __construct(Manager $manager, |
|
| 29 | - LoggerInterface $logger) { |
|
| 30 | - $this->manager = $manager; |
|
| 31 | - $this->logger = $logger; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function handle(Event $event): void { |
|
| 35 | - if (!($event instanceof UserDeletedEvent)) { |
|
| 36 | - // Unrelated |
|
| 37 | - return; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Catch any exception during this process as any failure here shouldn't block the |
|
| 42 | - * user deletion. |
|
| 43 | - */ |
|
| 44 | - try { |
|
| 45 | - $uid = $event->getUser()->getUID(); |
|
| 46 | - $tokens = $this->manager->getTokenByUser($uid); |
|
| 47 | - foreach ($tokens as $token) { |
|
| 48 | - $this->manager->invalidateTokenById($uid, $token->getId()); |
|
| 49 | - } |
|
| 50 | - } catch (Throwable $e) { |
|
| 51 | - $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
| 52 | - 'exception' => $e, |
|
| 53 | - ]); |
|
| 54 | - } |
|
| 55 | - } |
|
| 22 | + /** @var Manager */ |
|
| 23 | + private $manager; |
|
| 24 | + |
|
| 25 | + /** @var LoggerInterface */ |
|
| 26 | + private $logger; |
|
| 27 | + |
|
| 28 | + public function __construct(Manager $manager, |
|
| 29 | + LoggerInterface $logger) { |
|
| 30 | + $this->manager = $manager; |
|
| 31 | + $this->logger = $logger; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function handle(Event $event): void { |
|
| 35 | + if (!($event instanceof UserDeletedEvent)) { |
|
| 36 | + // Unrelated |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Catch any exception during this process as any failure here shouldn't block the |
|
| 42 | + * user deletion. |
|
| 43 | + */ |
|
| 44 | + try { |
|
| 45 | + $uid = $event->getUser()->getUID(); |
|
| 46 | + $tokens = $this->manager->getTokenByUser($uid); |
|
| 47 | + foreach ($tokens as $token) { |
|
| 48 | + $this->manager->invalidateTokenById($uid, $token->getId()); |
|
| 49 | + } |
|
| 50 | + } catch (Throwable $e) { |
|
| 51 | + $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
| 52 | + 'exception' => $e, |
|
| 53 | + ]); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -25,12 +25,12 @@ |
||
| 25 | 25 | ?> |
| 26 | 26 | |
| 27 | 27 | <div id="two-factor-auth" class="section"> |
| 28 | - <h2><?php p($l->t('Two-Factor Authentication'));?></h2> |
|
| 28 | + <h2><?php p($l->t('Two-Factor Authentication')); ?></h2> |
|
| 29 | 29 | <a target="_blank" rel="noreferrer noopener" class="icon-info" |
| 30 | - title="<?php p($l->t('Open documentation'));?>" |
|
| 30 | + title="<?php p($l->t('Open documentation')); ?>" |
|
| 31 | 31 | href="<?php p(link_to_docs('user-2fa')); ?>"></a> |
| 32 | - <p class="settings-hint"><?php p($l->t('Use a second factor besides your password to increase security for your account.'));?></p> |
|
| 33 | - <p class="settings-hint"><?php p($l->t('If you use third party applications to connect to Nextcloud, please make sure to create and configure an app password for each before enabling second factor authentication.'));?></p> |
|
| 32 | + <p class="settings-hint"><?php p($l->t('Use a second factor besides your password to increase security for your account.')); ?></p> |
|
| 33 | + <p class="settings-hint"><?php p($l->t('If you use third party applications to connect to Nextcloud, please make sure to create and configure an app password for each before enabling second factor authentication.')); ?></p> |
|
| 34 | 34 | <ul> |
| 35 | 35 | <?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?> |
| 36 | 36 | <li> |
@@ -19,18 +19,18 @@ |
||
| 19 | 19 | <li> |
| 20 | 20 | <?php |
| 21 | 21 | |
| 22 | - /** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */ |
|
| 23 | - $provider = $data['provider']; |
|
| 24 | - //Handle 2FA provider icons and theme |
|
| 25 | - if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { |
|
| 26 | - $icon = $provider->getDarkIcon(); |
|
| 27 | - //fallback icon if the 2factor provider doesn't provide an icon. |
|
| 28 | - } else { |
|
| 29 | - $icon = image_path('core', 'actions/password.svg'); |
|
| 30 | - } |
|
| 31 | - /** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */ |
|
| 32 | - $settings = $data['settings']; |
|
| 33 | - ?> |
|
| 22 | + /** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */ |
|
| 23 | + $provider = $data['provider']; |
|
| 24 | + //Handle 2FA provider icons and theme |
|
| 25 | + if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { |
|
| 26 | + $icon = $provider->getDarkIcon(); |
|
| 27 | + //fallback icon if the 2factor provider doesn't provide an icon. |
|
| 28 | + } else { |
|
| 29 | + $icon = image_path('core', 'actions/password.svg'); |
|
| 30 | + } |
|
| 31 | + /** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */ |
|
| 32 | + $settings = $data['settings']; |
|
| 33 | + ?> |
|
| 34 | 34 | <h3> |
| 35 | 35 | <img class="two-factor-provider-settings-icon" src="<?php p($icon) ?>" alt=""> |
| 36 | 36 | <?php p($provider->getDisplayName()) ?> |
@@ -29,15 +29,15 @@ |
||
| 29 | 29 | * @deprecated 18.0.0 use events and the \OCP\EventDispatcher\IEventDispatcher service |
| 30 | 30 | */ |
| 31 | 31 | class PublicEmitter extends BasicEmitter { |
| 32 | - /** |
|
| 33 | - * @param string $scope |
|
| 34 | - * @param string $method |
|
| 35 | - * @param array $arguments optional |
|
| 36 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped |
|
| 37 | - * |
|
| 38 | - * @suppress PhanAccessMethodProtected |
|
| 39 | - */ |
|
| 40 | - public function emit($scope, $method, array $arguments = []) { |
|
| 41 | - parent::emit($scope, $method, $arguments); |
|
| 42 | - } |
|
| 32 | + /** |
|
| 33 | + * @param string $scope |
|
| 34 | + * @param string $method |
|
| 35 | + * @param array $arguments optional |
|
| 36 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped |
|
| 37 | + * |
|
| 38 | + * @suppress PhanAccessMethodProtected |
|
| 39 | + */ |
|
| 40 | + public function emit($scope, $method, array $arguments = []) { |
|
| 41 | + parent::emit($scope, $method, $arguments); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | $managerProvider = $this->managerProvider; |
| 64 | 64 | $manager = $managerProvider(); |
| 65 | 65 | $data['manager'] = $manager; |
| 66 | - $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/'); |
|
| 66 | + $mountPoint = '/'.$user->getUID().'/files/'.ltrim($data['mountpoint'], '/'); |
|
| 67 | 67 | $data['mountpoint'] = $mountPoint; |
| 68 | 68 | $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']); |
| 69 | 69 | $data['certificateManager'] = \OC::$server->getCertificateManager(); |
@@ -17,52 +17,52 @@ |
||
| 17 | 17 | use OCP\Server; |
| 18 | 18 | |
| 19 | 19 | class MountProvider implements IMountProvider { |
| 20 | - public const STORAGE = '\OCA\Files_Sharing\External\Storage'; |
|
| 20 | + public const STORAGE = '\OCA\Files_Sharing\External\Storage'; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var callable |
|
| 24 | - */ |
|
| 25 | - private $managerProvider; |
|
| 22 | + /** |
|
| 23 | + * @var callable |
|
| 24 | + */ |
|
| 25 | + private $managerProvider; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param IDBConnection $connection |
|
| 29 | - * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself |
|
| 30 | - * @param ICloudIdManager $cloudIdManager |
|
| 31 | - */ |
|
| 32 | - public function __construct( |
|
| 33 | - private IDBConnection $connection, |
|
| 34 | - callable $managerProvider, |
|
| 35 | - private ICloudIdManager $cloudIdManager, |
|
| 36 | - ) { |
|
| 37 | - $this->managerProvider = $managerProvider; |
|
| 38 | - } |
|
| 27 | + /** |
|
| 28 | + * @param IDBConnection $connection |
|
| 29 | + * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself |
|
| 30 | + * @param ICloudIdManager $cloudIdManager |
|
| 31 | + */ |
|
| 32 | + public function __construct( |
|
| 33 | + private IDBConnection $connection, |
|
| 34 | + callable $managerProvider, |
|
| 35 | + private ICloudIdManager $cloudIdManager, |
|
| 36 | + ) { |
|
| 37 | + $this->managerProvider = $managerProvider; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function getMount(IUser $user, $data, IStorageFactory $storageFactory) { |
|
| 41 | - $managerProvider = $this->managerProvider; |
|
| 42 | - $manager = $managerProvider(); |
|
| 43 | - $data['manager'] = $manager; |
|
| 44 | - $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/'); |
|
| 45 | - $data['mountpoint'] = $mountPoint; |
|
| 46 | - $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']); |
|
| 47 | - $data['certificateManager'] = \OC::$server->getCertificateManager(); |
|
| 48 | - $data['HttpClientService'] = Server::get(IClientService::class); |
|
| 49 | - return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory); |
|
| 50 | - } |
|
| 40 | + public function getMount(IUser $user, $data, IStorageFactory $storageFactory) { |
|
| 41 | + $managerProvider = $this->managerProvider; |
|
| 42 | + $manager = $managerProvider(); |
|
| 43 | + $data['manager'] = $manager; |
|
| 44 | + $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/'); |
|
| 45 | + $data['mountpoint'] = $mountPoint; |
|
| 46 | + $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']); |
|
| 47 | + $data['certificateManager'] = \OC::$server->getCertificateManager(); |
|
| 48 | + $data['HttpClientService'] = Server::get(IClientService::class); |
|
| 49 | + return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
| 53 | - $qb = $this->connection->getQueryBuilder(); |
|
| 54 | - $qb->select('remote', 'share_token', 'password', 'mountpoint', 'owner') |
|
| 55 | - ->from('share_external') |
|
| 56 | - ->where($qb->expr()->eq('user', $qb->createNamedParameter($user->getUID()))) |
|
| 57 | - ->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))); |
|
| 58 | - $result = $qb->executeQuery(); |
|
| 59 | - $mounts = []; |
|
| 60 | - while ($row = $result->fetchAssociative()) { |
|
| 61 | - $row['manager'] = $this; |
|
| 62 | - $row['token'] = $row['share_token']; |
|
| 63 | - $mounts[] = $this->getMount($user, $row, $loader); |
|
| 64 | - } |
|
| 65 | - $result->closeCursor(); |
|
| 66 | - return $mounts; |
|
| 67 | - } |
|
| 52 | + public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
| 53 | + $qb = $this->connection->getQueryBuilder(); |
|
| 54 | + $qb->select('remote', 'share_token', 'password', 'mountpoint', 'owner') |
|
| 55 | + ->from('share_external') |
|
| 56 | + ->where($qb->expr()->eq('user', $qb->createNamedParameter($user->getUID()))) |
|
| 57 | + ->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))); |
|
| 58 | + $result = $qb->executeQuery(); |
|
| 59 | + $mounts = []; |
|
| 60 | + while ($row = $result->fetchAssociative()) { |
|
| 61 | + $row['manager'] = $this; |
|
| 62 | + $row['token'] = $row['share_token']; |
|
| 63 | + $mounts[] = $this->getMount($user, $row, $loader); |
|
| 64 | + } |
|
| 65 | + $result->closeCursor(); |
|
| 66 | + return $mounts; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | * @param bool $httpOnly |
| 95 | 95 | */ |
| 96 | 96 | public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
| 97 | - $path = $this->webRoot ? : '/'; |
|
| 97 | + $path = $this->webRoot ?: '/'; |
|
| 98 | 98 | |
| 99 | 99 | setcookie($name, $value, [ |
| 100 | 100 | 'expires' => $expire, |
@@ -13,72 +13,72 @@ |
||
| 13 | 13 | * Very thin wrapper class to make output testable |
| 14 | 14 | */ |
| 15 | 15 | class Output implements IOutput { |
| 16 | - public function __construct( |
|
| 17 | - private string $webRoot, |
|
| 18 | - ) { |
|
| 19 | - } |
|
| 16 | + public function __construct( |
|
| 17 | + private string $webRoot, |
|
| 18 | + ) { |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $out |
|
| 23 | - */ |
|
| 24 | - public function setOutput($out) { |
|
| 25 | - print($out); |
|
| 26 | - } |
|
| 21 | + /** |
|
| 22 | + * @param string $out |
|
| 23 | + */ |
|
| 24 | + public function setOutput($out) { |
|
| 25 | + print($out); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param string|resource $path or file handle |
|
| 30 | - * |
|
| 31 | - * @return bool false if an error occurred |
|
| 32 | - */ |
|
| 33 | - public function setReadfile($path) { |
|
| 34 | - if (is_resource($path)) { |
|
| 35 | - $output = fopen('php://output', 'w'); |
|
| 36 | - return stream_copy_to_stream($path, $output) > 0; |
|
| 37 | - } else { |
|
| 38 | - return @readfile($path); |
|
| 39 | - } |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * @param string|resource $path or file handle |
|
| 30 | + * |
|
| 31 | + * @return bool false if an error occurred |
|
| 32 | + */ |
|
| 33 | + public function setReadfile($path) { |
|
| 34 | + if (is_resource($path)) { |
|
| 35 | + $output = fopen('php://output', 'w'); |
|
| 36 | + return stream_copy_to_stream($path, $output) > 0; |
|
| 37 | + } else { |
|
| 38 | + return @readfile($path); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param string $header |
|
| 44 | - */ |
|
| 45 | - public function setHeader($header) { |
|
| 46 | - header($header); |
|
| 47 | - } |
|
| 42 | + /** |
|
| 43 | + * @param string $header |
|
| 44 | + */ |
|
| 45 | + public function setHeader($header) { |
|
| 46 | + header($header); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @param int $code sets the http status code |
|
| 51 | - */ |
|
| 52 | - public function setHttpResponseCode($code) { |
|
| 53 | - http_response_code($code); |
|
| 54 | - } |
|
| 49 | + /** |
|
| 50 | + * @param int $code sets the http status code |
|
| 51 | + */ |
|
| 52 | + public function setHttpResponseCode($code) { |
|
| 53 | + http_response_code($code); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return int returns the current http response code |
|
| 58 | - */ |
|
| 59 | - public function getHttpResponseCode() { |
|
| 60 | - return http_response_code(); |
|
| 61 | - } |
|
| 56 | + /** |
|
| 57 | + * @return int returns the current http response code |
|
| 58 | + */ |
|
| 59 | + public function getHttpResponseCode() { |
|
| 60 | + return http_response_code(); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param string $name |
|
| 65 | - * @param string $value |
|
| 66 | - * @param int $expire |
|
| 67 | - * @param string $path |
|
| 68 | - * @param string $domain |
|
| 69 | - * @param bool $secure |
|
| 70 | - * @param bool $httpOnly |
|
| 71 | - */ |
|
| 72 | - public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
|
| 73 | - $path = $this->webRoot ? : '/'; |
|
| 63 | + /** |
|
| 64 | + * @param string $name |
|
| 65 | + * @param string $value |
|
| 66 | + * @param int $expire |
|
| 67 | + * @param string $path |
|
| 68 | + * @param string $domain |
|
| 69 | + * @param bool $secure |
|
| 70 | + * @param bool $httpOnly |
|
| 71 | + */ |
|
| 72 | + public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
|
| 73 | + $path = $this->webRoot ? : '/'; |
|
| 74 | 74 | |
| 75 | - setcookie($name, $value, [ |
|
| 76 | - 'expires' => $expire, |
|
| 77 | - 'path' => $path, |
|
| 78 | - 'domain' => $domain, |
|
| 79 | - 'secure' => $secure, |
|
| 80 | - 'httponly' => $httpOnly, |
|
| 81 | - 'samesite' => $sameSite |
|
| 82 | - ]); |
|
| 83 | - } |
|
| 75 | + setcookie($name, $value, [ |
|
| 76 | + 'expires' => $expire, |
|
| 77 | + 'path' => $path, |
|
| 78 | + 'domain' => $domain, |
|
| 79 | + 'secure' => $secure, |
|
| 80 | + 'httponly' => $httpOnly, |
|
| 81 | + 'samesite' => $sameSite |
|
| 82 | + ]); |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -34,19 +34,19 @@ |
||
| 34 | 34 | use OCP\Migration\SimpleMigrationStep; |
| 35 | 35 | |
| 36 | 36 | class Version14000Date20180710092004 extends SimpleMigrationStep { |
| 37 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 38 | - /** @var ISchemaWrapper $schema */ |
|
| 39 | - $schema = $schemaClosure(); |
|
| 37 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 38 | + /** @var ISchemaWrapper $schema */ |
|
| 39 | + $schema = $schemaClosure(); |
|
| 40 | 40 | |
| 41 | - $table = $schema->getTable('share'); |
|
| 41 | + $table = $schema->getTable('share'); |
|
| 42 | 42 | |
| 43 | - if (!$table->hasColumn('password_by_talk')) { |
|
| 44 | - $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
| 45 | - 'default' => 0, |
|
| 46 | - 'notnull' => false, |
|
| 47 | - ]); |
|
| 48 | - } |
|
| 43 | + if (!$table->hasColumn('password_by_talk')) { |
|
| 44 | + $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
| 45 | + 'default' => 0, |
|
| 46 | + 'notnull' => false, |
|
| 47 | + ]); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return $schema; |
|
| 51 | - } |
|
| 50 | + return $schema; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -32,30 +32,30 @@ |
||
| 32 | 32 | use OCP\Migration\SimpleMigrationStep; |
| 33 | 33 | |
| 34 | 34 | class Version1016Date20201109085907 extends SimpleMigrationStep { |
| 35 | - /** |
|
| 36 | - * @param IOutput $output |
|
| 37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | - * @param array $options |
|
| 39 | - * @return null|ISchemaWrapper |
|
| 40 | - */ |
|
| 41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 42 | - /** @var ISchemaWrapper $schema */ |
|
| 43 | - $schema = $schemaClosure(); |
|
| 44 | - |
|
| 45 | - $result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring'); |
|
| 46 | - |
|
| 47 | - return $result ? $schema : null; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
| 51 | - $table = $schema->getTable($tableName); |
|
| 52 | - $column = $table->getColumn($columnName); |
|
| 53 | - |
|
| 54 | - if ($column->getNotnull()) { |
|
| 55 | - $column->setNotnull(false); |
|
| 56 | - return true; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - return false; |
|
| 60 | - } |
|
| 35 | + /** |
|
| 36 | + * @param IOutput $output |
|
| 37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | + * @param array $options |
|
| 39 | + * @return null|ISchemaWrapper |
|
| 40 | + */ |
|
| 41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 42 | + /** @var ISchemaWrapper $schema */ |
|
| 43 | + $schema = $schemaClosure(); |
|
| 44 | + |
|
| 45 | + $result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring'); |
|
| 46 | + |
|
| 47 | + return $result ? $schema : null; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
| 51 | + $table = $schema->getTable($tableName); |
|
| 52 | + $column = $table->getColumn($columnName); |
|
| 53 | + |
|
| 54 | + if ($column->getNotnull()) { |
|
| 55 | + $column->setNotnull(false); |
|
| 56 | + return true; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -32,30 +32,30 @@ |
||
| 32 | 32 | use OCP\Migration\SimpleMigrationStep; |
| 33 | 33 | |
| 34 | 34 | class Version20000Date20201111081915 extends SimpleMigrationStep { |
| 35 | - /** |
|
| 36 | - * @param IOutput $output |
|
| 37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | - * @param array $options |
|
| 39 | - * @return null|ISchemaWrapper |
|
| 40 | - */ |
|
| 41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 42 | - /** @var ISchemaWrapper $schema */ |
|
| 43 | - $schema = $schemaClosure(); |
|
| 44 | - |
|
| 45 | - $result = $this->ensureColumnIsNullable($schema, 'direct_edit', 'accessed'); |
|
| 46 | - |
|
| 47 | - return $result ? $schema : null; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
| 51 | - $table = $schema->getTable($tableName); |
|
| 52 | - $column = $table->getColumn($columnName); |
|
| 53 | - |
|
| 54 | - if ($column->getNotnull()) { |
|
| 55 | - $column->setNotnull(false); |
|
| 56 | - return true; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - return false; |
|
| 60 | - } |
|
| 35 | + /** |
|
| 36 | + * @param IOutput $output |
|
| 37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 38 | + * @param array $options |
|
| 39 | + * @return null|ISchemaWrapper |
|
| 40 | + */ |
|
| 41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 42 | + /** @var ISchemaWrapper $schema */ |
|
| 43 | + $schema = $schemaClosure(); |
|
| 44 | + |
|
| 45 | + $result = $this->ensureColumnIsNullable($schema, 'direct_edit', 'accessed'); |
|
| 46 | + |
|
| 47 | + return $result ? $schema : null; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
| 51 | + $table = $schema->getTable($tableName); |
|
| 52 | + $column = $table->getColumn($columnName); |
|
| 53 | + |
|
| 54 | + if ($column->getNotnull()) { |
|
| 55 | + $column->setNotnull(false); |
|
| 56 | + return true; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -37,61 +37,61 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class Version0001Date20200602134824 extends SimpleMigrationStep { |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param IOutput $output |
|
| 42 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 43 | - * @param array $options |
|
| 44 | - * @return null|ISchemaWrapper |
|
| 45 | - * @since 20.0.0 |
|
| 46 | - */ |
|
| 47 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 48 | - /** @var ISchemaWrapper $schema */ |
|
| 49 | - $schema = $schemaClosure(); |
|
| 40 | + /** |
|
| 41 | + * @param IOutput $output |
|
| 42 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 43 | + * @param array $options |
|
| 44 | + * @return null|ISchemaWrapper |
|
| 45 | + * @since 20.0.0 |
|
| 46 | + */ |
|
| 47 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 48 | + /** @var ISchemaWrapper $schema */ |
|
| 49 | + $schema = $schemaClosure(); |
|
| 50 | 50 | |
| 51 | - $statusTable = $schema->createTable('user_status'); |
|
| 52 | - $statusTable->addColumn('id', Types::BIGINT, [ |
|
| 53 | - 'autoincrement' => true, |
|
| 54 | - 'notnull' => true, |
|
| 55 | - 'length' => 20, |
|
| 56 | - 'unsigned' => true, |
|
| 57 | - ]); |
|
| 58 | - $statusTable->addColumn('user_id', Types::STRING, [ |
|
| 59 | - 'notnull' => true, |
|
| 60 | - 'length' => 255, |
|
| 61 | - ]); |
|
| 62 | - $statusTable->addColumn('status', Types::STRING, [ |
|
| 63 | - 'notnull' => true, |
|
| 64 | - 'length' => 255, |
|
| 65 | - ]); |
|
| 66 | - $statusTable->addColumn('status_timestamp', Types::INTEGER, [ |
|
| 67 | - 'notnull' => true, |
|
| 68 | - 'length' => 11, |
|
| 69 | - 'unsigned' => true, |
|
| 70 | - ]); |
|
| 71 | - $statusTable->addColumn('is_user_defined', Types::BOOLEAN, [ |
|
| 72 | - 'notnull' => false, |
|
| 73 | - ]); |
|
| 74 | - $statusTable->addColumn('message_id', Types::STRING, [ |
|
| 75 | - 'notnull' => false, |
|
| 76 | - 'length' => 255, |
|
| 77 | - ]); |
|
| 78 | - $statusTable->addColumn('custom_icon', Types::STRING, [ |
|
| 79 | - 'notnull' => false, |
|
| 80 | - 'length' => 255, |
|
| 81 | - ]); |
|
| 82 | - $statusTable->addColumn('custom_message', Types::TEXT, [ |
|
| 83 | - 'notnull' => false, |
|
| 84 | - ]); |
|
| 85 | - $statusTable->addColumn('clear_at', Types::INTEGER, [ |
|
| 86 | - 'notnull' => false, |
|
| 87 | - 'length' => 11, |
|
| 88 | - 'unsigned' => true, |
|
| 89 | - ]); |
|
| 51 | + $statusTable = $schema->createTable('user_status'); |
|
| 52 | + $statusTable->addColumn('id', Types::BIGINT, [ |
|
| 53 | + 'autoincrement' => true, |
|
| 54 | + 'notnull' => true, |
|
| 55 | + 'length' => 20, |
|
| 56 | + 'unsigned' => true, |
|
| 57 | + ]); |
|
| 58 | + $statusTable->addColumn('user_id', Types::STRING, [ |
|
| 59 | + 'notnull' => true, |
|
| 60 | + 'length' => 255, |
|
| 61 | + ]); |
|
| 62 | + $statusTable->addColumn('status', Types::STRING, [ |
|
| 63 | + 'notnull' => true, |
|
| 64 | + 'length' => 255, |
|
| 65 | + ]); |
|
| 66 | + $statusTable->addColumn('status_timestamp', Types::INTEGER, [ |
|
| 67 | + 'notnull' => true, |
|
| 68 | + 'length' => 11, |
|
| 69 | + 'unsigned' => true, |
|
| 70 | + ]); |
|
| 71 | + $statusTable->addColumn('is_user_defined', Types::BOOLEAN, [ |
|
| 72 | + 'notnull' => false, |
|
| 73 | + ]); |
|
| 74 | + $statusTable->addColumn('message_id', Types::STRING, [ |
|
| 75 | + 'notnull' => false, |
|
| 76 | + 'length' => 255, |
|
| 77 | + ]); |
|
| 78 | + $statusTable->addColumn('custom_icon', Types::STRING, [ |
|
| 79 | + 'notnull' => false, |
|
| 80 | + 'length' => 255, |
|
| 81 | + ]); |
|
| 82 | + $statusTable->addColumn('custom_message', Types::TEXT, [ |
|
| 83 | + 'notnull' => false, |
|
| 84 | + ]); |
|
| 85 | + $statusTable->addColumn('clear_at', Types::INTEGER, [ |
|
| 86 | + 'notnull' => false, |
|
| 87 | + 'length' => 11, |
|
| 88 | + 'unsigned' => true, |
|
| 89 | + ]); |
|
| 90 | 90 | |
| 91 | - $statusTable->setPrimaryKey(['id']); |
|
| 92 | - $statusTable->addUniqueIndex(['user_id'], 'user_status_uid_ix'); |
|
| 93 | - $statusTable->addIndex(['clear_at'], 'user_status_clr_ix'); |
|
| 91 | + $statusTable->setPrimaryKey(['id']); |
|
| 92 | + $statusTable->addUniqueIndex(['user_id'], 'user_status_uid_ix'); |
|
| 93 | + $statusTable->addIndex(['clear_at'], 'user_status_clr_ix'); |
|
| 94 | 94 | |
| 95 | - return $schema; |
|
| 96 | - } |
|
| 95 | + return $schema; |
|
| 96 | + } |
|
| 97 | 97 | } |