diff options
Diffstat (limited to 'lib/private')
21 files changed, 147 insertions, 34 deletions
diff --git a/lib/private/BackgroundJob/Job.php b/lib/private/BackgroundJob/Job.php index 6f85e3382ed..399ff05134e 100644 --- a/lib/private/BackgroundJob/Job.php +++ b/lib/private/BackgroundJob/Job.php @@ -29,6 +29,9 @@ use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\IJobList; use OCP\ILogger; +/** + * @deprecated internal class, use \OCP\BackgroundJob\Job + */ abstract class Job implements IJob { /** @var int */ protected $id; diff --git a/lib/private/BackgroundJob/Legacy/QueuedJob.php b/lib/private/BackgroundJob/Legacy/QueuedJob.php index d68fd217fdd..fd001738d4f 100644 --- a/lib/private/BackgroundJob/Legacy/QueuedJob.php +++ b/lib/private/BackgroundJob/Legacy/QueuedJob.php @@ -23,6 +23,9 @@ */ namespace OC\BackgroundJob\Legacy; +/** + * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob + */ class QueuedJob extends \OC\BackgroundJob\QueuedJob { public function run($argument) { $class = $argument['klass']; diff --git a/lib/private/BackgroundJob/Legacy/RegularJob.php b/lib/private/BackgroundJob/Legacy/RegularJob.php index e3286536c9a..0f337a35eb0 100644 --- a/lib/private/BackgroundJob/Legacy/RegularJob.php +++ b/lib/private/BackgroundJob/Legacy/RegularJob.php @@ -24,6 +24,9 @@ namespace OC\BackgroundJob\Legacy; use OCP\AutoloadNotAllowedException; +/** + * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob + */ class RegularJob extends \OC\BackgroundJob\Job { public function run($argument) { try { diff --git a/lib/private/BackgroundJob/QueuedJob.php b/lib/private/BackgroundJob/QueuedJob.php index 176227e73db..28d86481e62 100644 --- a/lib/private/BackgroundJob/QueuedJob.php +++ b/lib/private/BackgroundJob/QueuedJob.php @@ -32,6 +32,8 @@ use OCP\ILogger; * create a background job that is to be executed once * * @package OC\BackgroundJob + * + * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob */ abstract class QueuedJob extends Job { /** diff --git a/lib/private/BackgroundJob/TimedJob.php b/lib/private/BackgroundJob/TimedJob.php index 62b9bab7ccc..0f0951e1aec 100644 --- a/lib/private/BackgroundJob/TimedJob.php +++ b/lib/private/BackgroundJob/TimedJob.php @@ -34,6 +34,8 @@ use OCP\ILogger; * create a background job that is to be executed at an interval * * @package OC\BackgroundJob + * + * @deprecated internal class, use \OCP\BackgroundJob\TimedJob */ abstract class TimedJob extends Job { protected $interval = 0; diff --git a/lib/private/Files/Config/CachedMountFileInfo.php b/lib/private/Files/Config/CachedMountFileInfo.php index 7fdc26f7d53..71a6ddb9ea9 100644 --- a/lib/private/Files/Config/CachedMountFileInfo.php +++ b/lib/private/Files/Config/CachedMountFileInfo.php @@ -30,12 +30,21 @@ class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInf /** @var string */ private $internalPath; - public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId, $rootInternalPath, $internalPath) { - parent::__construct($user, $storageId, $rootId, $mountPoint, $mountId, $rootInternalPath); + public function __construct( + IUser $user, + int $storageId, + int $rootId, + string $mountPoint, + ?int $mountId, + string $mountProvider, + string $rootInternalPath, + string $internalPath + ) { + parent::__construct($user, $storageId, $rootId, $mountPoint, $mountProvider, $mountId, $rootInternalPath); $this->internalPath = $internalPath; } - public function getInternalPath() { + public function getInternalPath(): string { if ($this->getRootInternalPath()) { return substr($this->internalPath, strlen($this->getRootInternalPath()) + 1); } else { @@ -43,7 +52,7 @@ class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInf } } - public function getPath() { + public function getPath(): string { return $this->getMountPoint() . $this->getInternalPath(); } } diff --git a/lib/private/Files/Config/CachedMountInfo.php b/lib/private/Files/Config/CachedMountInfo.php index e7e10cfe2af..c70dba100a4 100644 --- a/lib/private/Files/Config/CachedMountInfo.php +++ b/lib/private/Files/Config/CachedMountInfo.php @@ -58,6 +58,9 @@ class CachedMountInfo implements ICachedMountInfo { */ protected $rootInternalPath; + /** @var string */ + protected $mountProvider; + /** * CachedMountInfo constructor. * @@ -68,13 +71,25 @@ class CachedMountInfo implements ICachedMountInfo { * @param int|null $mountId * @param string $rootInternalPath */ - public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId = null, $rootInternalPath = '') { + public function __construct( + IUser $user, + int $storageId, + int $rootId, + string $mountPoint, + string $mountProvider, + int $mountId = null, + string $rootInternalPath = '' + ) { $this->user = $user; $this->storageId = $storageId; $this->rootId = $rootId; $this->mountPoint = $mountPoint; $this->mountId = $mountId; $this->rootInternalPath = $rootInternalPath; + if (strlen($mountProvider) > 128) { + throw new \Exception("Mount provider $mountProvider name exceeds the limit of 128 characters"); + } + $this->mountProvider = $mountProvider; } /** @@ -138,4 +153,8 @@ class CachedMountInfo implements ICachedMountInfo { public function getRootInternalPath() { return $this->rootInternalPath; } + + public function getMountProvider(): string { + return $this->mountProvider; + } } diff --git a/lib/private/Files/Config/LazyStorageMountInfo.php b/lib/private/Files/Config/LazyStorageMountInfo.php index bfd632c5f6e..fd3bbcbe0fb 100644 --- a/lib/private/Files/Config/LazyStorageMountInfo.php +++ b/lib/private/Files/Config/LazyStorageMountInfo.php @@ -81,4 +81,8 @@ class LazyStorageMountInfo extends CachedMountInfo { public function getRootInternalPath() { return $this->mount->getInternalPath($this->mount->getMountPoint()); } + + public function getMountProvider(): string { + return $this->mount->getMountProvider(); + } } diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 71eb918a58c..dc2640361e7 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -164,7 +164,8 @@ class UserMountCache implements IUserMountCache { if ( $newMount->getMountPoint() !== $cachedMount->getMountPoint() || $newMount->getStorageId() !== $cachedMount->getStorageId() || - $newMount->getMountId() !== $cachedMount->getMountId() + $newMount->getMountId() !== $cachedMount->getMountId() || + $newMount->getMountProvider() !== $cachedMount->getMountProvider() ) { $changed[] = $newMount; } @@ -180,7 +181,8 @@ class UserMountCache implements IUserMountCache { 'root_id' => $mount->getRootId(), 'user_id' => $mount->getUser()->getUID(), 'mount_point' => $mount->getMountPoint(), - 'mount_id' => $mount->getMountId() + 'mount_id' => $mount->getMountId(), + 'mount_provider_class' => $mount->getMountProvider(), ], ['root_id', 'user_id']); } else { // in some cases this is legitimate, like orphaned shares @@ -195,6 +197,7 @@ class UserMountCache implements IUserMountCache { ->set('storage_id', $builder->createNamedParameter($mount->getStorageId())) ->set('mount_point', $builder->createNamedParameter($mount->getMountPoint())) ->set('mount_id', $builder->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT)) + ->set('mount_provider_class', $builder->createNamedParameter($mount->getMountProvider())) ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))); @@ -219,7 +222,15 @@ class UserMountCache implements IUserMountCache { if (!is_null($mount_id)) { $mount_id = (int)$mount_id; } - return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $mount_id, isset($row['path']) ? $row['path'] : ''); + return new CachedMountInfo( + $user, + (int)$row['storage_id'], + (int)$row['root_id'], + $row['mount_point'], + $row['mount_provider_class'] ?? '', + $mount_id, + isset($row['path']) ? $row['path'] : '', + ); } /** @@ -229,7 +240,7 @@ class UserMountCache implements IUserMountCache { public function getMountsForUser(IUser $user) { if (!isset($this->mountsForUsers[$user->getUID()])) { $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class') ->from('mounts', 'm') ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) ->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID()))); @@ -250,7 +261,7 @@ class UserMountCache implements IUserMountCache { */ public function getMountsForStorageId($numericStorageId, $user = null) { $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class') ->from('mounts', 'm') ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) ->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT))); @@ -272,7 +283,7 @@ class UserMountCache implements IUserMountCache { */ public function getMountsForRootId($rootFileId) { $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class') ->from('mounts', 'm') ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) ->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT))); @@ -286,10 +297,10 @@ class UserMountCache implements IUserMountCache { /** * @param $fileId - * @return array + * @return array{int, string, int} * @throws \OCP\Files\NotFoundException */ - private function getCacheInfoFromFileId($fileId) { + private function getCacheInfoFromFileId($fileId): array { if (!isset($this->cacheInfoCache[$fileId])) { $builder = $this->connection->getQueryBuilder(); $query = $builder->select('storage', 'path', 'mimetype') @@ -303,7 +314,7 @@ class UserMountCache implements IUserMountCache { if (is_array($row)) { $this->cacheInfoCache[$fileId] = [ (int)$row['storage'], - $row['path'], + (string)$row['path'], (int)$row['mimetype'] ]; } else { @@ -326,7 +337,7 @@ class UserMountCache implements IUserMountCache { return []; } $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class') ->from('mounts', 'm') ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) ->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($storageId, IQueryBuilder::PARAM_INT))); @@ -343,7 +354,7 @@ class UserMountCache implements IUserMountCache { if ($fileId === (int)$row['root_id']) { return true; } - $internalMountPath = isset($row['path']) ? $row['path'] : ''; + $internalMountPath = $row['path'] ?? ''; return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/'; }); @@ -356,6 +367,7 @@ class UserMountCache implements IUserMountCache { $mount->getRootId(), $mount->getMountPoint(), $mount->getMountId(), + $mount->getMountProvider(), $mount->getRootInternalPath(), $internalPath ); diff --git a/lib/private/Files/Mount/CacheMountProvider.php b/lib/private/Files/Mount/CacheMountProvider.php index 16ecefb0dac..90dfa0b05f3 100644 --- a/lib/private/Files/Mount/CacheMountProvider.php +++ b/lib/private/Files/Mount/CacheMountProvider.php @@ -61,8 +61,8 @@ class CacheMountProvider implements IMountProvider { } return [ - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir, $loader]), - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads', $loader]) + new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class), + new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class) ]; } else { return []; diff --git a/lib/private/Files/Mount/LocalHomeMountProvider.php b/lib/private/Files/Mount/LocalHomeMountProvider.php index c7b2296c4a8..25a67fc1574 100644 --- a/lib/private/Files/Mount/LocalHomeMountProvider.php +++ b/lib/private/Files/Mount/LocalHomeMountProvider.php @@ -38,6 +38,6 @@ class LocalHomeMountProvider implements IHomeMountProvider { */ public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { $arguments = ['user' => $user]; - return new MountPoint('\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader); + return new MountPoint('\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader, null, null, self::class); } } diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php index 8c6f1acceec..22b05b1f384 100644 --- a/lib/private/Files/Mount/Manager.php +++ b/lib/private/Files/Mount/Manager.php @@ -85,6 +85,9 @@ class Manager implements IMountManager { if (strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0) { // for appdata, we only setup the root bits, not the user bits \OC_Util::setupRootFS(); + } elseif (strpos($path, '/files_external/uploads/') === 0) { + // for OC\Security\CertificateManager, we only setup the root bits, not the user bits + \OC_Util::setupRootFS(); } else { \OC_Util::setupFS(); } diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 368be0a917e..d598355dbae 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -34,6 +34,7 @@ use OC\Files\Filesystem; use OC\Files\Storage\Storage; use OC\Files\Storage\StorageFactory; use OCP\Files\Mount\IMountPoint; +use OCP\Files\Storage\IStorageFactory; use OCP\ILogger; class MountPoint implements IMountPoint { @@ -76,6 +77,9 @@ class MountPoint implements IMountPoint { /** @var int|null */ protected $mountId; + /** @var string */ + protected $mountProvider; + /** * @param string|\OC\Files\Storage\Storage $storage * @param string $mountpoint @@ -83,9 +87,18 @@ class MountPoint implements IMountPoint { * @param \OCP\Files\Storage\IStorageFactory $loader * @param array $mountOptions mount specific options * @param int|null $mountId + * @param string|null $mountProvider * @throws \Exception */ - public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) { + public function __construct( + $storage, + string $mountpoint, + array $arguments = null, + IStorageFactory $loader = null, + array $mountOptions = null, + int $mountId = null, + string $mountProvider = null + ) { if (is_null($arguments)) { $arguments = []; } @@ -113,6 +126,12 @@ class MountPoint implements IMountPoint { $this->class = $storage; $this->arguments = $arguments; } + if ($mountProvider) { + if (strlen($mountProvider) > 128) { + throw new \Exception("Mount provider $mountProvider name exceeds the limit of 128 characters"); + } + } + $this->mountProvider = $mountProvider ?? ''; } /** @@ -286,4 +305,8 @@ class MountPoint implements IMountPoint { public function getMountType() { return ''; } + + public function getMountProvider(): string { + return $this->mountProvider; + } } diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php index 972d3893e66..6a8a7d1f2fb 100644 --- a/lib/private/Files/Mount/ObjectHomeMountProvider.php +++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php @@ -65,7 +65,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider { return null; } - return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader); + return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader, null, null, self::class); } /** diff --git a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php index 2830e37ded3..0043503f2cd 100644 --- a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php +++ b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php @@ -69,7 +69,10 @@ class ObjectStorePreviewCacheMountProvider implements IRootMountProvider { AppdataPreviewObjectStoreStorage::class, '/appdata_' . $instanceId . '/preview/' . $parent . '/' . $child, $this->getMultiBucketObjectStore($i), - $loader + $loader, + null, + null, + self::class ); $i++; } @@ -87,7 +90,10 @@ class ObjectStorePreviewCacheMountProvider implements IRootMountProvider { $fakeRootStorageJail, '/appdata_' . $instanceId . '/preview/old-multibucket', null, - $loader + $loader, + null, + null, + self::class ); return $mountPoints; diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index 55421257886..bfdaeeccff7 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -38,7 +38,7 @@ class LazyFolder implements \OCP\Files\Folder { private $folderClosure; /** @var LazyFolder | null */ - private $folder = null; + protected $folder = null; /** * LazyFolder constructor. diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 4a86207f25a..b5707c87543 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -29,6 +29,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OC\Files\Node; use OC\Cache\CappedMemoryCache; @@ -87,8 +88,8 @@ class Root extends Folder implements IRootFolder { * @param IUserManager $userManager */ public function __construct($manager, - $view, - $user, + $view, + $user, IUserMountCache $userMountCache, ILogger $logger, IUserManager $userManager) { @@ -189,9 +190,9 @@ class Root extends Folder implements IRootFolder { /** * @param string $path - * @throws \OCP\Files\NotFoundException - * @throws \OCP\Files\NotPermittedException * @return Node + * @throws \OCP\Files\NotPermittedException + * @throws \OCP\Files\NotFoundException */ public function get($path) { $path = $this->normalizePath($path); @@ -212,8 +213,8 @@ class Root extends Folder implements IRootFolder { /** * @param string $targetPath - * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node + * @throws \OCP\Files\NotPermittedException */ public function rename($targetPath) { throw new NotPermittedException(); @@ -225,8 +226,8 @@ class Root extends Folder implements IRootFolder { /** * @param string $targetPath - * @throws \OCP\Files\NotPermittedException * @return \OC\Files\Node\Node + * @throws \OCP\Files\NotPermittedException */ public function copy($targetPath) { throw new NotPermittedException(); diff --git a/lib/private/SystemConfig.php b/lib/private/SystemConfig.php index c435b9180b9..012c959ce85 100644 --- a/lib/private/SystemConfig.php +++ b/lib/private/SystemConfig.php @@ -43,6 +43,10 @@ class SystemConfig { 'dbhost' => true, 'dbpassword' => true, 'dbuser' => true, + 'activity_dbname' => true, + 'activity_dbhost' => true, + 'activity_dbpassword' => true, + 'activity_dbuser' => true, 'mail_from_address' => true, 'mail_domain' => true, 'mail_smtphost' => true, diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 2973240a4a1..cd26337cd20 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -548,11 +548,11 @@ class Session implements IUserSession, Emitter { \OC::$server->getCsrfTokenManager()->refreshToken(); } - //we need to pass the user name, which may differ from login name - $user = $this->getUser()->getUID(); - OC_Util::setupFS($user); - if ($firstTimeLogin) { + //we need to pass the user name, which may differ from login name + $user = $this->getUser()->getUID(); + OC_Util::setupFS($user); + // TODO: lock necessary? //trigger creation of user home and /files folder $userFolder = \OC::$server->getUserFolder($user); diff --git a/lib/private/UserStatus/ISettableProvider.php b/lib/private/UserStatus/ISettableProvider.php index fc0d502845e..88a107d1f86 100644 --- a/lib/private/UserStatus/ISettableProvider.php +++ b/lib/private/UserStatus/ISettableProvider.php @@ -52,4 +52,15 @@ interface ISettableProvider extends IProvider { * @param string $status The expected current status. */ public function revertUserStatus(string $userId, string $messageId, string $status): void; + + /** + * Revert an automatically set user status. For example after leaving a call, + * change back to the previously set status. If the user has already updated + * their status, this method does nothing. + * + * @param string[] $userIds The users for which we want to update the status. + * @param string $messageId The expected current messageId. + * @param string $status The expected current status. + */ + public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void; } diff --git a/lib/private/UserStatus/Manager.php b/lib/private/UserStatus/Manager.php index bca80bc5b03..c93795bea5b 100644 --- a/lib/private/UserStatus/Manager.php +++ b/lib/private/UserStatus/Manager.php @@ -121,4 +121,12 @@ class Manager implements IManager { } $this->provider->revertUserStatus($userId, $messageId, $status); } + + public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void { + $this->setupProvider(); + if (!$this->provider || !($this->provider instanceof ISettableProvider)) { + return; + } + $this->provider->revertMultipleUserStatus($userIds, $messageId, $status); + } } |