Skip to content

Commit 35847fb

Browse files
Merge pull request #50682 from nextcloud/backport/50640/stable30
[stable30] fix(TaskProcessing\Manager): Always use distributed cache and use PHP serialize
2 parents 094ea5c + befca3e commit 35847fb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/private/TaskProcessing/Manager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class Manager implements IManager {
8181
private IAppData $appData;
8282
private ?array $preferences = null;
8383
private ?array $providersById = null;
84-
private ICache $cache;
8584
private ICache $distributedCache;
8685

8786
public function __construct(
@@ -101,7 +100,6 @@ public function __construct(
101100
ICacheFactory $cacheFactory,
102101
) {
103102
$this->appData = $appDataFactory->get('core');
104-
$this->cache = $cacheFactory->createLocal('task_processing::');
105103
$this->distributedCache = $cacheFactory->createDistributed('task_processing::');
106104
}
107105

@@ -741,8 +739,10 @@ public function getPreferredProvider(string $taskTypeId) {
741739

742740
public function getAvailableTaskTypes(): array {
743741
if ($this->availableTaskTypes === null) {
744-
// We use local cache only because distributed cache uses JSOn stringify which would botch our ShapeDescriptor objects
745-
$this->availableTaskTypes = $this->cache->get('available_task_types');
742+
$cachedValue = $this->distributedCache->get('available_task_types_v2');
743+
if ($cachedValue !== null) {
744+
$this->availableTaskTypes = unserialize($cachedValue);
745+
}
746746
}
747747
if ($this->availableTaskTypes === null) {
748748
$taskTypes = $this->_getTaskTypes();
@@ -775,7 +775,7 @@ public function getAvailableTaskTypes(): array {
775775
}
776776

777777
$this->availableTaskTypes = $availableTaskTypes;
778-
$this->cache->set('available_task_types', $this->availableTaskTypes, 60);
778+
$this->distributedCache->set('available_task_types_v2', serialize($this->availableTaskTypes), 60);
779779
}
780780

781781
return $this->availableTaskTypes;

0 commit comments

Comments
 (0)