@@ -6,44 +6,44 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitFederatedFileSharing |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'O' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'OCA\\FederatedFileSharing\\' => 25, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'OCA\\FederatedFileSharing\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/..'.'/../lib', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
| 25 | - 'OCA\\FederatedFileSharing\\AddressHandler' => __DIR__ . '/..' . '/../lib/AddressHandler.php', |
|
| 26 | - 'OCA\\FederatedFileSharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
| 27 | - 'OCA\\FederatedFileSharing\\BackgroundJob\\RetryJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/RetryJob.php', |
|
| 28 | - 'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => __DIR__ . '/..' . '/../lib/Controller/MountPublicLinkController.php', |
|
| 29 | - 'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => __DIR__ . '/..' . '/../lib/Controller/RequestHandlerController.php', |
|
| 30 | - 'OCA\\FederatedFileSharing\\Events\\FederatedShareAddedEvent' => __DIR__ . '/..' . '/../lib/Events/FederatedShareAddedEvent.php', |
|
| 31 | - 'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php', |
|
| 32 | - 'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listeners/LoadAdditionalScriptsListener.php', |
|
| 33 | - 'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191755.php', |
|
| 34 | - 'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20201120125158.php', |
|
| 35 | - 'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php', |
|
| 36 | - 'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php', |
|
| 37 | - 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__ . '/..' . '/../lib/OCM/CloudFederationProviderFiles.php', |
|
| 38 | - 'OCA\\FederatedFileSharing\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php', |
|
| 39 | - 'OCA\\FederatedFileSharing\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php', |
|
| 40 | - 'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => __DIR__ . '/..' . '/../lib/Settings/PersonalSection.php', |
|
| 41 | - 'OCA\\FederatedFileSharing\\TokenHandler' => __DIR__ . '/..' . '/../lib/TokenHandler.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
| 25 | + 'OCA\\FederatedFileSharing\\AddressHandler' => __DIR__.'/..'.'/../lib/AddressHandler.php', |
|
| 26 | + 'OCA\\FederatedFileSharing\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
| 27 | + 'OCA\\FederatedFileSharing\\BackgroundJob\\RetryJob' => __DIR__.'/..'.'/../lib/BackgroundJob/RetryJob.php', |
|
| 28 | + 'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => __DIR__.'/..'.'/../lib/Controller/MountPublicLinkController.php', |
|
| 29 | + 'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => __DIR__.'/..'.'/../lib/Controller/RequestHandlerController.php', |
|
| 30 | + 'OCA\\FederatedFileSharing\\Events\\FederatedShareAddedEvent' => __DIR__.'/..'.'/../lib/Events/FederatedShareAddedEvent.php', |
|
| 31 | + 'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__.'/..'.'/../lib/FederatedShareProvider.php', |
|
| 32 | + 'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => __DIR__.'/..'.'/../lib/Listeners/LoadAdditionalScriptsListener.php', |
|
| 33 | + 'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__.'/..'.'/../lib/Migration/Version1010Date20200630191755.php', |
|
| 34 | + 'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => __DIR__.'/..'.'/../lib/Migration/Version1011Date20201120125158.php', |
|
| 35 | + 'OCA\\FederatedFileSharing\\Notifications' => __DIR__.'/..'.'/../lib/Notifications.php', |
|
| 36 | + 'OCA\\FederatedFileSharing\\Notifier' => __DIR__.'/..'.'/../lib/Notifier.php', |
|
| 37 | + 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__.'/..'.'/../lib/OCM/CloudFederationProviderFiles.php', |
|
| 38 | + 'OCA\\FederatedFileSharing\\Settings\\Admin' => __DIR__.'/..'.'/../lib/Settings/Admin.php', |
|
| 39 | + 'OCA\\FederatedFileSharing\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php', |
|
| 40 | + 'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => __DIR__.'/..'.'/../lib/Settings/PersonalSection.php', |
|
| 41 | + 'OCA\\FederatedFileSharing\\TokenHandler' => __DIR__.'/..'.'/../lib/TokenHandler.php', |
|
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | 44 | public static function getInitializer(ClassLoader $loader) |
| 45 | 45 | { |
| 46 | - return \Closure::bind(function () use ($loader) { |
|
| 46 | + return \Closure::bind(function() use ($loader) { |
|
| 47 | 47 | $loader->prefixLengthsPsr4 = ComposerStaticInitFederatedFileSharing::$prefixLengthsPsr4; |
| 48 | 48 | $loader->prefixDirsPsr4 = ComposerStaticInitFederatedFileSharing::$prefixDirsPsr4; |
| 49 | 49 | $loader->classMap = ComposerStaticInitFederatedFileSharing::$classMap; |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | |
| 65 | 65 | public function run(IOutput $output) { |
| 66 | 66 | if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) { |
| 67 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
| 67 | + $this->userManager->callForSeenUsers(function(IUser $user) { |
|
| 68 | 68 | $this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]); |
| 69 | 69 | }); |
| 70 | 70 | $this->config->setAppValue('core', 'previewsCleanedUp', '1'); |
@@ -14,43 +14,43 @@ |
||
| 14 | 14 | use OCP\Migration\IRepairStep; |
| 15 | 15 | |
| 16 | 16 | class CleanPreviews implements IRepairStep { |
| 17 | - /** @var IJobList */ |
|
| 18 | - private $jobList; |
|
| 19 | - |
|
| 20 | - /** @var IUserManager */ |
|
| 21 | - private $userManager; |
|
| 22 | - |
|
| 23 | - /** @var IConfig */ |
|
| 24 | - private $config; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * MoveAvatars constructor. |
|
| 28 | - * |
|
| 29 | - * @param IJobList $jobList |
|
| 30 | - * @param IUserManager $userManager |
|
| 31 | - * @param IConfig $config |
|
| 32 | - */ |
|
| 33 | - public function __construct(IJobList $jobList, |
|
| 34 | - IUserManager $userManager, |
|
| 35 | - IConfig $config) { |
|
| 36 | - $this->jobList = $jobList; |
|
| 37 | - $this->userManager = $userManager; |
|
| 38 | - $this->config = $config; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function getName() { |
|
| 45 | - return 'Add preview cleanup background jobs'; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function run(IOutput $output) { |
|
| 49 | - if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) { |
|
| 50 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
| 51 | - $this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]); |
|
| 52 | - }); |
|
| 53 | - $this->config->setAppValue('core', 'previewsCleanedUp', '1'); |
|
| 54 | - } |
|
| 55 | - } |
|
| 17 | + /** @var IJobList */ |
|
| 18 | + private $jobList; |
|
| 19 | + |
|
| 20 | + /** @var IUserManager */ |
|
| 21 | + private $userManager; |
|
| 22 | + |
|
| 23 | + /** @var IConfig */ |
|
| 24 | + private $config; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * MoveAvatars constructor. |
|
| 28 | + * |
|
| 29 | + * @param IJobList $jobList |
|
| 30 | + * @param IUserManager $userManager |
|
| 31 | + * @param IConfig $config |
|
| 32 | + */ |
|
| 33 | + public function __construct(IJobList $jobList, |
|
| 34 | + IUserManager $userManager, |
|
| 35 | + IConfig $config) { |
|
| 36 | + $this->jobList = $jobList; |
|
| 37 | + $this->userManager = $userManager; |
|
| 38 | + $this->config = $config; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | + public function getName() { |
|
| 45 | + return 'Add preview cleanup background jobs'; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function run(IOutput $output) { |
|
| 49 | + if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) { |
|
| 50 | + $this->userManager->callForSeenUsers(function (IUser $user) { |
|
| 51 | + $this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]); |
|
| 52 | + }); |
|
| 53 | + $this->config->setAppValue('core', 'previewsCleanedUp', '1'); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -33,55 +33,55 @@ |
||
| 33 | 33 | use OCP\Migration\SimpleMigrationStep; |
| 34 | 34 | |
| 35 | 35 | class Version1010Date20200630192639 extends SimpleMigrationStep { |
| 36 | - /** |
|
| 37 | - * @param IOutput $output |
|
| 38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 39 | - * @param array $options |
|
| 40 | - * @return null|ISchemaWrapper |
|
| 41 | - */ |
|
| 42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 43 | - /** @var ISchemaWrapper $schema */ |
|
| 44 | - $schema = $schemaClosure(); |
|
| 36 | + /** |
|
| 37 | + * @param IOutput $output |
|
| 38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 39 | + * @param array $options |
|
| 40 | + * @return null|ISchemaWrapper |
|
| 41 | + */ |
|
| 42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 43 | + /** @var ISchemaWrapper $schema */ |
|
| 44 | + $schema = $schemaClosure(); |
|
| 45 | 45 | |
| 46 | - if (!$schema->hasTable('files_trash')) { |
|
| 47 | - $table = $schema->createTable('files_trash'); |
|
| 48 | - $table->addColumn('auto_id', Types::BIGINT, [ |
|
| 49 | - 'autoincrement' => true, |
|
| 50 | - 'notnull' => true, |
|
| 51 | - ]); |
|
| 52 | - $table->addColumn('id', Types::STRING, [ |
|
| 53 | - 'notnull' => true, |
|
| 54 | - 'length' => 250, |
|
| 55 | - 'default' => '', |
|
| 56 | - ]); |
|
| 57 | - $table->addColumn('user', Types::STRING, [ |
|
| 58 | - 'notnull' => true, |
|
| 59 | - 'length' => 64, |
|
| 60 | - 'default' => '', |
|
| 61 | - ]); |
|
| 62 | - $table->addColumn('timestamp', Types::STRING, [ |
|
| 63 | - 'notnull' => true, |
|
| 64 | - 'length' => 12, |
|
| 65 | - 'default' => '', |
|
| 66 | - ]); |
|
| 67 | - $table->addColumn('location', Types::STRING, [ |
|
| 68 | - 'notnull' => true, |
|
| 69 | - 'length' => 512, |
|
| 70 | - 'default' => '', |
|
| 71 | - ]); |
|
| 72 | - $table->addColumn('type', Types::STRING, [ |
|
| 73 | - 'notnull' => false, |
|
| 74 | - 'length' => 4, |
|
| 75 | - ]); |
|
| 76 | - $table->addColumn('mime', Types::STRING, [ |
|
| 77 | - 'notnull' => false, |
|
| 78 | - 'length' => 255, |
|
| 79 | - ]); |
|
| 80 | - $table->setPrimaryKey(['auto_id']); |
|
| 81 | - $table->addIndex(['id'], 'id_index'); |
|
| 82 | - $table->addIndex(['timestamp'], 'timestamp_index'); |
|
| 83 | - $table->addIndex(['user'], 'user_index'); |
|
| 84 | - } |
|
| 85 | - return $schema; |
|
| 86 | - } |
|
| 46 | + if (!$schema->hasTable('files_trash')) { |
|
| 47 | + $table = $schema->createTable('files_trash'); |
|
| 48 | + $table->addColumn('auto_id', Types::BIGINT, [ |
|
| 49 | + 'autoincrement' => true, |
|
| 50 | + 'notnull' => true, |
|
| 51 | + ]); |
|
| 52 | + $table->addColumn('id', Types::STRING, [ |
|
| 53 | + 'notnull' => true, |
|
| 54 | + 'length' => 250, |
|
| 55 | + 'default' => '', |
|
| 56 | + ]); |
|
| 57 | + $table->addColumn('user', Types::STRING, [ |
|
| 58 | + 'notnull' => true, |
|
| 59 | + 'length' => 64, |
|
| 60 | + 'default' => '', |
|
| 61 | + ]); |
|
| 62 | + $table->addColumn('timestamp', Types::STRING, [ |
|
| 63 | + 'notnull' => true, |
|
| 64 | + 'length' => 12, |
|
| 65 | + 'default' => '', |
|
| 66 | + ]); |
|
| 67 | + $table->addColumn('location', Types::STRING, [ |
|
| 68 | + 'notnull' => true, |
|
| 69 | + 'length' => 512, |
|
| 70 | + 'default' => '', |
|
| 71 | + ]); |
|
| 72 | + $table->addColumn('type', Types::STRING, [ |
|
| 73 | + 'notnull' => false, |
|
| 74 | + 'length' => 4, |
|
| 75 | + ]); |
|
| 76 | + $table->addColumn('mime', Types::STRING, [ |
|
| 77 | + 'notnull' => false, |
|
| 78 | + 'length' => 255, |
|
| 79 | + ]); |
|
| 80 | + $table->setPrimaryKey(['auto_id']); |
|
| 81 | + $table->addIndex(['id'], 'id_index'); |
|
| 82 | + $table->addIndex(['timestamp'], 'timestamp_index'); |
|
| 83 | + $table->addIndex(['user'], 'user_index'); |
|
| 84 | + } |
|
| 85 | + return $schema; |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -34,37 +34,37 @@ |
||
| 34 | 34 | use OCP\Migration\SimpleMigrationStep; |
| 35 | 35 | |
| 36 | 36 | class Version21000Date20201223143245 extends SimpleMigrationStep { |
| 37 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 38 | - /** @var ISchemaWrapper $schema */ |
|
| 39 | - $schema = $schemaClosure(); |
|
| 37 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 38 | + /** @var ISchemaWrapper $schema */ |
|
| 39 | + $schema = $schemaClosure(); |
|
| 40 | 40 | |
| 41 | - if ($schema->hasTable('share_external')) { |
|
| 42 | - $table = $schema->getTable('share_external'); |
|
| 43 | - $changed = false; |
|
| 44 | - if (!$table->hasColumn('parent')) { |
|
| 45 | - $table->addColumn('parent', Types::BIGINT, [ |
|
| 46 | - 'notnull' => false, |
|
| 47 | - 'default' => -1, |
|
| 48 | - ]); |
|
| 49 | - $changed = true; |
|
| 50 | - } |
|
| 51 | - if (!$table->hasColumn('share_type')) { |
|
| 52 | - $table->addColumn('share_type', Types::INTEGER, [ |
|
| 53 | - 'notnull' => false, |
|
| 54 | - 'length' => 4, |
|
| 55 | - ]); |
|
| 56 | - $changed = true; |
|
| 57 | - } |
|
| 58 | - if ($table->hasColumn('lastscan')) { |
|
| 59 | - $table->dropColumn('lastscan'); |
|
| 60 | - $changed = true; |
|
| 61 | - } |
|
| 41 | + if ($schema->hasTable('share_external')) { |
|
| 42 | + $table = $schema->getTable('share_external'); |
|
| 43 | + $changed = false; |
|
| 44 | + if (!$table->hasColumn('parent')) { |
|
| 45 | + $table->addColumn('parent', Types::BIGINT, [ |
|
| 46 | + 'notnull' => false, |
|
| 47 | + 'default' => -1, |
|
| 48 | + ]); |
|
| 49 | + $changed = true; |
|
| 50 | + } |
|
| 51 | + if (!$table->hasColumn('share_type')) { |
|
| 52 | + $table->addColumn('share_type', Types::INTEGER, [ |
|
| 53 | + 'notnull' => false, |
|
| 54 | + 'length' => 4, |
|
| 55 | + ]); |
|
| 56 | + $changed = true; |
|
| 57 | + } |
|
| 58 | + if ($table->hasColumn('lastscan')) { |
|
| 59 | + $table->dropColumn('lastscan'); |
|
| 60 | + $changed = true; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - if ($changed) { |
|
| 64 | - return $schema; |
|
| 65 | - } |
|
| 66 | - } |
|
| 63 | + if ($changed) { |
|
| 64 | + return $schema; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - return null; |
|
| 69 | - } |
|
| 68 | + return null; |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | $query->select($query->func()->max('cardid')) |
| 75 | 75 | ->from('cards_properties') |
| 76 | 76 | ->where($query->expr()->eq('name', $query->createNamedParameter('X-SOCIALPROFILE'))); |
| 77 | - $maxId = (int)$query->execute()->fetchOne(); |
|
| 77 | + $maxId = (int) $query->execute()->fetchOne(); |
|
| 78 | 78 | |
| 79 | 79 | if ($maxId === 0) { |
| 80 | 80 | return; |
@@ -13,52 +13,52 @@ |
||
| 13 | 13 | |
| 14 | 14 | class BuildSocialSearchIndex implements IRepairStep { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @param IDBConnection $db |
|
| 18 | - * @param IJobList $jobList |
|
| 19 | - * @param IConfig $config |
|
| 20 | - */ |
|
| 21 | - public function __construct( |
|
| 22 | - private IDBConnection $db, |
|
| 23 | - private IJobList $jobList, |
|
| 24 | - private IConfig $config, |
|
| 25 | - ) { |
|
| 26 | - } |
|
| 16 | + /** |
|
| 17 | + * @param IDBConnection $db |
|
| 18 | + * @param IJobList $jobList |
|
| 19 | + * @param IConfig $config |
|
| 20 | + */ |
|
| 21 | + public function __construct( |
|
| 22 | + private IDBConnection $db, |
|
| 23 | + private IJobList $jobList, |
|
| 24 | + private IConfig $config, |
|
| 25 | + ) { |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - public function getName() { |
|
| 32 | - return 'Register building of social profile search index as background job'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + public function getName() { |
|
| 32 | + return 'Register building of social profile search index as background job'; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param IOutput $output |
|
| 37 | - */ |
|
| 38 | - public function run(IOutput $output) { |
|
| 39 | - // only run once |
|
| 40 | - if ($this->config->getAppValue('dav', 'builtSocialSearchIndex') === 'yes') { |
|
| 41 | - $output->info('Repair step already executed'); |
|
| 42 | - return; |
|
| 43 | - } |
|
| 35 | + /** |
|
| 36 | + * @param IOutput $output |
|
| 37 | + */ |
|
| 38 | + public function run(IOutput $output) { |
|
| 39 | + // only run once |
|
| 40 | + if ($this->config->getAppValue('dav', 'builtSocialSearchIndex') === 'yes') { |
|
| 41 | + $output->info('Repair step already executed'); |
|
| 42 | + return; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $query = $this->db->getQueryBuilder(); |
|
| 46 | - $query->select($query->func()->max('cardid')) |
|
| 47 | - ->from('cards_properties') |
|
| 48 | - ->where($query->expr()->eq('name', $query->createNamedParameter('X-SOCIALPROFILE'))); |
|
| 49 | - $maxId = (int)$query->execute()->fetchOne(); |
|
| 45 | + $query = $this->db->getQueryBuilder(); |
|
| 46 | + $query->select($query->func()->max('cardid')) |
|
| 47 | + ->from('cards_properties') |
|
| 48 | + ->where($query->expr()->eq('name', $query->createNamedParameter('X-SOCIALPROFILE'))); |
|
| 49 | + $maxId = (int)$query->execute()->fetchOne(); |
|
| 50 | 50 | |
| 51 | - if ($maxId === 0) { |
|
| 52 | - return; |
|
| 53 | - } |
|
| 51 | + if ($maxId === 0) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $output->info('Add background job'); |
|
| 56 | - $this->jobList->add(BuildSocialSearchIndexBackgroundJob::class, [ |
|
| 57 | - 'offset' => 0, |
|
| 58 | - 'stopAt' => $maxId |
|
| 59 | - ]); |
|
| 55 | + $output->info('Add background job'); |
|
| 56 | + $this->jobList->add(BuildSocialSearchIndexBackgroundJob::class, [ |
|
| 57 | + 'offset' => 0, |
|
| 58 | + 'stopAt' => $maxId |
|
| 59 | + ]); |
|
| 60 | 60 | |
| 61 | - // no need to redo the repair during next upgrade |
|
| 62 | - $this->config->setAppValue('dav', 'builtSocialSearchIndex', 'yes'); |
|
| 63 | - } |
|
| 61 | + // no need to redo the repair during next upgrade |
|
| 62 | + $this->config->setAppValue('dav', 'builtSocialSearchIndex', 'yes'); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -31,42 +31,42 @@ |
||
| 31 | 31 | use Doctrine\DBAL\Events; |
| 32 | 32 | |
| 33 | 33 | class SQLiteSessionInit implements EventSubscriber { |
| 34 | - /** |
|
| 35 | - * @var bool |
|
| 36 | - */ |
|
| 37 | - private $caseSensitiveLike; |
|
| 34 | + /** |
|
| 35 | + * @var bool |
|
| 36 | + */ |
|
| 37 | + private $caseSensitiveLike; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 42 | - private $journalMode; |
|
| 39 | + /** |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | + private $journalMode; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Configure case sensitive like for each connection |
|
| 46 | - * |
|
| 47 | - * @param bool $caseSensitiveLike |
|
| 48 | - * @param string $journalMode |
|
| 49 | - */ |
|
| 50 | - public function __construct($caseSensitiveLike, $journalMode) { |
|
| 51 | - $this->caseSensitiveLike = $caseSensitiveLike; |
|
| 52 | - $this->journalMode = $journalMode; |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * Configure case sensitive like for each connection |
|
| 46 | + * |
|
| 47 | + * @param bool $caseSensitiveLike |
|
| 48 | + * @param string $journalMode |
|
| 49 | + */ |
|
| 50 | + public function __construct($caseSensitiveLike, $journalMode) { |
|
| 51 | + $this->caseSensitiveLike = $caseSensitiveLike; |
|
| 52 | + $this->journalMode = $journalMode; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @param ConnectionEventArgs $args |
|
| 57 | - * @return void |
|
| 58 | - */ |
|
| 59 | - public function postConnect(ConnectionEventArgs $args) { |
|
| 60 | - $sensitive = $this->caseSensitiveLike ? 'true' : 'false'; |
|
| 61 | - $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
| 62 | - $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
| 63 | - /** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */ |
|
| 64 | - $connection = $args->getConnection()->getWrappedConnection(); |
|
| 65 | - $pdo = $connection->getWrappedConnection(); |
|
| 66 | - $pdo->sqliteCreateFunction('md5', 'md5', 1); |
|
| 67 | - } |
|
| 55 | + /** |
|
| 56 | + * @param ConnectionEventArgs $args |
|
| 57 | + * @return void |
|
| 58 | + */ |
|
| 59 | + public function postConnect(ConnectionEventArgs $args) { |
|
| 60 | + $sensitive = $this->caseSensitiveLike ? 'true' : 'false'; |
|
| 61 | + $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
| 62 | + $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
| 63 | + /** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */ |
|
| 64 | + $connection = $args->getConnection()->getWrappedConnection(); |
|
| 65 | + $pdo = $connection->getWrappedConnection(); |
|
| 66 | + $pdo->sqliteCreateFunction('md5', 'md5', 1); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public function getSubscribedEvents() { |
|
| 70 | - return [Events::postConnect]; |
|
| 71 | - } |
|
| 69 | + public function getSubscribedEvents() { |
|
| 70 | + return [Events::postConnect]; |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -58,8 +58,8 @@ |
||
| 58 | 58 | */ |
| 59 | 59 | public function postConnect(ConnectionEventArgs $args) { |
| 60 | 60 | $sensitive = $this->caseSensitiveLike ? 'true' : 'false'; |
| 61 | - $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
| 62 | - $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
| 61 | + $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = '.$sensitive); |
|
| 62 | + $args->getConnection()->executeUpdate('PRAGMA journal_mode = '.$this->journalMode); |
|
| 63 | 63 | /** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */ |
| 64 | 64 | $connection = $args->getConnection()->getWrappedConnection(); |
| 65 | 65 | $pdo = $connection->getWrappedConnection(); |
@@ -35,21 +35,21 @@ |
||
| 35 | 35 | * Auto-generated migration step: Please modify to your needs! |
| 36 | 36 | */ |
| 37 | 37 | class Version21000Date20210119195004 extends SimpleMigrationStep { |
| 38 | - /** |
|
| 39 | - * @param IOutput $output |
|
| 40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | - * @param array $options |
|
| 42 | - * @return null|ISchemaWrapper |
|
| 43 | - */ |
|
| 44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | - /** @var ISchemaWrapper $schema */ |
|
| 46 | - $schema = $schemaClosure(); |
|
| 38 | + /** |
|
| 39 | + * @param IOutput $output |
|
| 40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | + * @param array $options |
|
| 42 | + * @return null|ISchemaWrapper |
|
| 43 | + */ |
|
| 44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | + /** @var ISchemaWrapper $schema */ |
|
| 46 | + $schema = $schemaClosure(); |
|
| 47 | 47 | |
| 48 | - $table = $schema->getTable('authtoken'); |
|
| 49 | - if ($table->hasIndex('authtoken_version_index')) { |
|
| 50 | - $table->dropIndex('authtoken_version_index'); |
|
| 51 | - } |
|
| 48 | + $table = $schema->getTable('authtoken'); |
|
| 49 | + if ($table->hasIndex('authtoken_version_index')) { |
|
| 50 | + $table->dropIndex('authtoken_version_index'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $schema; |
|
| 54 | - } |
|
| 53 | + return $schema; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -31,24 +31,24 @@ |
||
| 31 | 31 | use OCP\Migration\SimpleMigrationStep; |
| 32 | 32 | |
| 33 | 33 | class Version14000Date20180518120534 extends SimpleMigrationStep { |
| 34 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 35 | - /** @var ISchemaWrapper $schema */ |
|
| 36 | - $schema = $schemaClosure(); |
|
| 34 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 35 | + /** @var ISchemaWrapper $schema */ |
|
| 36 | + $schema = $schemaClosure(); |
|
| 37 | 37 | |
| 38 | - $table = $schema->getTable('authtoken'); |
|
| 39 | - $table->addColumn('private_key', 'text', [ |
|
| 40 | - 'notnull' => false, |
|
| 41 | - ]); |
|
| 42 | - $table->addColumn('public_key', 'text', [ |
|
| 43 | - 'notnull' => false, |
|
| 44 | - ]); |
|
| 45 | - $table->addColumn('version', 'smallint', [ |
|
| 46 | - 'notnull' => true, |
|
| 47 | - 'default' => 1, |
|
| 48 | - 'unsigned' => true, |
|
| 49 | - ]); |
|
| 50 | - $table->addIndex(['uid'], 'authtoken_uid_index'); |
|
| 38 | + $table = $schema->getTable('authtoken'); |
|
| 39 | + $table->addColumn('private_key', 'text', [ |
|
| 40 | + 'notnull' => false, |
|
| 41 | + ]); |
|
| 42 | + $table->addColumn('public_key', 'text', [ |
|
| 43 | + 'notnull' => false, |
|
| 44 | + ]); |
|
| 45 | + $table->addColumn('version', 'smallint', [ |
|
| 46 | + 'notnull' => true, |
|
| 47 | + 'default' => 1, |
|
| 48 | + 'unsigned' => true, |
|
| 49 | + ]); |
|
| 50 | + $table->addIndex(['uid'], 'authtoken_uid_index'); |
|
| 51 | 51 | |
| 52 | - return $schema; |
|
| 53 | - } |
|
| 52 | + return $schema; |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $qb = $this->dbc->getQueryBuilder(); |
| 75 | 75 | $qb->select(['id', 'principaluri']) |
| 76 | 76 | ->from('dav_shares') |
| 77 | - ->where($qb->expr()->like('principaluri', $qb->createNamedParameter(self::GROUP_PRINCIPAL_PREFIX . '%'))); |
|
| 77 | + ->where($qb->expr()->like('principaluri', $qb->createNamedParameter(self::GROUP_PRINCIPAL_PREFIX.'%'))); |
|
| 78 | 78 | |
| 79 | 79 | $updateQuery = $this->dbc->getQueryBuilder(); |
| 80 | 80 | $updateQuery->update('dav_shares') |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | // + AND there are no ambivalent groups |
| 101 | 101 | |
| 102 | 102 | try { |
| 103 | - $fixedPrincipal = self::GROUP_PRINCIPAL_PREFIX . $encodedGid; |
|
| 103 | + $fixedPrincipal = self::GROUP_PRINCIPAL_PREFIX.$encodedGid; |
|
| 104 | 104 | $logParameters = [ |
| 105 | 105 | 'app' => 'core', |
| 106 | 106 | 'id' => $share['id'], |
@@ -21,89 +21,89 @@ |
||
| 21 | 21 | use function urlencode; |
| 22 | 22 | |
| 23 | 23 | class RepairDavShares implements IRepairStep { |
| 24 | - protected const GROUP_PRINCIPAL_PREFIX = 'principals/groups/'; |
|
| 24 | + protected const GROUP_PRINCIPAL_PREFIX = 'principals/groups/'; |
|
| 25 | 25 | |
| 26 | - /** @var bool */ |
|
| 27 | - private $hintInvalidShares = false; |
|
| 26 | + /** @var bool */ |
|
| 27 | + private $hintInvalidShares = false; |
|
| 28 | 28 | |
| 29 | - public function __construct( |
|
| 30 | - private IConfig $config, |
|
| 31 | - private IDBConnection $dbc, |
|
| 32 | - private IGroupManager $groupManager, |
|
| 33 | - private LoggerInterface $logger, |
|
| 34 | - ) { |
|
| 35 | - } |
|
| 29 | + public function __construct( |
|
| 30 | + private IConfig $config, |
|
| 31 | + private IDBConnection $dbc, |
|
| 32 | + private IGroupManager $groupManager, |
|
| 33 | + private LoggerInterface $logger, |
|
| 34 | + ) { |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @inheritDoc |
|
| 39 | - */ |
|
| 40 | - public function getName() { |
|
| 41 | - return 'Repair DAV shares'; |
|
| 42 | - } |
|
| 37 | + /** |
|
| 38 | + * @inheritDoc |
|
| 39 | + */ |
|
| 40 | + public function getName() { |
|
| 41 | + return 'Repair DAV shares'; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - protected function repairUnencodedGroupShares() { |
|
| 45 | - $qb = $this->dbc->getQueryBuilder(); |
|
| 46 | - $qb->select(['id', 'principaluri']) |
|
| 47 | - ->from('dav_shares') |
|
| 48 | - ->where($qb->expr()->like('principaluri', $qb->createNamedParameter(self::GROUP_PRINCIPAL_PREFIX . '%'))); |
|
| 44 | + protected function repairUnencodedGroupShares() { |
|
| 45 | + $qb = $this->dbc->getQueryBuilder(); |
|
| 46 | + $qb->select(['id', 'principaluri']) |
|
| 47 | + ->from('dav_shares') |
|
| 48 | + ->where($qb->expr()->like('principaluri', $qb->createNamedParameter(self::GROUP_PRINCIPAL_PREFIX . '%'))); |
|
| 49 | 49 | |
| 50 | - $updateQuery = $this->dbc->getQueryBuilder(); |
|
| 51 | - $updateQuery->update('dav_shares') |
|
| 52 | - ->set('principaluri', $updateQuery->createParameter('updatedPrincipalUri')) |
|
| 53 | - ->where($updateQuery->expr()->eq('id', $updateQuery->createParameter('shareId'))); |
|
| 50 | + $updateQuery = $this->dbc->getQueryBuilder(); |
|
| 51 | + $updateQuery->update('dav_shares') |
|
| 52 | + ->set('principaluri', $updateQuery->createParameter('updatedPrincipalUri')) |
|
| 53 | + ->where($updateQuery->expr()->eq('id', $updateQuery->createParameter('shareId'))); |
|
| 54 | 54 | |
| 55 | - $statement = $qb->executeQuery(); |
|
| 56 | - while ($share = $statement->fetch()) { |
|
| 57 | - $gid = substr($share['principaluri'], strlen(self::GROUP_PRINCIPAL_PREFIX)); |
|
| 58 | - $decodedGid = urldecode($gid); |
|
| 59 | - $encodedGid = urlencode($gid); |
|
| 60 | - if ($gid === $encodedGid |
|
| 61 | - || !$this->groupManager->groupExists($gid) |
|
| 62 | - || ($gid !== $decodedGid && $this->groupManager->groupExists($decodedGid)) |
|
| 63 | - ) { |
|
| 64 | - $this->hintInvalidShares = $this->hintInvalidShares || $gid !== $encodedGid; |
|
| 65 | - continue; |
|
| 66 | - } |
|
| 55 | + $statement = $qb->executeQuery(); |
|
| 56 | + while ($share = $statement->fetch()) { |
|
| 57 | + $gid = substr($share['principaluri'], strlen(self::GROUP_PRINCIPAL_PREFIX)); |
|
| 58 | + $decodedGid = urldecode($gid); |
|
| 59 | + $encodedGid = urlencode($gid); |
|
| 60 | + if ($gid === $encodedGid |
|
| 61 | + || !$this->groupManager->groupExists($gid) |
|
| 62 | + || ($gid !== $decodedGid && $this->groupManager->groupExists($decodedGid)) |
|
| 63 | + ) { |
|
| 64 | + $this->hintInvalidShares = $this->hintInvalidShares || $gid !== $encodedGid; |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - // Repair when |
|
| 69 | - // + the group name needs encoding |
|
| 70 | - // + AND it is not encoded yet |
|
| 71 | - // + AND there are no ambivalent groups |
|
| 68 | + // Repair when |
|
| 69 | + // + the group name needs encoding |
|
| 70 | + // + AND it is not encoded yet |
|
| 71 | + // + AND there are no ambivalent groups |
|
| 72 | 72 | |
| 73 | - try { |
|
| 74 | - $fixedPrincipal = self::GROUP_PRINCIPAL_PREFIX . $encodedGid; |
|
| 75 | - $logParameters = [ |
|
| 76 | - 'app' => 'core', |
|
| 77 | - 'id' => $share['id'], |
|
| 78 | - 'old' => $share['principaluri'], |
|
| 79 | - 'new' => $fixedPrincipal, |
|
| 80 | - ]; |
|
| 81 | - $updateQuery |
|
| 82 | - ->setParameter('updatedPrincipalUri', $fixedPrincipal) |
|
| 83 | - ->setParameter('shareId', $share['id']) |
|
| 84 | - ->executeStatement(); |
|
| 85 | - $this->logger->info('Repaired principal for dav share {id} from {old} to {new}', $logParameters); |
|
| 86 | - } catch (Exception $e) { |
|
| 87 | - $logParameters['message'] = $e->getMessage(); |
|
| 88 | - $logParameters['exception'] = $e; |
|
| 89 | - $this->logger->info('Could not repair principal for dav share {id} from {old} to {new}: {message}', $logParameters); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - return true; |
|
| 93 | - } |
|
| 73 | + try { |
|
| 74 | + $fixedPrincipal = self::GROUP_PRINCIPAL_PREFIX . $encodedGid; |
|
| 75 | + $logParameters = [ |
|
| 76 | + 'app' => 'core', |
|
| 77 | + 'id' => $share['id'], |
|
| 78 | + 'old' => $share['principaluri'], |
|
| 79 | + 'new' => $fixedPrincipal, |
|
| 80 | + ]; |
|
| 81 | + $updateQuery |
|
| 82 | + ->setParameter('updatedPrincipalUri', $fixedPrincipal) |
|
| 83 | + ->setParameter('shareId', $share['id']) |
|
| 84 | + ->executeStatement(); |
|
| 85 | + $this->logger->info('Repaired principal for dav share {id} from {old} to {new}', $logParameters); |
|
| 86 | + } catch (Exception $e) { |
|
| 87 | + $logParameters['message'] = $e->getMessage(); |
|
| 88 | + $logParameters['exception'] = $e; |
|
| 89 | + $this->logger->info('Could not repair principal for dav share {id} from {old} to {new}: {message}', $logParameters); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + return true; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @inheritDoc |
|
| 97 | - */ |
|
| 98 | - public function run(IOutput $output) { |
|
| 99 | - $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); |
|
| 100 | - if (version_compare($versionFromBeforeUpdate, '20.0.8', '<') |
|
| 101 | - && $this->repairUnencodedGroupShares() |
|
| 102 | - ) { |
|
| 103 | - $output->info('Repaired DAV group shares'); |
|
| 104 | - if ($this->hintInvalidShares) { |
|
| 105 | - $output->info('Invalid shares might be left in the database, running "occ dav:remove-invalid-shares" can remove them.'); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 95 | + /** |
|
| 96 | + * @inheritDoc |
|
| 97 | + */ |
|
| 98 | + public function run(IOutput $output) { |
|
| 99 | + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); |
|
| 100 | + if (version_compare($versionFromBeforeUpdate, '20.0.8', '<') |
|
| 101 | + && $this->repairUnencodedGroupShares() |
|
| 102 | + ) { |
|
| 103 | + $output->info('Repaired DAV group shares'); |
|
| 104 | + if ($this->hintInvalidShares) { |
|
| 105 | + $output->info('Invalid shares might be left in the database, running "occ dav:remove-invalid-shares" can remove them.'); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | } |