summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlexander Piskun <13381981+bigcat88@users.noreply.github.com>2023-10-09 11:24:04 +0300
committerGitHub <noreply@github.com>2023-10-09 11:24:04 +0300
commit6ef3875e745e0ea6211e32ee0f84736474d30dbb (patch)
treeb47afede678c14fe159cf66c4a00a58b800af57c /lib
parent0b8a3b578d9be62da1d002f10e190855bb21998e (diff)
parentcad745b0d6145e90fde04994cf4c0256089d9331 (diff)
downloadnextcloud-server-6ef3875e745e0ea6211e32ee0f84736474d30dbb.tar.gz
nextcloud-server-6ef3875e745e0ea6211e32ee0f84736474d30dbb.zip
Merge branch 'master' into cors-app_api
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php3
-rw-r--r--lib/composer/composer/autoload_static.php3
-rw-r--r--lib/l10n/ja.js1
-rw-r--r--lib/l10n/ja.json1
-rw-r--r--lib/l10n/sk.js1
-rw-r--r--lib/l10n/sk.json1
-rw-r--r--lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php37
-rw-r--r--lib/private/BackgroundJob/JobList.php21
-rw-r--r--lib/private/Collaboration/Reference/File/FileReferenceEventListener.php7
-rw-r--r--lib/private/Collaboration/Reference/File/FileReferenceProvider.php20
-rw-r--r--lib/private/Collaboration/Reference/LinkReferenceProvider.php30
-rw-r--r--lib/private/Collaboration/Reference/ReferenceManager.php49
-rw-r--r--lib/private/Collaboration/Reference/RenderReferenceEventListener.php10
-rw-r--r--lib/private/Collaboration/Resources/Collection.php47
-rw-r--r--lib/private/Collaboration/Resources/Manager.php51
-rw-r--r--lib/private/Collaboration/Resources/ProviderManager.php17
-rw-r--r--lib/private/Collaboration/Resources/Resource.php44
-rw-r--r--lib/private/DB/Connection.php5
-rw-r--r--lib/private/DB/Migrator.php22
-rw-r--r--lib/private/DB/MySQLMigrator.php50
-rw-r--r--lib/private/DB/OracleMigrator.php239
-rw-r--r--lib/private/DB/PostgreSqlMigrator.php55
-rw-r--r--lib/private/DB/SQLiteMigrator.php11
-rw-r--r--lib/private/Repair.php4
-rw-r--r--lib/private/Repair/SqliteAutoincrement.php100
-rw-r--r--lib/private/Setup.php2
-rw-r--r--lib/private/TemplateLayout.php4
-rw-r--r--lib/private/User/Session.php2
-rw-r--r--lib/public/BackgroundJob/IJobList.php13
-rw-r--r--lib/public/DB/QueryBuilder/IQueryBuilder.php5
30 files changed, 220 insertions, 635 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 6e5bf85efcf..108a2f74b50 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -1194,14 +1194,12 @@ return array(
'OC\\DB\\MissingColumnInformation' => $baseDir . '/lib/private/DB/MissingColumnInformation.php',
'OC\\DB\\MissingIndexInformation' => $baseDir . '/lib/private/DB/MissingIndexInformation.php',
'OC\\DB\\MissingPrimaryKeyInformation' => $baseDir . '/lib/private/DB/MissingPrimaryKeyInformation.php',
- 'OC\\DB\\MySQLMigrator' => $baseDir . '/lib/private/DB/MySQLMigrator.php',
'OC\\DB\\MySqlTools' => $baseDir . '/lib/private/DB/MySqlTools.php',
'OC\\DB\\OCSqlitePlatform' => $baseDir . '/lib/private/DB/OCSqlitePlatform.php',
'OC\\DB\\ObjectParameter' => $baseDir . '/lib/private/DB/ObjectParameter.php',
'OC\\DB\\OracleConnection' => $baseDir . '/lib/private/DB/OracleConnection.php',
'OC\\DB\\OracleMigrator' => $baseDir . '/lib/private/DB/OracleMigrator.php',
'OC\\DB\\PgSqlTools' => $baseDir . '/lib/private/DB/PgSqlTools.php',
- 'OC\\DB\\PostgreSqlMigrator' => $baseDir . '/lib/private/DB/PostgreSqlMigrator.php',
'OC\\DB\\PreparedStatement' => $baseDir . '/lib/private/DB/PreparedStatement.php',
'OC\\DB\\QueryBuilder\\CompositeExpression' => $baseDir . '/lib/private/DB/QueryBuilder/CompositeExpression.php',
'OC\\DB\\QueryBuilder\\ExpressionBuilder\\ExpressionBuilder' => $baseDir . '/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php',
@@ -1594,7 +1592,6 @@ return array(
'OC\\Repair\\RepairDavShares' => $baseDir . '/lib/private/Repair/RepairDavShares.php',
'OC\\Repair\\RepairInvalidShares' => $baseDir . '/lib/private/Repair/RepairInvalidShares.php',
'OC\\Repair\\RepairMimeTypes' => $baseDir . '/lib/private/Repair/RepairMimeTypes.php',
- 'OC\\Repair\\SqliteAutoincrement' => $baseDir . '/lib/private/Repair/SqliteAutoincrement.php',
'OC\\RichObjectStrings\\Validator' => $baseDir . '/lib/private/RichObjectStrings/Validator.php',
'OC\\Route\\CachingRouter' => $baseDir . '/lib/private/Route/CachingRouter.php',
'OC\\Route\\Route' => $baseDir . '/lib/private/Route/Route.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index ef88bcd2a9b..ae1f13fc89b 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -1227,14 +1227,12 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\DB\\MissingColumnInformation' => __DIR__ . '/../../..' . '/lib/private/DB/MissingColumnInformation.php',
'OC\\DB\\MissingIndexInformation' => __DIR__ . '/../../..' . '/lib/private/DB/MissingIndexInformation.php',
'OC\\DB\\MissingPrimaryKeyInformation' => __DIR__ . '/../../..' . '/lib/private/DB/MissingPrimaryKeyInformation.php',
- 'OC\\DB\\MySQLMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/MySQLMigrator.php',
'OC\\DB\\MySqlTools' => __DIR__ . '/../../..' . '/lib/private/DB/MySqlTools.php',
'OC\\DB\\OCSqlitePlatform' => __DIR__ . '/../../..' . '/lib/private/DB/OCSqlitePlatform.php',
'OC\\DB\\ObjectParameter' => __DIR__ . '/../../..' . '/lib/private/DB/ObjectParameter.php',
'OC\\DB\\OracleConnection' => __DIR__ . '/../../..' . '/lib/private/DB/OracleConnection.php',
'OC\\DB\\OracleMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/OracleMigrator.php',
'OC\\DB\\PgSqlTools' => __DIR__ . '/../../..' . '/lib/private/DB/PgSqlTools.php',
- 'OC\\DB\\PostgreSqlMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/PostgreSqlMigrator.php',
'OC\\DB\\PreparedStatement' => __DIR__ . '/../../..' . '/lib/private/DB/PreparedStatement.php',
'OC\\DB\\QueryBuilder\\CompositeExpression' => __DIR__ . '/../../..' . '/lib/private/DB/QueryBuilder/CompositeExpression.php',
'OC\\DB\\QueryBuilder\\ExpressionBuilder\\ExpressionBuilder' => __DIR__ . '/../../..' . '/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php',
@@ -1627,7 +1625,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Repair\\RepairDavShares' => __DIR__ . '/../../..' . '/lib/private/Repair/RepairDavShares.php',
'OC\\Repair\\RepairInvalidShares' => __DIR__ . '/../../..' . '/lib/private/Repair/RepairInvalidShares.php',
'OC\\Repair\\RepairMimeTypes' => __DIR__ . '/../../..' . '/lib/private/Repair/RepairMimeTypes.php',
- 'OC\\Repair\\SqliteAutoincrement' => __DIR__ . '/../../..' . '/lib/private/Repair/SqliteAutoincrement.php',
'OC\\RichObjectStrings\\Validator' => __DIR__ . '/../../..' . '/lib/private/RichObjectStrings/Validator.php',
'OC\\Route\\CachingRouter' => __DIR__ . '/../../..' . '/lib/private/Route/CachingRouter.php',
'OC\\Route\\Route' => __DIR__ . '/../../..' . '/lib/private/Route/Route.php',
diff --git a/lib/l10n/ja.js b/lib/l10n/ja.js
index a58519f02ca..8dee8ebbc49 100644
--- a/lib/l10n/ja.js
+++ b/lib/l10n/ja.js
@@ -156,6 +156,7 @@ OC.L10N.register(
"%1$s shared »%2$s« with you." : "%1$sが あなたと »%2$s« を共有しました。",
"Click the button below to open it." : "開くには下のボタンをクリック",
"The requested share does not exist anymore" : "この共有はもう存在しません。",
+ "The requested share comes from a disabled user" : "要求された共有は無効化されたユーザーからのものです。",
"The user was not created because the user limit has been reached. Check your notifications to learn more." : "登録可能なユーザー数の上限に達したため、ユーザーは作成されませんでした。詳細については通知をご確認ください。",
"Could not find category \"%s\"" : "カテゴリ \"%s\" が見つかりませんでした",
"Sunday" : "日曜日",
diff --git a/lib/l10n/ja.json b/lib/l10n/ja.json
index f45d9b5e93f..7d8beb60f63 100644
--- a/lib/l10n/ja.json
+++ b/lib/l10n/ja.json
@@ -154,6 +154,7 @@
"%1$s shared »%2$s« with you." : "%1$sが あなたと »%2$s« を共有しました。",
"Click the button below to open it." : "開くには下のボタンをクリック",
"The requested share does not exist anymore" : "この共有はもう存在しません。",
+ "The requested share comes from a disabled user" : "要求された共有は無効化されたユーザーからのものです。",
"The user was not created because the user limit has been reached. Check your notifications to learn more." : "登録可能なユーザー数の上限に達したため、ユーザーは作成されませんでした。詳細については通知をご確認ください。",
"Could not find category \"%s\"" : "カテゴリ \"%s\" が見つかりませんでした",
"Sunday" : "日曜日",
diff --git a/lib/l10n/sk.js b/lib/l10n/sk.js
index 4c2843a76aa..2d165447848 100644
--- a/lib/l10n/sk.js
+++ b/lib/l10n/sk.js
@@ -112,6 +112,7 @@ OC.L10N.register(
"Address" : "Adresa",
"Profile picture" : "Profilový obrázok",
"About" : "O aplikácii",
+ "Display name" : "Zobrazované meno",
"Headline" : "Titulok",
"Organisation" : "Organizácia",
"Role" : "Rola",
diff --git a/lib/l10n/sk.json b/lib/l10n/sk.json
index 23c783f5e3e..1238e26e29e 100644
--- a/lib/l10n/sk.json
+++ b/lib/l10n/sk.json
@@ -110,6 +110,7 @@
"Address" : "Adresa",
"Profile picture" : "Profilový obrázok",
"About" : "O aplikácii",
+ "Display name" : "Zobrazované meno",
"Headline" : "Titulok",
"Organisation" : "Organizácia",
"Role" : "Rola",
diff --git a/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php
index 4817c6b8de0..97d6a02b4c4 100644
--- a/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php
+++ b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php
@@ -25,8 +25,6 @@ declare(strict_types=1);
*/
namespace OC\Authentication\TwoFactorAuth\Db;
-use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use function array_map;
@@ -70,25 +68,24 @@ class ProviderUserAssignmentDao {
* Persist a new/updated (provider_id, uid, enabled) tuple
*/
public function persist(string $providerId, string $uid, int $enabled): void {
- $qb = $this->conn->getQueryBuilder();
-
- try {
- // Insert a new entry
- $insertQuery = $qb->insert(self::TABLE_NAME)->values([
- 'provider_id' => $qb->createNamedParameter($providerId),
- 'uid' => $qb->createNamedParameter($uid),
- 'enabled' => $qb->createNamedParameter($enabled, IQueryBuilder::PARAM_INT),
- ]);
-
- $insertQuery->execute();
- } catch (UniqueConstraintViolationException $ex) {
- // There is already an entry -> update it
- $updateQuery = $qb->update(self::TABLE_NAME)
- ->set('enabled', $qb->createNamedParameter($enabled))
- ->where($qb->expr()->eq('provider_id', $qb->createNamedParameter($providerId)))
- ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
- $updateQuery->execute();
+ $conn = $this->conn;
+
+ // Insert a new entry
+ if ($conn->insertIgnoreConflict(self::TABLE_NAME, [
+ 'provider_id' => $providerId,
+ 'uid' => $uid,
+ 'enabled' => $enabled,
+ ])) {
+ return;
}
+
+ // There is already an entry -> update it
+ $qb = $conn->getQueryBuilder();
+ $updateQuery = $qb->update(self::TABLE_NAME)
+ ->set('enabled', $qb->createNamedParameter($enabled))
+ ->where($qb->expr()->eq('provider_id', $qb->createNamedParameter($providerId)))
+ ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
+ $updateQuery->executeStatement();
}
/**
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index 36cccbd4eab..2b42e2ff1ee 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -41,6 +41,10 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use Psr\Log\LoggerInterface;
+use function get_class;
+use function json_encode;
+use function md5;
+use function strlen;
class JobList implements IJobList {
protected IDBConnection $connection;
@@ -55,11 +59,10 @@ class JobList implements IJobList {
$this->logger = $logger;
}
- /**
- * @param IJob|class-string<IJob> $job
- * @param mixed $argument
- */
- public function add($job, $argument = null): void {
+ public function add($job, $argument = null, int $firstCheck = null): void {
+ if ($firstCheck === null) {
+ $firstCheck = $this->timeFactory->getTime();
+ }
if ($job instanceof IJob) {
$class = get_class($job);
} else {
@@ -79,18 +82,22 @@ class JobList implements IJobList {
'argument' => $query->createNamedParameter($argumentJson),
'argument_hash' => $query->createNamedParameter(md5($argumentJson)),
'last_run' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
- 'last_checked' => $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT),
+ 'last_checked' => $query->createNamedParameter($firstCheck, IQueryBuilder::PARAM_INT),
]);
} else {
$query->update('jobs')
->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT))
- ->set('last_checked', $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT))
+ ->set('last_checked', $query->createNamedParameter($firstCheck, IQueryBuilder::PARAM_INT))
->where($query->expr()->eq('class', $query->createNamedParameter($class)))
->andWhere($query->expr()->eq('argument_hash', $query->createNamedParameter(md5($argumentJson))));
}
$query->executeStatement();
}
+ public function scheduleAfter(string $job, int $runAfter, $argument = null): void {
+ $this->add($job, $argument, $runAfter);
+ }
+
/**
* @param IJob|string $job
* @param mixed $argument
diff --git a/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php b/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php
index 1dbe8e3bc35..4277b3837d2 100644
--- a/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php
+++ b/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php
@@ -36,10 +36,9 @@ use OCP\Share\Events\ShareDeletedEvent;
/** @template-implements IEventListener<Event|NodeDeletedEvent|ShareDeletedEvent|ShareCreatedEvent> */
class FileReferenceEventListener implements IEventListener {
- private IReferenceManager $manager;
-
- public function __construct(IReferenceManager $manager) {
- $this->manager = $manager;
+ public function __construct(
+ private IReferenceManager $manager,
+ ) {
}
public static function register(IEventDispatcher $eventDispatcher): void {
diff --git a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php
index d423a830495..5f384213976 100644
--- a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php
+++ b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php
@@ -41,26 +41,18 @@ use OCP\IUserSession;
use OCP\L10N\IFactory;
class FileReferenceProvider extends ADiscoverableReferenceProvider {
- private IURLGenerator $urlGenerator;
- private IRootFolder $rootFolder;
private ?string $userId;
- private IPreview $previewManager;
- private IMimeTypeDetector $mimeTypeDetector;
private IL10N $l10n;
public function __construct(
- IURLGenerator $urlGenerator,
- IRootFolder $rootFolder,
+ private IURLGenerator $urlGenerator,
+ private IRootFolder $rootFolder,
IUserSession $userSession,
- IMimeTypeDetector $mimeTypeDetector,
- IPreview $previewManager,
- IFactory $l10n
+ private IMimeTypeDetector $mimeTypeDetector,
+ private IPreview $previewManager,
+ IFactory $l10n,
) {
- $this->urlGenerator = $urlGenerator;
- $this->rootFolder = $rootFolder;
- $this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
- $this->previewManager = $previewManager;
- $this->mimeTypeDetector = $mimeTypeDetector;
+ $this->userId = $userSession->getUser()?->getUID();
$this->l10n = $l10n->get('files');
}
diff --git a/lib/private/Collaboration/Reference/LinkReferenceProvider.php b/lib/private/Collaboration/Reference/LinkReferenceProvider.php
index dbdab75abcb..df6c6cc9da9 100644
--- a/lib/private/Collaboration/Reference/LinkReferenceProvider.php
+++ b/lib/private/Collaboration/Reference/LinkReferenceProvider.php
@@ -54,24 +54,16 @@ class LinkReferenceProvider implements IReferenceProvider {
'image/webp'
];
- private IClientService $clientService;
- private LoggerInterface $logger;
- private SystemConfig $systemConfig;
- private IAppDataFactory $appDataFactory;
- private IURLGenerator $urlGenerator;
- private Limiter $limiter;
- private IUserSession $userSession;
- private IRequest $request;
-
- public function __construct(IClientService $clientService, LoggerInterface $logger, SystemConfig $systemConfig, IAppDataFactory $appDataFactory, IURLGenerator $urlGenerator, Limiter $limiter, IUserSession $userSession, IRequest $request) {
- $this->clientService = $clientService;
- $this->logger = $logger;
- $this->systemConfig = $systemConfig;
- $this->appDataFactory = $appDataFactory;
- $this->urlGenerator = $urlGenerator;
- $this->limiter = $limiter;
- $this->userSession = $userSession;
- $this->request = $request;
+ public function __construct(
+ private IClientService $clientService,
+ private LoggerInterface $logger,
+ private SystemConfig $systemConfig,
+ private IAppDataFactory $appDataFactory,
+ private IURLGenerator $urlGenerator,
+ private Limiter $limiter,
+ private IUserSession $userSession,
+ private IRequest $request,
+ ) {
}
public function matchReference(string $referenceText): bool {
@@ -119,7 +111,7 @@ class LinkReferenceProvider implements IReferenceProvider {
$linkContentType = $headResponse->getHeader('Content-Type');
$expectedContentType = 'text/html';
$suffixedExpectedContentType = $expectedContentType . ';';
- $startsWithSuffixed = substr($linkContentType, 0, strlen($suffixedExpectedContentType)) === $suffixedExpectedContentType;
+ $startsWithSuffixed = str_starts_with($linkContentType, $suffixedExpectedContentType);
// check the header begins with the expected content type
if ($linkContentType !== $expectedContentType && !$startsWithSuffixed) {
$this->logger->debug('Skip resolving links pointing to content type that is not "text/html"');
diff --git a/lib/private/Collaboration/Reference/ReferenceManager.php b/lib/private/Collaboration/Reference/ReferenceManager.php
index 2897410f5d6..1db87a56494 100644
--- a/lib/private/Collaboration/Reference/ReferenceManager.php
+++ b/lib/private/Collaboration/Reference/ReferenceManager.php
@@ -46,33 +46,22 @@ class ReferenceManager implements IReferenceManager {
/** @var IReferenceProvider[]|null */
private ?array $providers = null;
private ICache $cache;
- private Coordinator $coordinator;
- private ContainerInterface $container;
- private LinkReferenceProvider $linkReferenceProvider;
- private LoggerInterface $logger;
- private IConfig $config;
- private IUserSession $userSession;
-
- public function __construct(LinkReferenceProvider $linkReferenceProvider,
- ICacheFactory $cacheFactory,
- Coordinator $coordinator,
- ContainerInterface $container,
- LoggerInterface $logger,
- IConfig $config,
- IUserSession $userSession) {
- $this->linkReferenceProvider = $linkReferenceProvider;
+
+ public function __construct(
+ private LinkReferenceProvider $linkReferenceProvider,
+ ICacheFactory $cacheFactory,
+ private Coordinator $coordinator,
+ private ContainerInterface $container,
+ private LoggerInterface $logger,
+ private IConfig $config,
+ private IUserSession $userSession,
+ ) {
$this->cache = $cacheFactory->createDistributed('reference');
- $this->coordinator = $coordinator;
- $this->container = $container;
- $this->logger = $logger;
- $this->config = $config;
- $this->userSession = $userSession;
}
/**
* Extract a list of URLs from a text
*
- * @param string $text
* @return string[]
*/
public function extractReferences(string $text): array {
@@ -85,9 +74,6 @@ class ReferenceManager implements IReferenceManager {
/**
* Try to get a cached reference object from a reference string
- *
- * @param string $referenceId
- * @return IReference|null
*/
public function getReferenceFromCache(string $referenceId): ?IReference {
$matchedProvider = $this->getMatchedProvider($referenceId);
@@ -102,9 +88,6 @@ class ReferenceManager implements IReferenceManager {
/**
* Try to get a cached reference object from a full cache key
- *
- * @param string $cacheKey
- * @return IReference|null
*/
public function getReferenceByCacheKey(string $cacheKey): ?IReference {
$cached = $this->cache->get($cacheKey);
@@ -118,9 +101,6 @@ class ReferenceManager implements IReferenceManager {
/**
* Get a reference object from a reference string with a matching provider
* Use a cached reference if possible
- *
- * @param string $referenceId
- * @return IReference|null
*/
public function resolveReference(string $referenceId): ?IReference {
$matchedProvider = $this->getMatchedProvider($referenceId);
@@ -148,7 +128,6 @@ class ReferenceManager implements IReferenceManager {
* Try to match a reference string with all the registered providers
* Fallback to the link reference provider (using OpenGraph)
*
- * @param string $referenceId
* @return IReferenceProvider|null the first matching provider
*/
private function getMatchedProvider(string $referenceId): ?IReferenceProvider {
@@ -169,10 +148,6 @@ class ReferenceManager implements IReferenceManager {
/**
* Get a hashed full cache key from a key and prefix given by a provider
- *
- * @param IReferenceProvider $provider
- * @param string $referenceId
- * @return string
*/
private function getFullCacheKey(IReferenceProvider $provider, string $referenceId): string {
$cacheKey = $provider->getCacheKey($referenceId);
@@ -183,10 +158,6 @@ class ReferenceManager implements IReferenceManager {
/**
* Remove a specific cache entry from its key+prefix
- *
- * @param string $cachePrefix
- * @param string|null $cacheKey
- * @return void
*/
public function invalidateCache(string $cachePrefix, ?string $cacheKey = null): void {
if ($cacheKey === null) {
diff --git a/lib/private/Collaboration/Reference/RenderReferenceEventListener.php b/lib/private/Collaboration/Reference/RenderReferenceEventListener.php
index dc2c5612666..ab9b8fd1b63 100644
--- a/lib/private/Collaboration/Reference/RenderReferenceEventListener.php
+++ b/lib/private/Collaboration/Reference/RenderReferenceEventListener.php
@@ -34,12 +34,10 @@ use OCP\IInitialStateService;
/** @template-implements IEventListener<Event|RenderReferenceEvent> */
class RenderReferenceEventListener implements IEventListener {
- private IReferenceManager $manager;
- private IInitialStateService $initialStateService;
-
- public function __construct(IReferenceManager $manager, IInitialStateService $initialStateService) {
- $this->manager = $manager;
- $this->initialStateService = $initialStateService;
+ public function __construct(
+ private IReferenceManager $manager,
+ private IInitialStateService $initialStateService,
+ ) {
}
public static function register(IEventDispatcher $eventDispatcher): void {
diff --git a/lib/private/Collaboration/Resources/Collection.php b/lib/private/Collaboration/Resources/Collection.php
index e34c38a80cd..3a09fe60051 100644
--- a/lib/private/Collaboration/Resources/Collection.php
+++ b/lib/private/Collaboration/Resources/Collection.php
@@ -37,46 +37,21 @@ use OCP\IDBConnection;
use OCP\IUser;
class Collection implements ICollection {
- /** @var Manager */
- protected $manager;
-
- /** @var IDBConnection */
- protected $connection;
-
- /** @var int */
- protected $id;
-
- /** @var string */
- protected $name;
-
- /** @var IUser|null */
- protected $userForAccess;
-
- /** @var bool|null */
- protected $access;
-
/** @var IResource[] */
- protected $resources;
+ protected array $resources = [];
public function __construct(
- IManager $manager,
- IDBConnection $connection,
- int $id,
- string $name,
- ?IUser $userForAccess = null,
- ?bool $access = null
+ /** @var Manager $manager */
+ protected IManager $manager,
+ protected IDBConnection $connection,
+ protected int $id,
+ protected string $name,
+ protected ?IUser $userForAccess = null,
+ protected ?bool $access = null
) {
- $this->manager = $manager;
- $this->connection = $connection;
- $this->id = $id;
- $this->name = $name;
- $this->userForAccess = $userForAccess;
- $this->access = $access;
- $this->resources = [];
}
/**
- * @return int
* @since 16.0.0
*/
public function getId(): int {
@@ -84,7 +59,6 @@ class Collection implements ICollection {
}
/**
- * @return string
* @since 16.0.0
*/
public function getName(): string {
@@ -92,7 +66,6 @@ class Collection implements ICollection {
}
/**
- * @param string $name
* @since 16.0.0
*/
public function setName(string $name): void {
@@ -120,7 +93,6 @@ class Collection implements ICollection {
/**
* Adds a resource to a collection
*
- * @param IResource $resource
* @throws ResourceException when the resource is already part of the collection
* @since 16.0.0
*/
@@ -153,7 +125,6 @@ class Collection implements ICollection {
/**
* Removes a resource from a collection
*
- * @param IResource $resource
* @since 16.0.0
*/
public function removeResource(IResource $resource): void {
@@ -178,8 +149,6 @@ class Collection implements ICollection {
/**
* Can a user/guest access the collection
*
- * @param IUser|null $user
- * @return bool
* @since 16.0.0
*/
public function canAccess(?IUser $user): bool {
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php
index fc8804e69b4..0f4dbd7cbb7 100644
--- a/lib/private/Collaboration/Resources/Manager.php
+++ b/lib/private/Collaboration/Resources/Manager.php
@@ -45,26 +45,17 @@ class Manager implements IManager {
public const TABLE_RESOURCES = 'collres_resources';
public const TABLE_ACCESS_CACHE = 'collres_accesscache';
- /** @var IDBConnection */
- protected $connection;
- /** @var IProviderManager */
- protected $providerManager;
- /** @var LoggerInterface */
- protected $logger;
-
/** @var string[] */
- protected $providers = [];
-
+ protected array $providers = [];
- public function __construct(IDBConnection $connection, IProviderManager $providerManager, LoggerInterface $logger) {
- $this->connection = $connection;
- $this->providerManager = $providerManager;
- $this->logger = $logger;
+ public function __construct(
+ protected IDBConnection $connection,
+ protected IProviderManager $providerManager,
+ protected LoggerInterface $logger,
+ ) {
}
/**
- * @param int $id
- * @return ICollection
* @throws CollectionException when the collection could not be found
* @since 16.0.0
*/
@@ -85,9 +76,6 @@ class Manager implements IManager {
}
/**
- * @param int $id
- * @param IUser|null $user
- * @return ICollection
* @throws CollectionException when the collection could not be found
* @since 16.0.0
*/
@@ -122,10 +110,6 @@ class Manager implements IManager {
}
/**
- * @param IUser $user
- * @param string $filter
- * @param int $limit
- * @param int $start
* @return ICollection[]
* @since 16.0.0
*/
@@ -173,8 +157,6 @@ class Manager implements IManager {
}
/**
- * @param string $name
- * @return ICollection
* @since 16.0.0
*/
public function newCollection(string $name): ICollection {
@@ -189,9 +171,6 @@ class Manager implements IManager {
}
/**
- * @param string $type
- * @param string $id
- * @return IResource
* @since 16.0.0
*/
public function createResource(string $type, string $id): IResource {
@@ -199,10 +178,6 @@ class Manager implements IManager {
}
/**
- * @param string $type
- * @param string $id
- * @param IUser|null $user
- * @return IResource
* @throws ResourceException
* @since 16.0.0
*/
@@ -239,8 +214,6 @@ class Manager implements IManager {
}
/**
- * @param ICollection $collection
- * @param IUser|null $user
* @return IResource[]
* @since 16.0.0
*/
@@ -274,8 +247,6 @@ class Manager implements IManager {
/**
* Get the rich object data of a resource
*
- * @param IResource $resource
- * @return array
* @since 16.0.0
*/
public function getResourceRichObject(IResource $resource): array {
@@ -294,9 +265,6 @@ class Manager implements IManager {
/**
* Can a user/guest access the collection
*
- * @param IResource $resource
- * @param IUser|null $user
- * @return bool
* @since 16.0.0
*/
public function canAccessResource(IResource $resource, ?IUser $user): bool {
@@ -325,9 +293,6 @@ class Manager implements IManager {
/**
* Can a user/guest access the collection
*
- * @param ICollection $collection
- * @param IUser|null $user
- * @return bool
* @since 16.0.0
*/
public function canAccessCollection(ICollection $collection, ?IUser $user): bool {
@@ -505,9 +470,6 @@ class Manager implements IManager {
$query->execute();
}
- /**
- * @param string $provider
- */
public function registerResourceProvider(string $provider): void {
$this->logger->debug('\OC\Collaboration\Resources\Manager::registerResourceProvider is deprecated', ['provider' => $provider]);
$this->providerManager->registerResourceProvider($provider);
@@ -516,7 +478,6 @@ class Manager implements IManager {
/**
* Get the resource type of the provider
*
- * @return string
* @since 16.0.0
*/
public function getType(): string {
diff --git a/lib/private/Collaboration/Resources/ProviderManager.php b/lib/private/Collaboration/Resources/ProviderManager.php
index 4f5ed53b162..823d6764f58 100644
--- a/lib/private/Collaboration/Resources/ProviderManager.php
+++ b/lib/private/Collaboration/Resources/ProviderManager.php
@@ -34,20 +34,15 @@ use Psr\Log\LoggerInterface;
class ProviderManager implements IProviderManager {
/** @var string[] */
- protected $providers = [];
+ protected array $providers = [];
/** @var IProvider[] */
- protected $providerInstances = [];
+ protected array $providerInstances = [];
- /** @var IServerContainer */
- protected $serverContainer;
-
- /** @var LoggerInterface */
- protected $logger;
-
- public function __construct(IServerContainer $serverContainer, LoggerInterface $logger) {
- $this->serverContainer = $serverContainer;
- $this->logger = $logger;
+ public function __construct(
+ protected IServerContainer $serverContainer,
+ protected LoggerInterface $logger,
+ ) {
}
public function getResourceProviders(): array {
diff --git a/lib/private/Collaboration/Resources/Resource.php b/lib/private/Collaboration/Resources/Resource.php
index b5e0215cb39..059b1802128 100644
--- a/lib/private/Collaboration/Resources/Resource.php
+++ b/lib/private/Collaboration/Resources/Resource.php
@@ -33,45 +33,19 @@ use OCP\IDBConnection;
use OCP\IUser;
class Resource implements IResource {
- /** @var IManager */
- protected $manager;
-
- /** @var IDBConnection */
- protected $connection;
-
- /** @var string */
- protected $type;
-
- /** @var string */
- protected $id;
-
- /** @var IUser|null */
- protected $userForAccess;
-
- /** @var bool|null */
- protected $access;
-
- /** @var array|null */
- protected $data;
+ protected ?array $data = null;
public function __construct(
- IManager $manager,
- IDBConnection $connection,
- string $type,
- string $id,
- ?IUser $userForAccess = null,
- ?bool $access = null
+ protected IManager $manager,
+ protected IDBConnection $connection,
+ protected string $type,
+ protected string $id,
+ protected ?IUser $userForAccess = null,
+ protected ?bool $access = null
) {
- $this->manager = $manager;
- $this->connection = $connection;
- $this->type = $type;
- $this->id = $id;
- $this->userForAccess = $userForAccess;
- $this->access = $access;
}
/**
- * @return string
* @since 16.0.0
*/
public function getType(): string {
@@ -79,7 +53,6 @@ class Resource implements IResource {
}
/**
- * @return string
* @since 16.0.0
*/
public function getId(): string {
@@ -87,7 +60,6 @@ class Resource implements IResource {
}
/**
- * @return array
* @since 16.0.0
*/
public function getRichObject(): array {
@@ -101,8 +73,6 @@ class Resource implements IResource {
/**
* Can a user/guest access the resource
*
- * @param IUser|null $user
- * @return bool
* @since 16.0.0
*/
public function canAccess(?IUser $user): bool {
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index 2bd1d4c824a..df35e0b5e0d 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -42,7 +42,6 @@ use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Schema\Schema;
@@ -600,10 +599,6 @@ class Connection extends \Doctrine\DBAL\Connection {
return new SQLiteMigrator($this, $config, $dispatcher);
} elseif ($platform instanceof OraclePlatform) {
return new OracleMigrator($this, $config, $dispatcher);
- } elseif ($platform instanceof MySQLPlatform) {
- return new MySQLMigrator($this, $config, $dispatcher);
- } elseif ($platform instanceof PostgreSQL94Platform) {
- return new PostgreSqlMigrator($this, $config, $dispatcher);
} else {
return new Migrator($this, $config, $dispatcher);
}
diff --git a/lib/private/DB/Migrator.php b/lib/private/DB/Migrator.php
index 46be512440a..1d960e72dc5 100644
--- a/lib/private/DB/Migrator.php
+++ b/lib/private/DB/Migrator.php
@@ -31,7 +31,6 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Schema\AbstractAsset;
-use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaDiff;
use Doctrine\DBAL\Types\StringType;
@@ -75,7 +74,7 @@ class Migrator {
$schemaDiff = $this->getDiff($targetSchema, $this->connection);
$script = '';
- $sqls = $schemaDiff->toSql($this->connection->getDatabasePlatform());
+ $sqls = $this->connection->getDatabasePlatform()->getAlterSchemaSQL($schemaDiff);
foreach ($sqls as $sql) {
$script .= $this->convertStatementToScript($sql);
}
@@ -95,18 +94,20 @@ class Migrator {
}
return preg_match($filterExpression, $asset) === 1;
});
- return $this->connection->getSchemaManager()->createSchema();
+ return $this->connection->createSchemaManager()->introspectSchema();
}
/**
* @return SchemaDiff
*/
protected function getDiff(Schema $targetSchema, Connection $connection) {
- // adjust varchar columns with a length higher then getVarcharMaxLength to clob
+ // Adjust STRING columns with a length higher than 4000 to TEXT (clob)
+ // for consistency between the supported databases and
+ // old vs. new installations.
foreach ($targetSchema->getTables() as $table) {
foreach ($table->getColumns() as $column) {
if ($column->getType() instanceof StringType) {
- if ($column->getLength() > $connection->getDatabasePlatform()->getVarcharMaxLength()) {
+ if ($column->getLength() > 4000) {
$column->setType(Type::getType('text'));
$column->setLength(null);
}
@@ -122,7 +123,7 @@ class Migrator {
}
return preg_match($filterExpression, $asset) === 1;
});
- $sourceSchema = $connection->getSchemaManager()->createSchema();
+ $sourceSchema = $connection->createSchemaManager()->introspectSchema();
// remove tables we don't know about
foreach ($sourceSchema->getTables() as $table) {
@@ -137,9 +138,8 @@ class Migrator {
}
}
- /** @psalm-suppress InternalMethod */
- $comparator = new Comparator();
- return $comparator->compare($sourceSchema, $targetSchema);
+ $comparator = $connection->createSchemaManager()->createComparator();
+ return $comparator->compareSchemas($sourceSchema, $targetSchema);
}
/**
@@ -155,7 +155,7 @@ class Migrator {
if (!$connection->getDatabasePlatform() instanceof MySQLPlatform) {
$connection->beginTransaction();
}
- $sqls = $schemaDiff->toSql($connection->getDatabasePlatform());
+ $sqls = $connection->getDatabasePlatform()->getAlterSchemaSQL($schemaDiff);
$step = 0;
foreach ($sqls as $sql) {
$this->emit($sql, $step++, count($sqls));
@@ -178,7 +178,7 @@ class Migrator {
}
protected function getFilterExpression() {
- return '/^' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/';
+ return '/^' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_'), '/') . '/';
}
protected function emit(string $sql, int $step, int $max): void {
diff --git a/lib/private/DB/MySQLMigrator.php b/lib/private/DB/MySQLMigrator.php
deleted file mode 100644
index 0f8cbb309f3..00000000000
--- a/lib/private/DB/MySQLMigrator.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Robin Appelman <robin@icewind.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\DB;
-
-use Doctrine\DBAL\Schema\Schema;
-
-class MySQLMigrator extends Migrator {
- /**
- * @param Schema $targetSchema
- * @param \Doctrine\DBAL\Connection $connection
- * @return \Doctrine\DBAL\Schema\SchemaDiff
- */
- protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
- $platform = $connection->getDatabasePlatform();
- $platform->registerDoctrineTypeMapping('enum', 'string');
- $platform->registerDoctrineTypeMapping('bit', 'string');
-
- $schemaDiff = parent::getDiff($targetSchema, $connection);
-
- // identifiers need to be quoted for mysql
- foreach ($schemaDiff->changedTables as $tableDiff) {
- $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
- foreach ($tableDiff->changedColumns as $column) {
- $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
- }
- }
-
- return $schemaDiff;
- }
-}
diff --git a/lib/private/DB/OracleMigrator.php b/lib/private/DB/OracleMigrator.php
index 4828110074c..5abab1a34e2 100644
--- a/lib/private/DB/OracleMigrator.php
+++ b/lib/private/DB/OracleMigrator.php
@@ -1,5 +1,8 @@
<?php
+
+declare(strict_types=1);
/**
+ * @copyright Copyright (c) 2023, Joas Schilling <coding@schilljs.com>
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
@@ -29,176 +32,114 @@
namespace OC\DB;
use Doctrine\DBAL\Exception;
-use Doctrine\DBAL\Schema\Column;
-use Doctrine\DBAL\Schema\ColumnDiff;
-use Doctrine\DBAL\Schema\ForeignKeyConstraint;
-use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
-use Doctrine\DBAL\Schema\Table;
class OracleMigrator extends Migrator {
/**
- * Quote a column's name but changing the name requires recreating
- * the column instance and copying over all properties.
- *
- * @param Column $column old column
- * @return Column new column instance with new name
- */
- protected function quoteColumn(Column $column) {
- $newColumn = new Column(
- $this->connection->quoteIdentifier($column->getName()),
- $column->getType()
- );
- $newColumn->setAutoincrement($column->getAutoincrement());
- $newColumn->setColumnDefinition($column->getColumnDefinition());
- $newColumn->setComment($column->getComment());
- $newColumn->setDefault($column->getDefault());
- $newColumn->setFixed($column->getFixed());
- $newColumn->setLength($column->getLength());
- $newColumn->setNotnull($column->getNotnull());
- $newColumn->setPrecision($column->getPrecision());
- $newColumn->setScale($column->getScale());
- $newColumn->setUnsigned($column->getUnsigned());
- $newColumn->setPlatformOptions($column->getPlatformOptions());
- $newColumn->setCustomSchemaOptions($column->getPlatformOptions());
- return $newColumn;
- }
-
- /**
- * Quote an index's name but changing the name requires recreating
- * the index instance and copying over all properties.
- *
- * @param Index $index old index
- * @return Index new index instance with new name
- */
- protected function quoteIndex($index) {
- return new Index(
- //TODO migrate existing uppercase indexes, then $this->connection->quoteIdentifier($index->getName()),
- $index->getName(),
- array_map(function ($columnName) {
- return $this->connection->quoteIdentifier($columnName);
- }, $index->getColumns()),
- $index->isUnique(),
- $index->isPrimary(),
- $index->getFlags(),
- $index->getOptions()
- );
- }
-
- /**
- * Quote an ForeignKeyConstraint's name but changing the name requires recreating
- * the ForeignKeyConstraint instance and copying over all properties.
- *
- * @param ForeignKeyConstraint $fkc old fkc
- * @return ForeignKeyConstraint new fkc instance with new name
- */
- protected function quoteForeignKeyConstraint($fkc) {
- return new ForeignKeyConstraint(
- array_map(function ($columnName) {
- return $this->connection->quoteIdentifier($columnName);
- }, $fkc->getLocalColumns()),
- $this->connection->quoteIdentifier($fkc->getForeignTableName()),
- array_map(function ($columnName) {
- return $this->connection->quoteIdentifier($columnName);
- }, $fkc->getForeignColumns()),
- $fkc->getName(),
- $fkc->getOptions()
- );
- }
-
- /**
* @param Schema $targetSchema
* @param \Doctrine\DBAL\Connection $connection
* @return \Doctrine\DBAL\Schema\SchemaDiff
* @throws Exception
*/
- protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
- $schemaDiff = parent::getDiff($targetSchema, $connection);
-
+ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection): \Doctrine\DBAL\Schema\SchemaDiff {
// oracle forces us to quote the identifiers
- $schemaDiff->newTables = array_map(function (Table $table) {
- return new Table(
+ $quotedSchema = new Schema();
+ foreach ($targetSchema->getTables() as $table) {
+ $quotedTable = $quotedSchema->createTable(
$this->connection->quoteIdentifier($table->getName()),
- array_map(function (Column $column) {
- return $this->quoteColumn($column);
- }, $table->getColumns()),
- array_map(function (Index $index) {
- return $this->quoteIndex($index);
- }, $table->getIndexes()),
- [],
- array_map(function (ForeignKeyConstraint $fck) {
- return $this->quoteForeignKeyConstraint($fck);
- }, $table->getForeignKeys()),
- $table->getOptions()
);
- }, $schemaDiff->newTables);
- $schemaDiff->removedTables = array_map(function (Table $table) {
- return new Table(
- $this->connection->quoteIdentifier($table->getName()),
- $table->getColumns(),
- $table->getIndexes(),
- [],
- $table->getForeignKeys(),
- $table->getOptions()
- );
- }, $schemaDiff->removedTables);
-
- foreach ($schemaDiff->changedTables as $tableDiff) {
- $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
-
- $tableDiff->addedColumns = array_map(function (Column $column) {
- return $this->quoteColumn($column);
- }, $tableDiff->addedColumns);
-
- foreach ($tableDiff->changedColumns as $column) {
- $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
- // auto increment is not relevant for oracle and can anyhow not be applied on change
- $column->changedProperties = array_diff($column->changedProperties, ['autoincrement', 'unsigned']);
+ foreach ($table->getColumns() as $column) {
+ $newColumn = $quotedTable->addColumn(
+ $this->connection->quoteIdentifier($column->getName()),
+ $column->getType()->getTypeRegistry()->lookupName($column->getType()),
+ );
+ $newColumn->setAutoincrement($column->getAutoincrement());
+ $newColumn->setColumnDefinition($column->getColumnDefinition());
+ $newColumn->setComment($column->getComment());
+ $newColumn->setDefault($column->getDefault());
+ $newColumn->setFixed($column->getFixed());
+ $newColumn->setLength($column->getLength());
+ $newColumn->setNotnull($column->getNotnull());
+ $newColumn->setPrecision($column->getPrecision());
+ $newColumn->setScale($column->getScale());
+ $newColumn->setUnsigned($column->getUnsigned());
+ $newColumn->setPlatformOptions($column->getPlatformOptions());
}
- // remove columns that no longer have changed (because autoincrement and unsigned are not supported)
- $tableDiff->changedColumns = array_filter($tableDiff->changedColumns, function (ColumnDiff $column) {
- return count($column->changedProperties) > 0;
- });
-
- $tableDiff->removedColumns = array_map(function (Column $column) {
- return $this->quoteColumn($column);
- }, $tableDiff->removedColumns);
-
- $tableDiff->renamedColumns = array_map(function (Column $column) {
- return $this->quoteColumn($column);
- }, $tableDiff->renamedColumns);
-
- $tableDiff->addedIndexes = array_map(function (Index $index) {
- return $this->quoteIndex($index);
- }, $tableDiff->addedIndexes);
- $tableDiff->changedIndexes = array_map(function (Index $index) {
- return $this->quoteIndex($index);
- }, $tableDiff->changedIndexes);
-
- $tableDiff->removedIndexes = array_map(function (Index $index) {
- return $this->quoteIndex($index);
- }, $tableDiff->removedIndexes);
+ foreach ($table->getIndexes() as $index) {
+ if ($index->isPrimary()) {
+ $quotedTable->setPrimaryKey(
+ array_map(function ($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $index->getColumns()),
+ //TODO migrate existing uppercase indexes, then $this->connection->quoteIdentifier($index->getName()),
+ $index->getName(),
+ );
+ } elseif ($index->isUnique()) {
+ $quotedTable->addUniqueIndex(
+ array_map(function ($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $index->getColumns()),
+ //TODO migrate existing uppercase indexes, then $this->connection->quoteIdentifier($index->getName()),
+ $index->getName(),
+ $index->getOptions(),
+ );
+ } else {
+ $quotedTable->addIndex(
+ array_map(function ($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $index->getColumns()),
+ //TODO migrate existing uppercase indexes, then $this->connection->quoteIdentifier($index->getName()),
+ $index->getName(),
+ $index->getFlags(),
+ $index->getOptions(),
+ );
+ }
+ }
- $tableDiff->renamedIndexes = array_map(function (Index $index) {
- return $this->quoteIndex($index);
- }, $tableDiff->renamedIndexes);
+ foreach ($table->getUniqueConstraints() as $constraint) {
+ $quotedTable->addUniqueConstraint(
+ array_map(function ($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $constraint->getColumns()),
+ $this->connection->quoteIdentifier($constraint->getName()),
+ $constraint->getFlags(),
+ $constraint->getOptions(),
+ );
+ }
- $tableDiff->addedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) {
- return $this->quoteForeignKeyConstraint($fkc);
- }, $tableDiff->addedForeignKeys);
+ foreach ($table->getForeignKeys() as $foreignKey) {
+ $quotedTable->addForeignKeyConstraint(
+ $this->connection->quoteIdentifier($foreignKey->getForeignTableName()),
+ array_map(function ($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $foreignKey->getLocalColumns()),
+ array_map(function ($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $foreignKey->getForeignColumns()),
+ $foreignKey->getOptions(),
+ $this->connection->quoteIdentifier($foreignKey->getName()),
+ );
+ }
- $tableDiff->changedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) {
- return $this->quoteForeignKeyConstraint($fkc);
- }, $tableDiff->changedForeignKeys);
+ foreach ($table->getOptions() as $option => $value) {
+ $quotedTable->addOption(
+ $option,
+ $value,
+ );
+ }
+ }
- $tableDiff->removedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) {
- return $this->quoteForeignKeyConstraint($fkc);
- }, $tableDiff->removedForeignKeys);
+ foreach ($targetSchema->getSequences() as $sequence) {
+ $quotedSchema->createSequence(
+ $sequence->getName(),
+ $sequence->getAllocationSize(),
+ $sequence->getInitialValue(),
+ );
}
- return $schemaDiff;
+ return parent::getDiff($quotedSchema, $connection);
}
/**
diff --git a/lib/private/DB/PostgreSqlMigrator.php b/lib/private/DB/PostgreSqlMigrator.php
deleted file mode 100644
index 92a0842e1a7..00000000000
--- a/lib/private/DB/PostgreSqlMigrator.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\DB;
-
-use Doctrine\DBAL\Schema\Schema;
-
-class PostgreSqlMigrator extends Migrator {
- /**
- * @param Schema $targetSchema
- * @param \Doctrine\DBAL\Connection $connection
- * @return \Doctrine\DBAL\Schema\SchemaDiff
- */
- protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
- $schemaDiff = parent::getDiff($targetSchema, $connection);
-
- foreach ($schemaDiff->changedTables as $tableDiff) {
- // fix default value in brackets - pg 9.4 is returning a negative default value in ()
- // see https://github.com/doctrine/dbal/issues/2427
- foreach ($tableDiff->changedColumns as $column) {
- $column->changedProperties = array_filter($column->changedProperties, function ($changedProperties) use ($column) {
- if ($changedProperties !== 'default') {
- return true;
- }
- $fromDefault = $column->fromColumn->getDefault();
- $toDefault = $column->column->getDefault();
- $fromDefault = trim((string) $fromDefault, '()');
-
- // by intention usage of !=
- return $fromDefault != $toDefault;
- });
- }
- }
-
- return $schemaDiff;
- }
-}
diff --git a/lib/private/DB/SQLiteMigrator.php b/lib/private/DB/SQLiteMigrator.php
index cbb39070a48..e0102e105b2 100644
--- a/lib/private/DB/SQLiteMigrator.php
+++ b/lib/private/DB/SQLiteMigrator.php
@@ -24,8 +24,6 @@
namespace OC\DB;
use Doctrine\DBAL\Schema\Schema;
-use Doctrine\DBAL\Types\BigIntType;
-use Doctrine\DBAL\Types\Type;
class SQLiteMigrator extends Migrator {
/**
@@ -34,21 +32,12 @@ class SQLiteMigrator extends Migrator {
* @return \Doctrine\DBAL\Schema\SchemaDiff
*/
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
- $platform = $connection->getDatabasePlatform();
- $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer');
- $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer');
- $platform->registerDoctrineTypeMapping('varchar ', 'string');
-
foreach ($targetSchema->getTables() as $table) {
foreach ($table->getColumns() as $column) {
// column comments are not supported on SQLite
if ($column->getComment() !== null) {
$column->setComment(null);
}
- // with sqlite autoincrement columns is of type integer
- if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) {
- $column->setType(Type::getType('integer'));
- }
}
}
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index 05624a2423a..5c68c106993 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -84,7 +84,6 @@ use OC\Repair\RemoveLinkShares;
use OC\Repair\RepairDavShares;
use OC\Repair\RepairInvalidShares;
use OC\Repair\RepairMimeTypes;
-use OC\Repair\SqliteAutoincrement;
use OC\Template\JSCombiner;
use Psr\Log\LoggerInterface;
use Throwable;
@@ -235,14 +234,11 @@ class Repair implements IOutput {
* @return IRepairStep[]
*/
public static function getBeforeUpgradeRepairSteps() {
- /** @var Connection $connection */
- $connection = \OC::$server->get(Connection::class);
/** @var ConnectionAdapter $connectionAdapter */
$connectionAdapter = \OC::$server->get(ConnectionAdapter::class);
$config = \OC::$server->getConfig();
$steps = [
new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), $connectionAdapter, true),
- new SqliteAutoincrement($connection),
new SaveAccountsTableData($connectionAdapter, $config),
new DropAccountTermsTable($connectionAdapter),
];
diff --git a/lib/private/Repair/SqliteAutoincrement.php b/lib/private/Repair/SqliteAutoincrement.php
deleted file mode 100644
index 1199370f221..00000000000
--- a/lib/private/Repair/SqliteAutoincrement.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\Repair;
-
-use Doctrine\DBAL\Platforms\SqlitePlatform;
-use Doctrine\DBAL\Schema\ColumnDiff;
-use Doctrine\DBAL\Schema\SchemaDiff;
-use Doctrine\DBAL\Schema\SchemaException;
-use Doctrine\DBAL\Schema\TableDiff;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-/**
- * Fixes Sqlite autoincrement by forcing the SQLite table schemas to be
- * altered in order to retrigger SQL schema generation through OCSqlitePlatform.
- */
-class SqliteAutoincrement implements IRepairStep {
- /**
- * @var \OC\DB\Connection
- */
- protected $connection;
-
- /**
- * @param \OC\DB\Connection $connection
- */
- public function __construct($connection) {
- $this->connection = $connection;
- }
-
- public function getName() {
- return 'Repair SQLite autoincrement';
- }
-
- /**
- * Fix mime types
- */
- public function run(IOutput $out) {
- if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
- return;
- }
-
- $sourceSchema = $this->connection->getSchemaManager()->createSchema();
-
- $schemaDiff = new SchemaDiff();
-
- foreach ($sourceSchema->getTables() as $tableSchema) {
- $primaryKey = $tableSchema->getPrimaryKey();
- if (!$primaryKey) {
- continue;
- }
-
- $columnNames = $primaryKey->getColumns();
-
- // add a column diff for every primary key column,
- // but do not actually change anything, this will
- // force the generation of SQL statements to alter
- // those tables, which will then trigger the
- // specific SQL code from OCSqlitePlatform
- try {
- $tableDiff = new TableDiff($tableSchema->getName());
- $tableDiff->fromTable = $tableSchema;
- foreach ($columnNames as $columnName) {
- $columnSchema = $tableSchema->getColumn($columnName);
- $columnDiff = new ColumnDiff($columnSchema->getName(), $columnSchema);
- $tableDiff->changedColumns[$columnSchema->getName()] = $columnDiff;
- $schemaDiff->changedTables[] = $tableDiff;
- }
- } catch (SchemaException $e) {
- // ignore
- }
- }
-
- $this->connection->beginTransaction();
- foreach ($schemaDiff->toSql($this->connection->getDatabasePlatform()) as $sql) {
- $this->connection->executeQuery($sql);
- }
- $this->connection->commit();
- }
-}
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 0993fe54f47..f167d19adeb 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -537,7 +537,7 @@ class Setup {
$content .= "\n RewriteCond %{REQUEST_FILENAME} !/(cron|public|remote|status)\\.php";
$content .= "\n RewriteCond %{REQUEST_FILENAME} !/ocs/v(1|2)\\.php";
$content .= "\n RewriteCond %{REQUEST_FILENAME} !/robots\\.txt";
- $content .= "\n RewriteCond %{REQUEST_FILENAME} !/(ocm-provider|ocs-provider|updater)/";
+ $content .= "\n RewriteCond %{REQUEST_FILENAME} !/(ocs-provider|updater)/";
$content .= "\n RewriteCond %{REQUEST_URI} !^/\\.well-known/(acme-challenge|pki-validation)/.*";
$content .= "\n RewriteCond %{REQUEST_FILENAME} !/richdocumentscode(_arm64)?/proxy.php$";
$content .= "\n RewriteRule . index.php [PT,E=PATH_INFO:$1]";
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index cefa1f30876..e2504363257 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -189,6 +189,10 @@ class TemplateLayout extends \OC_Template {
$this->assign('appid', $appId);
$this->assign('bodyid', 'body-public');
+ // Set logo link target
+ $logoUrl = $this->config->getSystemValueString('logo_url', '');
+ $this->assign('logoUrl', $logoUrl);
+
/** @var IRegistry $subscription */
$subscription = \OCP\Server::get(IRegistry::class);
$showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true);
diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php
index 82887f8d029..b654387d17a 100644
--- a/lib/private/User/Session.php
+++ b/lib/private/User/Session.php
@@ -794,6 +794,8 @@ class Session implements IUserSession, Emitter {
$this->logger->error('App token login name does not match', [
'tokenLoginName' => $dbToken->getLoginName(),
'sessionLoginName' => $user,
+ 'app' => 'core',
+ 'user' => $dbToken->getUID(),
]);
return false;
diff --git a/lib/public/BackgroundJob/IJobList.php b/lib/public/BackgroundJob/IJobList.php
index 65e2f5b6250..eeca986423b 100644
--- a/lib/public/BackgroundJob/IJobList.php
+++ b/lib/public/BackgroundJob/IJobList.php
@@ -58,6 +58,19 @@ interface IJobList {
public function add($job, $argument = null): void;
/**
+ * Add a job to the list but only run it after the given timestamp
+ *
+ * For cron background jobs this means the job will likely run shortly after the timestamp
+ * has been reached. For ajax background jobs the job might only run when users are active
+ * on the instance again.
+ *
+ * @param class-string<IJob> $job
+ * @param mixed $argument The serializable argument to be passed to $job->run() when the job is executed
+ * @since 28.0.0
+ */
+ public function scheduleAfter(string $job, int $runAfter, $argument = null): void;
+
+ /**
* Remove a job from the list
*
* @param IJob|class-string<IJob> $job
diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php
index 63fdfb65971..491ac6d8e2f 100644
--- a/lib/public/DB/QueryBuilder/IQueryBuilder.php
+++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php
@@ -27,6 +27,7 @@
*/
namespace OCP\DB\QueryBuilder;
+use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use OCP\DB\Exception;
@@ -72,11 +73,11 @@ interface IQueryBuilder {
/**
* @since 9.0.0
*/
- public const PARAM_INT_ARRAY = Connection::PARAM_INT_ARRAY;
+ public const PARAM_INT_ARRAY = ArrayParameterType::INTEGER;
/**
* @since 9.0.0
*/
- public const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY;
+ public const PARAM_STR_ARRAY = ArrayParameterType::STRING;
/**
* @since 24.0.0 Indicates how many rows can be deleted at once with MySQL