Skip to content

ReferenceManager ignores IReferenceProvider::getCacheTTL() - always uses hardcoded 3600s #56012

@LexioJ

Description

@LexioJ

Problem

The IReferenceProvider interface defines a getCacheTTL() method that allows reference providers to specify custom cache TTLs. However, ReferenceManager::resolveReference() ignores this method and always caches resolved references for a hardcoded 3600 seconds.

This prevents providers from implementing shorter TTLs for frequently-changing data (e.g., external API data that updates more frequently than 1 hour).

Current Behavior

In lib/private/Collaboration/Reference/ReferenceManager.php line 125:

$this->cache->set($cacheKey, Reference::toCache($reference), self::CACHE_TTL);  // Always 3600s

The provider's getCacheTTL() return value is never consulted.

Expected Behavior

ReferenceManager should respect the provider's getCacheTTL() method:

$ttl = $matchedProvider->getCacheTTL() ?? self::CACHE_TTL;
$this->cache->set($cacheKey, Reference::toCache($reference), $ttl);

Benefits

  • Allows providers to define appropriate TTLs for their data
  • Maintains backward compatibility (null returns fallback to 3600s)
  • Aligns with existing interface design
  • Minimal code change (1-2 lines)

Use Case

External integrations (e.g., ticketing systems, configuration management) often have data that changes more frequently than 1 hour. Providers should be able to specify shorter TTLs (e.g., 60 seconds) without being blocked by Nextcloud's hardcoded cache duration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmap33-feedbackbug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions