aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/Migration
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/lib/Migration')
-rw-r--r--apps/user_ldap/lib/Migration/GroupMappingMigration.php31
-rw-r--r--apps/user_ldap/lib/Migration/RemoveRefreshTime.php35
-rw-r--r--apps/user_ldap/lib/Migration/SetDefaultProvider.php35
-rw-r--r--apps/user_ldap/lib/Migration/UUIDFix.php32
-rw-r--r--apps/user_ldap/lib/Migration/UUIDFixGroup.php26
-rw-r--r--apps/user_ldap/lib/Migration/UUIDFixInsert.php49
-rw-r--r--apps/user_ldap/lib/Migration/UUIDFixUser.php28
-rw-r--r--apps/user_ldap/lib/Migration/UnsetDefaultProvider.php29
-rw-r--r--apps/user_ldap/lib/Migration/Version1010Date20200630192842.php24
-rw-r--r--apps/user_ldap/lib/Migration/Version1120Date20210917155206.php38
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20211102154716.php32
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20220110154717.php21
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20220110154718.php21
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20220110154719.php21
-rw-r--r--apps/user_ldap/lib/Migration/Version1141Date20220323143801.php28
-rw-r--r--apps/user_ldap/lib/Migration/Version1190Date20230706134108.php108
-rw-r--r--apps/user_ldap/lib/Migration/Version1190Date20230706134109.php29
17 files changed, 217 insertions, 370 deletions
diff --git a/apps/user_ldap/lib/Migration/GroupMappingMigration.php b/apps/user_ldap/lib/Migration/GroupMappingMigration.php
index f89bebe57d6..7dfb8705770 100644
--- a/apps/user_ldap/lib/Migration/GroupMappingMigration.php
+++ b/apps/user_ldap/lib/Migration/GroupMappingMigration.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
- *
- * @author Côme Chilliet <come.chilliet@nextcloud.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -31,11 +14,9 @@ use OCP\Migration\SimpleMigrationStep;
abstract class GroupMappingMigration extends SimpleMigrationStep {
- /** @var IDBConnection */
- private $dbc;
-
- public function __construct(IDBConnection $dbc) {
- $this->dbc = $dbc;
+ public function __construct(
+ private IDBConnection $dbc,
+ ) {
}
protected function copyGroupMappingData(string $sourceTable, string $destinationTable): void {
@@ -60,7 +41,7 @@ abstract class GroupMappingMigration extends SimpleMigrationStep {
->setParameter('owncloud_name', $row['owncloud_name'])
->setParameter('directory_uuid', $row['directory_uuid'])
->setParameter('ldap_dn_hash', $row['ldap_dn_hash'])
- ;
+ ;
$insert->executeStatement();
}
diff --git a/apps/user_ldap/lib/Migration/RemoveRefreshTime.php b/apps/user_ldap/lib/Migration/RemoveRefreshTime.php
index 501076ed0e8..88ac56ccb84 100644
--- a/apps/user_ldap/lib/Migration/RemoveRefreshTime.php
+++ b/apps/user_ldap/lib/Migration/RemoveRefreshTime.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -39,14 +22,10 @@ use OCP\Migration\IRepairStep;
*/
class RemoveRefreshTime implements IRepairStep {
- /** @var IDBConnection */
- private $dbc;
- /** @var IConfig */
- private $config;
-
- public function __construct(IDBConnection $dbc, IConfig $config) {
- $this->dbc = $dbc;
- $this->config = $config;
+ public function __construct(
+ private IDBConnection $dbc,
+ private IConfig $config,
+ ) {
}
public function getName() {
@@ -60,6 +39,6 @@ class RemoveRefreshTime implements IRepairStep {
$qb->delete('preferences')
->where($qb->expr()->eq('appid', $qb->createNamedParameter('user_ldap')))
->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lastFeatureRefresh')))
- ->execute();
+ ->executeStatement();
}
}
diff --git a/apps/user_ldap/lib/Migration/SetDefaultProvider.php b/apps/user_ldap/lib/Migration/SetDefaultProvider.php
index 15dba57e5f3..0bb04438a1d 100644
--- a/apps/user_ldap/lib/Migration/SetDefaultProvider.php
+++ b/apps/user_ldap/lib/Migration/SetDefaultProvider.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -33,16 +16,10 @@ use OCP\Migration\IRepairStep;
class SetDefaultProvider implements IRepairStep {
- /** @var IConfig */
- private $config;
-
- /** @var Helper */
- private $helper;
-
- public function __construct(IConfig $config,
- Helper $helper) {
- $this->config = $config;
- $this->helper = $helper;
+ public function __construct(
+ private IConfig $config,
+ private Helper $helper,
+ ) {
}
public function getName(): string {
diff --git a/apps/user_ldap/lib/Migration/UUIDFix.php b/apps/user_ldap/lib/Migration/UUIDFix.php
index 74ab65d347c..e853f3bba66 100644
--- a/apps/user_ldap/lib/Migration/UUIDFix.php
+++ b/apps/user_ldap/lib/Migration/UUIDFix.php
@@ -1,39 +1,19 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
-use OC\BackgroundJob\QueuedJob;
use OCA\User_LDAP\Mapping\AbstractMapping;
use OCA\User_LDAP\Proxy;
use OCA\User_LDAP\User_Proxy;
+use OCP\BackgroundJob\QueuedJob;
abstract class UUIDFix extends QueuedJob {
- /** @var AbstractMapping */
- protected $mapper;
-
- /** @var Proxy */
- protected $proxy;
+ protected AbstractMapping $mapper;
+ protected Proxy $proxy;
public function run($argument) {
$isUser = $this->proxy instanceof User_Proxy;
diff --git a/apps/user_ldap/lib/Migration/UUIDFixGroup.php b/apps/user_ldap/lib/Migration/UUIDFixGroup.php
index a90dcb5a938..3924c91e7ba 100644
--- a/apps/user_ldap/lib/Migration/UUIDFixGroup.php
+++ b/apps/user_ldap/lib/Migration/UUIDFixGroup.php
@@ -1,32 +1,18 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
use OCA\User_LDAP\Group_Proxy;
use OCA\User_LDAP\Mapping\GroupMapping;
+use OCP\AppFramework\Utility\ITimeFactory;
class UUIDFixGroup extends UUIDFix {
- public function __construct(GroupMapping $mapper, Group_Proxy $proxy) {
+ public function __construct(ITimeFactory $time, GroupMapping $mapper, Group_Proxy $proxy) {
+ parent::__construct($time);
$this->mapper = $mapper;
$this->proxy = $proxy;
}
diff --git a/apps/user_ldap/lib/Migration/UUIDFixInsert.php b/apps/user_ldap/lib/Migration/UUIDFixInsert.php
index a8e9d2829d7..bb92314d93a 100644
--- a/apps/user_ldap/lib/Migration/UUIDFixInsert.php
+++ b/apps/user_ldap/lib/Migration/UUIDFixInsert.php
@@ -1,26 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -33,23 +15,12 @@ use OCP\Migration\IRepairStep;
class UUIDFixInsert implements IRepairStep {
- /** @var IConfig */
- protected $config;
-
- /** @var UserMapping */
- protected $userMapper;
-
- /** @var GroupMapping */
- protected $groupMapper;
-
- /** @var IJobList */
- protected $jobList;
-
- public function __construct(IConfig $config, UserMapping $userMapper, GroupMapping $groupMapper, IJobList $jobList) {
- $this->config = $config;
- $this->userMapper = $userMapper;
- $this->groupMapper = $groupMapper;
- $this->jobList = $jobList;
+ public function __construct(
+ protected IConfig $config,
+ protected UserMapping $userMapper,
+ protected GroupMapping $groupMapper,
+ protected IJobList $jobList,
+ ) {
}
/**
@@ -90,7 +61,7 @@ class UUIDFixInsert implements IRepairStep {
$this->jobList->add($jobClass, ['records' => $records]);
$offset += $batchSize;
} catch (\InvalidArgumentException $e) {
- if (strpos($e->getMessage(), 'Background job arguments can\'t exceed 4000') !== false) {
+ if (str_contains($e->getMessage(), 'Background job arguments can\'t exceed 4000')) {
$batchSize = (int)floor(count($records) * 0.8);
$retry = true;
}
diff --git a/apps/user_ldap/lib/Migration/UUIDFixUser.php b/apps/user_ldap/lib/Migration/UUIDFixUser.php
index 2cb7ac8bdfb..71c3f638095 100644
--- a/apps/user_ldap/lib/Migration/UUIDFixUser.php
+++ b/apps/user_ldap/lib/Migration/UUIDFixUser.php
@@ -1,32 +1,18 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
-use OCA\User_LDAP\User_Proxy;
use OCA\User_LDAP\Mapping\UserMapping;
+use OCA\User_LDAP\User_Proxy;
+use OCP\AppFramework\Utility\ITimeFactory;
class UUIDFixUser extends UUIDFix {
- public function __construct(UserMapping $mapper, User_Proxy $proxy) {
+ public function __construct(ITimeFactory $time, UserMapping $mapper, User_Proxy $proxy) {
+ parent::__construct($time);
$this->mapper = $mapper;
$this->proxy = $proxy;
}
diff --git a/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php b/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php
index a696b815856..025415cf712 100644
--- a/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php
+++ b/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -32,11 +15,9 @@ use OCP\Migration\IRepairStep;
class UnsetDefaultProvider implements IRepairStep {
- /** @var IConfig */
- private $config;
-
- public function __construct(IConfig $config) {
- $this->config = $config;
+ public function __construct(
+ private IConfig $config,
+ ) {
}
public function getName(): string {
diff --git a/apps/user_ldap/lib/Migration/Version1010Date20200630192842.php b/apps/user_ldap/lib/Migration/Version1010Date20200630192842.php
index 5c7dc7db95c..1464e50e359 100644
--- a/apps/user_ldap/lib/Migration/Version1010Date20200630192842.php
+++ b/apps/user_ldap/lib/Migration/Version1010Date20200630192842.php
@@ -3,32 +3,14 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
use Closure;
-use OCP\DB\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
diff --git a/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php b/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php
index b7a9b81d6a0..dc3823bf771 100644
--- a/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php
+++ b/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -31,7 +14,6 @@ use OC\Hooks\PublicEmitter;
use OCP\DB\Exception;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
-use OCP\DB\Types;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\Migration\IOutput;
@@ -40,17 +22,11 @@ use Psr\Log\LoggerInterface;
class Version1120Date20210917155206 extends SimpleMigrationStep {
- /** @var IDBConnection */
- private $dbc;
- /** @var IUserManager */
- private $userManager;
- /** @var LoggerInterface */
- private $logger;
-
- public function __construct(IDBConnection $dbc, IUserManager $userManager, LoggerInterface $logger) {
- $this->dbc = $dbc;
- $this->userManager = $userManager;
- $this->logger = $logger;
+ public function __construct(
+ private IDBConnection $dbc,
+ private IUserManager $userManager,
+ private LoggerInterface $logger,
+ ) {
}
public function getName() {
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
index 5c5ed44c899..2457acd840d 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
- *
- * @author Côme Chilliet <come.chilliet@nextcloud.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -39,16 +22,13 @@ use Psr\Log\LoggerInterface;
class Version1130Date20211102154716 extends SimpleMigrationStep {
- /** @var IDBConnection */
- private $dbc;
- /** @var LoggerInterface */
- private $logger;
/** @var string[] */
private $hashColumnAddedToTables = [];
- public function __construct(IDBConnection $dbc, LoggerInterface $logger) {
- $this->dbc = $dbc;
- $this->logger = $logger;
+ public function __construct(
+ private IDBConnection $dbc,
+ private LoggerInterface $logger,
+ ) {
}
public function getName() {
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20220110154717.php b/apps/user_ldap/lib/Migration/Version1130Date20220110154717.php
index 2ffda4198c1..80960373edf 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20220110154717.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20220110154717.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
- *
- * @author Côme Chilliet <come.chilliet@nextcloud.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php b/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php
index 74dd2d873bc..f67b791daad 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
- *
- * @author Côme Chilliet <come.chilliet@nextcloud.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20220110154719.php b/apps/user_ldap/lib/Migration/Version1130Date20220110154719.php
index 9e9ed38cb70..c34ee5357f5 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20220110154719.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20220110154719.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
- *
- * @author Côme Chilliet <come.chilliet@nextcloud.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
diff --git a/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php b/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php
index 10043371aae..ecedbf1de20 100644
--- a/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php
+++ b/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2022 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Migration;
@@ -35,10 +18,9 @@ use OCP\Migration\SimpleMigrationStep;
class Version1141Date20220323143801 extends SimpleMigrationStep {
- private IDBConnection $dbc;
-
- public function __construct(IDBConnection $dbc) {
- $this->dbc = $dbc;
+ public function __construct(
+ private IDBConnection $dbc,
+ ) {
}
/**
diff --git a/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php
new file mode 100644
index 00000000000..85b046ab7c9
--- /dev/null
+++ b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php
@@ -0,0 +1,108 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\User_LDAP\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version1190Date20230706134108 extends SimpleMigrationStep {
+ public function __construct(
+ private IDBConnection $dbc,
+ ) {
+ }
+
+ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ }
+
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if (!$schema->hasTable('ldap_group_membership')) {
+ $table = $schema->createTable('ldap_group_membership');
+ $table->addColumn('id', Types::BIGINT, [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ ]);
+ $table->addColumn('groupid', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 255,
+ 'default' => '',
+ ]);
+ $table->addColumn('userid', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ 'default' => '',
+ ]);
+ $table->setPrimaryKey(['id']);
+ $table->addUniqueIndex(['groupid', 'userid'], 'user_ldap_membership_unique');
+ return $schema;
+ } else {
+ return null;
+ }
+ }
+
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if (!$schema->hasTable('ldap_group_members')) {
+ // Old table does not exist
+ return;
+ }
+
+ $output->startProgress();
+ $this->copyGroupMembershipData();
+ $output->finishProgress();
+ }
+
+ protected function copyGroupMembershipData(): void {
+ $insert = $this->dbc->getQueryBuilder();
+ $insert->insert('ldap_group_membership')
+ ->values([
+ 'userid' => $insert->createParameter('userid'),
+ 'groupid' => $insert->createParameter('groupid'),
+ ]);
+
+ $query = $this->dbc->getQueryBuilder();
+ $query->select('*')
+ ->from('ldap_group_members');
+
+ $result = $query->executeQuery();
+ while ($row = $result->fetch()) {
+ $knownUsers = unserialize($row['owncloudusers']);
+ if (!is_array($knownUsers)) {
+ /* Unserialize failed or data was incorrect in database, ignore */
+ continue;
+ }
+ $knownUsers = array_unique($knownUsers);
+ foreach ($knownUsers as $knownUser) {
+ try {
+ $insert
+ ->setParameter('groupid', $row['owncloudname'])
+ ->setParameter('userid', $knownUser)
+ ;
+
+ $insert->executeStatement();
+ } catch (\OCP\DB\Exception $e) {
+ /*
+ * If it fails on unique constaint violation it may just be left over value from previous half-migration
+ * If it fails on something else, ignore as well, data will be filled by background job later anyway
+ */
+ }
+ }
+ }
+ $result->closeCursor();
+ }
+}
diff --git a/apps/user_ldap/lib/Migration/Version1190Date20230706134109.php b/apps/user_ldap/lib/Migration/Version1190Date20230706134109.php
new file mode 100644
index 00000000000..2d3c26f0d49
--- /dev/null
+++ b/apps/user_ldap/lib/Migration/Version1190Date20230706134109.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\User_LDAP\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version1190Date20230706134109 extends SimpleMigrationStep {
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if ($schema->hasTable('ldap_group_members')) {
+ $schema->dropTable('ldap_group_members');
+ return $schema;
+ }
+
+ return null;
+ }
+}