mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 10:10:49 -04:00
adjust backport to stable20
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
2208ed6f67
commit
a5228a0c42
8 changed files with 33 additions and 14 deletions
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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')),
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue