Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2022-02-14 16:48:39 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2022-02-15 15:23:26 +0300
commita5228a0c42d169b113bbcd5f820e089b3ca74d78 (patch)
treed70ed35dafd651c689a9b3f006e3dd4f6b3a2192
parent2208ed6f67040cbdd97f0be36d0d48c9c0a05caf (diff)
adjust backport to stable20
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r--apps/settings/composer/composer/autoload_classmap.php1
-rw-r--r--apps/settings/composer/composer/autoload_static.php1
-rw-r--r--apps/settings/lib/Controller/CheckSetupController.php4
-rw-r--r--apps/user_ldap/appinfo/register_command.php10
-rw-r--r--apps/user_ldap/composer/composer/autoload_classmap.php1
-rw-r--r--apps/user_ldap/composer/composer/autoload_static.php1
-rw-r--r--apps/user_ldap/lib/Mapping/AbstractMapping.php2
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20211102154716.php27
8 files changed, 33 insertions, 14 deletions
diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php
index 0b088ff3602..e88158ae2c8 100644
--- a/apps/settings/composer/composer/autoload_classmap.php
+++ b/apps/settings/composer/composer/autoload_classmap.php
@@ -56,6 +56,7 @@ return array(
'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir . '/../lib/Settings/Personal/Security/TwoFactor.php',
'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => $baseDir . '/../lib/Settings/Personal/Security/WebAuthn.php',
'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
+ 'OCA\\Settings\\SetupChecks\\LdapInvalidUuids' => $baseDir . '/../lib/SetupChecks/LdapInvalidUuids.php',
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php',
'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php',
diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php
index 457e700f6a5..9157773d2b3 100644
--- a/apps/settings/composer/composer/autoload_static.php
+++ b/apps/settings/composer/composer/autoload_static.php
@@ -71,6 +71,7 @@ class ComposerStaticInitSettings
'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php',
'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/WebAuthn.php',
'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
+ 'OCA\\Settings\\SetupChecks\\LdapInvalidUuids' => __DIR__ . '/..' . '/../lib/SetupChecks/LdapInvalidUuids.php',
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php',
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php
index 2c950ce15e0..4ce5ef6ae4a 100644
--- a/apps/settings/lib/Controller/CheckSetupController.php
+++ b/apps/settings/lib/Controller/CheckSetupController.php
@@ -54,6 +54,7 @@ use OC\DB\SchemaWrapper;
use OC\IntegrityCheck\Checker;
use OC\Lock\NoopLockingProvider;
use OC\MemoryInfo;
+use OCA\Settings\SetupChecks\LdapInvalidUuids;
use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
use OCA\Settings\SetupChecks\PhpDefaultCharset;
use OCA\Settings\SetupChecks\PhpOutputBuffering;
@@ -63,7 +64,6 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\RedirectResponse;
-use OCP\DB\Types;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDateTimeFormatter;
@@ -733,6 +733,8 @@ Raw output
$phpOutputBuffering = new PhpOutputBuffering();
$legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
$supportedDatabases = new SupportedDatabase($this->l10n, $this->connection);
+ $ldapInvalidUuids = new LdapInvalidUuids($this->appManager, $this->l10n, $this->serverContainer);
+
return new DataResponse(
[
'isGetenvServerWorking' => !empty(getenv('PATH')),
diff --git a/apps/user_ldap/appinfo/register_command.php b/apps/user_ldap/appinfo/register_command.php
index fc8f6eba5bc..44969bfa8f3 100644
--- a/apps/user_ldap/appinfo/register_command.php
+++ b/apps/user_ldap/appinfo/register_command.php
@@ -25,8 +25,11 @@
*
*/
+use OCA\User_LDAP\Command\UpdateUUID;
+use OCA\User_LDAP\Group_Proxy;
use OCA\User_LDAP\Helper;
use OCA\User_LDAP\LDAP;
+use OCA\User_LDAP\Mapping\GroupMapping;
use OCA\User_LDAP\User_Proxy;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\DeletedUsersIndex;
@@ -35,19 +38,23 @@ use OCP\IUserManager;
$dbConnection = \OC::$server->getDatabaseConnection();
$userMapping = new UserMapping($dbConnection);
+$groupMapping = \OC::$server->get(GroupMapping::class);
$helper = new Helper(\OC::$server->getConfig());
$ocConfig = \OC::$server->getConfig();
+$activeConfigurationPrefixes = $helper->getServerConfigurationPrefixes(true);
$uBackend = new User_Proxy(
- $helper->getServerConfigurationPrefixes(true),
+ $activeConfigurationPrefixes,
new LDAP(),
$ocConfig,
\OC::$server->getNotificationManager(),
\OC::$server->getUserSession(),
\OC::$server->query(UserPluginManager::class)
);
+$groupBackend = new Group_Proxy($activeConfigurationPrefixes, new LDAP(), \OC::$server->get(\OCA\User_LDAP\GroupPluginManager::class));
$deletedUsersIndex = new DeletedUsersIndex(
$ocConfig, $dbConnection, $userMapping
);
+$logger = \OC::$server->get(\Psr\Log\LoggerInterface::class);
$application->add(new OCA\User_LDAP\Command\ShowConfig($helper));
$application->add(new OCA\User_LDAP\Command\SetConfig());
@@ -66,3 +73,4 @@ $application->add(new OCA\User_LDAP\Command\ShowRemnants(
$application->add(new OCA\User_LDAP\Command\CheckUser(
$uBackend, $helper, $deletedUsersIndex, $userMapping)
);
+$application->add(new UpdateUUID($userMapping, $groupMapping, $uBackend, $groupBackend, $logger));
diff --git a/apps/user_ldap/composer/composer/autoload_classmap.php b/apps/user_ldap/composer/composer/autoload_classmap.php
index 734f17248f9..1637bbc4e3b 100644
--- a/apps/user_ldap/composer/composer/autoload_classmap.php
+++ b/apps/user_ldap/composer/composer/autoload_classmap.php
@@ -20,6 +20,7 @@ return array(
'OCA\\User_LDAP\\Command\\ShowRemnants' => $baseDir . '/../lib/Command/ShowRemnants.php',
'OCA\\User_LDAP\\Command\\TestConfig' => $baseDir . '/../lib/Command/TestConfig.php',
'OCA\\User_LDAP\\Command\\UpdateUUID' => $baseDir . '/../lib/Command/UpdateUUID.php',
+ 'OCA\\User_LDAP\\Command\\UuidUpdateReport' => $baseDir . '/../lib/Command/UpdateUUID.php',
'OCA\\User_LDAP\\Configuration' => $baseDir . '/../lib/Configuration.php',
'OCA\\User_LDAP\\Connection' => $baseDir . '/../lib/Connection.php',
'OCA\\User_LDAP\\ConnectionFactory' => $baseDir . '/../lib/ConnectionFactory.php',
diff --git a/apps/user_ldap/composer/composer/autoload_static.php b/apps/user_ldap/composer/composer/autoload_static.php
index fd4a836a176..aa0d1efd469 100644
--- a/apps/user_ldap/composer/composer/autoload_static.php
+++ b/apps/user_ldap/composer/composer/autoload_static.php
@@ -35,6 +35,7 @@ class ComposerStaticInitUser_LDAP
'OCA\\User_LDAP\\Command\\ShowRemnants' => __DIR__ . '/..' . '/../lib/Command/ShowRemnants.php',
'OCA\\User_LDAP\\Command\\TestConfig' => __DIR__ . '/..' . '/../lib/Command/TestConfig.php',
'OCA\\User_LDAP\\Command\\UpdateUUID' => __DIR__ . '/..' . '/../lib/Command/UpdateUUID.php',
+ 'OCA\\User_LDAP\\Command\\UuidUpdateReport' => __DIR__ . '/..' . '/../lib/Command/UpdateUUID.php',
'OCA\\User_LDAP\\Configuration' => __DIR__ . '/..' . '/../lib/Configuration.php',
'OCA\\User_LDAP\\Connection' => __DIR__ . '/..' . '/../lib/Connection.php',
'OCA\\User_LDAP\\ConnectionFactory' => __DIR__ . '/..' . '/../lib/ConnectionFactory.php',
diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php
index 761a0a607a5..05da7a8f2ff 100644
--- a/apps/user_ldap/lib/Mapping/AbstractMapping.php
+++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php
@@ -450,7 +450,7 @@ abstract class AbstractMapping {
->from($this->getTableName())
->where($query->expr()->like('directory_uuid', $query->createNamedParameter('invalidated_%')));
$res = $query->execute();
- $count = $res->fetchOne();
+ $count = $res->fetchColumn();
$res->closeCursor();
return (int)$count;
}
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
index 0a41345e0d4..7566098832e 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
@@ -27,8 +27,11 @@ declare(strict_types=1);
namespace OCA\User_LDAP\Migration;
use Closure;
+use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Driver\Statement;
+use Doctrine\DBAL\Exception\ConstraintViolationException;
use Doctrine\DBAL\Types\Types;
-use OCP\DB\Exception;
+use Generator;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@@ -65,7 +68,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
// should be empty.
// TRUNCATE is not available from Query Builder, but faster than DELETE FROM.
$sql = $this->dbc->getDatabasePlatform()->getTruncateTableSQL('ldap_group_mapping_backup', false);
- $this->dbc->executeStatement($sql);
+ $this->dbc->executeUpdate($sql);
}
}
@@ -159,7 +162,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
$update->setParameter('dn_hash', $dnHash);
try {
$update->execute();
- } catch (Exception $e) {
+ } catch (DBALException $e) {
$this->logger->error('Failed to add hash "{dnHash}" ("{name}" of {table})',
[
'app' => 'user_ldap',
@@ -191,7 +194,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
}
/**
- * @throws Exception
+ * @throws DBALException
*/
protected function processDuplicateUUIDs(string $table): void {
$uuids = $this->getDuplicatedUuids($table);
@@ -203,7 +206,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
}
/**
- * @throws Exception
+ * @throws DBALException
*/
protected function invalidateUuids(string $table, array $idList): void {
$update = $this->dbc->getQueryBuilder();
@@ -223,12 +226,12 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
'nid' => $nextcloudId,
]
);
- } catch (Exception $e) {
+ } catch (DBALException $e) {
// Catch possible, but unlikely duplications if new invalidated errors.
// There is the theoretical chance of an infinity loop is, when
// the constraint violation has a different background. I cannot
// think of one at the moment.
- if ($e->getReason() !== Exception::REASON_CONSTRAINT_VIOLATION) {
+ if (!$e instanceof ConstraintViolationException) {
throw $e;
}
$idList[] = $nextcloudId;
@@ -237,7 +240,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
}
/**
- * @throws \OCP\DB\Exception
+ * @throws DBALException
* @return array<string>
*/
protected function getNextcloudIdsByUuid(string $table, string $uuid): array {
@@ -246,9 +249,10 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
->from($table)
->where($select->expr()->eq('directory_uuid', $select->createNamedParameter($uuid)));
+ /** @var Statement $result */
$result = $select->execute();
$idList = [];
- while ($id = $result->fetchOne()) {
+ while ($id = $result->fetchColumn()) {
$idList[] = $id;
}
$result->closeCursor();
@@ -257,7 +261,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
/**
* @return Generator<string>
- * @throws \OCP\DB\Exception
+ * @throws DBALException
*/
protected function getDuplicatedUuids(string $table): Generator {
$select = $this->dbc->getQueryBuilder();
@@ -266,8 +270,9 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
->groupBy('directory_uuid')
->having($select->expr()->gt($select->func()->count('owncloud_name'), $select->createNamedParameter(1)));
+ /** @var Statement $result */
$result = $select->execute();
- while ($uuid = $result->fetchOne()) {
+ while ($uuid = $result->fetchColumn()) {
yield $uuid;
}
$result->closeCursor();