aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/App/AppStore/Fetcher/Fetcher.php2
-rw-r--r--lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php6
-rw-r--r--lib/private/BackgroundJob/JobList.php13
-rw-r--r--lib/private/DB/ConnectionFactory.php38
-rw-r--r--lib/private/Federation/CloudIdManager.php47
-rw-r--r--lib/private/Files/Filesystem.php5
-rw-r--r--lib/private/Lockdown/Filesystem/NullStorage.php2
-rw-r--r--lib/private/Server.php4
-rw-r--r--lib/private/Share20/DefaultShareProvider.php2
-rw-r--r--lib/private/Share20/Manager.php2
10 files changed, 86 insertions, 35 deletions
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php
index 2e949fedb51..24876675d60 100644
--- a/lib/private/App/AppStore/Fetcher/Fetcher.php
+++ b/lib/private/App/AppStore/Fetcher/Fetcher.php
@@ -56,7 +56,7 @@ abstract class Fetcher {
*
* @return array
*/
- protected function fetch($ETag, $content) {
+ protected function fetch($ETag, $content, $allowUnstable = false) {
$appstoreenabled = $this->config->getSystemValueBool('appstoreenabled', true);
if ((int)$this->config->getAppValue('settings', 'appstore-fetcher-lastFailure', '0') > time() - self::RETRY_AFTER_FAILURE_SECONDS) {
return [];
diff --git a/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php b/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php
index e4571dfc50e..b69b129f798 100644
--- a/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php
+++ b/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php
@@ -15,6 +15,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Middleware;
use OCP\ISession;
use OCP\IUserSession;
+use Psr\Log\LoggerInterface;
use ReflectionMethod;
// Will close the session if the user session is ephemeral.
@@ -24,6 +25,7 @@ class FlowV2EphemeralSessionsMiddleware extends Middleware {
private ISession $session,
private IUserSession $userSession,
private ControllerMethodReflector $reflector,
+ private LoggerInterface $logger,
) {
}
@@ -52,6 +54,10 @@ class FlowV2EphemeralSessionsMiddleware extends Middleware {
return;
}
+ $this->logger->info('Closing user and PHP session for ephemeral session', [
+ 'controller' => $controller::class,
+ 'method' => $methodName,
+ ]);
$this->userSession->logout();
$this->session->close();
}
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index 0d88200cff7..c00a51e3851 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -24,6 +24,9 @@ use function min;
use function strlen;
class JobList implements IJobList {
+ /** @var array<string, int> */
+ protected array $alreadyVisitedParallelBlocked = [];
+
public function __construct(
protected IDBConnection $connection,
protected IConfig $config,
@@ -198,6 +201,12 @@ class JobList implements IJobList {
$job = $this->buildJob($row);
if ($job instanceof IParallelAwareJob && !$job->getAllowParallelRuns() && $this->hasReservedJob(get_class($job))) {
+ if (!isset($this->alreadyVisitedParallelBlocked[get_class($job)])) {
+ $this->alreadyVisitedParallelBlocked[get_class($job)] = $job->getId();
+ } elseif ($this->alreadyVisitedParallelBlocked[get_class($job)] === $job->getId()) {
+ $this->logger->info('Skipped through all jobs and revisited a IParallelAwareJob blocked job again, giving up.', ['app' => 'cron']);
+ return null;
+ }
$this->logger->info('Skipping ' . get_class($job) . ' job with ID ' . $job->getId() . ' because another job with the same class is already running', ['app' => 'cron']);
$update = $this->connection->getQueryBuilder();
@@ -210,6 +219,10 @@ class JobList implements IJobList {
return $this->getNext($onlyTimeSensitive, $jobClasses);
}
+ if ($job !== null && isset($this->alreadyVisitedParallelBlocked[get_class($job)])) {
+ unset($this->alreadyVisitedParallelBlocked[get_class($job)]);
+ }
+
if ($job instanceof \OCP\BackgroundJob\TimedJob) {
$now = $this->timeFactory->getTime();
$nextPossibleRun = $job->getLastRun() + $job->getInterval();
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php
index 4d286cb3068..d9b80b81992 100644
--- a/lib/private/DB/ConnectionFactory.php
+++ b/lib/private/DB/ConnectionFactory.php
@@ -121,21 +121,9 @@ class ConnectionFactory {
case 'oci':
$eventManager->addEventSubscriber(new OracleSessionInit);
- // the driverOptions are unused in dbal and need to be mapped to the parameters
- if (isset($connectionParams['driverOptions'])) {
- $connectionParams = array_merge($connectionParams, $connectionParams['driverOptions']);
- }
- $host = $connectionParams['host'];
- $port = $connectionParams['port'] ?? null;
- $dbName = $connectionParams['dbname'];
-
- // we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string
- if ($host === '') {
- $connectionParams['dbname'] = $dbName; // use dbname as easy connect name
- } else {
- $connectionParams['dbname'] = '//' . $host . (!empty($port) ? ":{$port}" : '') . '/' . $dbName;
- }
- unset($connectionParams['host']);
+ $connectionParams = $this->forceConnectionStringOracle($connectionParams);
+ $connectionParams['primary'] = $this->forceConnectionStringOracle($connectionParams['primary']);
+ $connectionParams['replica'] = array_map([$this, 'forceConnectionStringOracle'], $connectionParams['replica']);
break;
case 'sqlite3':
@@ -265,4 +253,24 @@ class ConnectionFactory {
return $params;
}
+
+ protected function forceConnectionStringOracle(array $connectionParams): array {
+ // the driverOptions are unused in dbal and need to be mapped to the parameters
+ if (isset($connectionParams['driverOptions'])) {
+ $connectionParams = array_merge($connectionParams, $connectionParams['driverOptions']);
+ }
+ $host = $connectionParams['host'];
+ $port = $connectionParams['port'] ?? null;
+ $dbName = $connectionParams['dbname'];
+
+ // we set the connect string as dbname and unset the host to coerce doctrine into using it as connect string
+ if ($host === '') {
+ $connectionParams['dbname'] = $dbName; // use dbname as easy connect name
+ } else {
+ $connectionParams['dbname'] = '//' . $host . (!empty($port) ? ":{$port}" : '') . '/' . $dbName;
+ }
+ unset($connectionParams['host']);
+
+ return $connectionParams;
+ }
}
diff --git a/lib/private/Federation/CloudIdManager.php b/lib/private/Federation/CloudIdManager.php
index 7e7adda3d39..c599d9046a6 100644
--- a/lib/private/Federation/CloudIdManager.php
+++ b/lib/private/Federation/CloudIdManager.php
@@ -14,6 +14,7 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudId;
use OCP\Federation\ICloudIdManager;
+use OCP\Federation\ICloudIdResolver;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IURLGenerator;
@@ -21,27 +22,19 @@ use OCP\IUserManager;
use OCP\User\Events\UserChangedEvent;
class CloudIdManager implements ICloudIdManager {
- /** @var IManager */
- private $contactsManager;
- /** @var IURLGenerator */
- private $urlGenerator;
- /** @var IUserManager */
- private $userManager;
private ICache $memCache;
private ICache $displayNameCache;
- /** @var array[] */
private array $cache = [];
+ /** @var ICloudIdResolver[] */
+ private array $cloudIdResolvers = [];
public function __construct(
- IManager $contactsManager,
- IURLGenerator $urlGenerator,
- IUserManager $userManager,
ICacheFactory $cacheFactory,
IEventDispatcher $eventDispatcher,
+ private IManager $contactsManager,
+ private IURLGenerator $urlGenerator,
+ private IUserManager $userManager,
) {
- $this->contactsManager = $contactsManager;
- $this->urlGenerator = $urlGenerator;
- $this->userManager = $userManager;
$this->memCache = $cacheFactory->createDistributed('cloud_id_');
$this->displayNameCache = $cacheFactory->createDistributed('cloudid_name_');
$eventDispatcher->addListener(UserChangedEvent::class, [$this, 'handleUserEvent']);
@@ -81,6 +74,12 @@ class CloudIdManager implements ICloudIdManager {
public function resolveCloudId(string $cloudId): ICloudId {
// TODO magic here to get the url and user instead of just splitting on @
+ foreach ($this->cloudIdResolvers as $resolver) {
+ if ($resolver->isValidCloudId($cloudId)) {
+ return $resolver->resolveCloudId($cloudId);
+ }
+ }
+
if (!$this->isValidCloudId($cloudId)) {
throw new \InvalidArgumentException('Invalid cloud id');
}
@@ -251,6 +250,26 @@ class CloudIdManager implements ICloudIdManager {
* @return bool
*/
public function isValidCloudId(string $cloudId): bool {
- return str_contains($cloudId, '@');
+ foreach ($this->cloudIdResolvers as $resolver) {
+ if ($resolver->isValidCloudId($cloudId)) {
+ return true;
+ }
+ }
+
+ return strpos($cloudId, '@') !== false;
+ }
+
+ public function createCloudId(string $id, string $user, string $remote, ?string $displayName = null): ICloudId {
+ return new CloudId($id, $user, $remote, $displayName);
+ }
+
+ public function registerCloudIdResolver(ICloudIdResolver $resolver): void {
+ array_unshift($this->cloudIdResolvers, $resolver);
+ }
+
+ public function unregisterCloudIdResolver(ICloudIdResolver $resolver): void {
+ if (($key = array_search($resolver, $this->cloudIdResolvers)) !== false) {
+ array_splice($this->cloudIdResolvers, $key, 1);
+ }
}
}
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index 48c069de0b9..8fe56cf060c 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -8,6 +8,7 @@
namespace OC\Files;
use OC\Files\Mount\MountPoint;
+use OC\Files\Storage\StorageFactory;
use OC\User\NoUserException;
use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
@@ -178,7 +179,9 @@ class Filesystem {
}
$mounts = self::getMountManager()->getAll();
- if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper, $priority, $mounts)) {
+ /** @var StorageFactory $loader */
+ $loader = self::getLoader();
+ if (!$loader->addStorageWrapper($wrapperName, $wrapper, $priority, $mounts)) {
// do not re-wrap if storage with this name already existed
return;
}
diff --git a/lib/private/Lockdown/Filesystem/NullStorage.php b/lib/private/Lockdown/Filesystem/NullStorage.php
index 71a40d8da1e..fd952fae637 100644
--- a/lib/private/Lockdown/Filesystem/NullStorage.php
+++ b/lib/private/Lockdown/Filesystem/NullStorage.php
@@ -30,7 +30,7 @@ class NullStorage extends Common {
}
public function opendir(string $path): IteratorDirectory {
- return new IteratorDirectory([]);
+ return new IteratorDirectory();
}
public function is_dir(string $path): bool {
diff --git a/lib/private/Server.php b/lib/private/Server.php
index d339a97baab..171fee2afa1 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -1160,11 +1160,11 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
return new CloudIdManager(
+ $c->get(ICacheFactory::class),
+ $c->get(IEventDispatcher::class),
$c->get(\OCP\Contacts\IManager::class),
$c->get(IURLGenerator::class),
$c->get(IUserManager::class),
- $c->get(ICacheFactory::class),
- $c->get(IEventDispatcher::class),
);
});
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index e1eebe1e450..a2c0fd15eb4 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -284,7 +284,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->set('expiration', $qb->createNamedParameter($expirationDate, IQueryBuilder::PARAM_DATETIME_MUTABLE))
->set('note', $qb->createNamedParameter($share->getNote()))
->set('label', $qb->createNamedParameter($share->getLabel()))
- ->set('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0), IQueryBuilder::PARAM_INT)
+ ->set('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0, IQueryBuilder::PARAM_INT))
->executeStatement();
}
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 01664c6a0a3..9bfa810b108 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -12,6 +12,7 @@ use OC\KnownUser\KnownUserService;
use OC\Share20\Exception\ProviderException;
use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files_Sharing\SharedStorage;
+use OCA\ShareByMail\ShareByMailProvider;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
use OCP\Files\Folder;
@@ -869,6 +870,7 @@ class Manager implements IManager {
// Now update the share!
$provider = $this->factory->getProviderForType($share->getShareType());
if ($share->getShareType() === IShare::TYPE_EMAIL) {
+ /** @var ShareByMailProvider $provider */
$share = $provider->update($share, $plainTextPassword);
} else {
$share = $provider->update($share);