Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/private/Profile/ProfileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OCP\IUser;
use OCP\L10N\IFactory;
use OCP\Profile\ILinkAction;
use OCP\Cache\CappedMemoryCache;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -81,6 +82,8 @@ class ProfileManager {

/** @var null|ILinkAction[] */
private $sortedActions = null;
/** @var CappedMemoryCache<ProfileConfig> */
private CappedMemoryCache $configCache;

private const CORE_APP_ID = 'core';

Expand Down Expand Up @@ -127,6 +130,7 @@ public function __construct(
$this->l10nFactory = $l10nFactory;
$this->logger = $logger;
$this->coordinator = $coordinator;
$this->configCache = new CappedMemoryCache();
}

/**
Expand Down Expand Up @@ -370,7 +374,10 @@ private function getDefaultProfileConfig(IUser $targetUser, ?IUser $visitingUser
public function getProfileConfig(IUser $targetUser, ?IUser $visitingUser): array {
$defaultProfileConfig = $this->getDefaultProfileConfig($targetUser, $visitingUser);
try {
$config = $this->configMapper->get($targetUser->getUID());
if (($config = $this->configCache[$targetUser->getUID()]) === null) {
$config = $this->configMapper->get($targetUser->getUID());
$this->configCache[$targetUser->getUID()] = $config;
}
// Merge defaults with the existing config in case the defaults are missing
$config->setConfigArray(array_merge(
$defaultProfileConfig,
Expand Down