diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-03-18 17:50:12 +0100 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-03-19 09:36:06 +0100 |
commit | bae133bf4f43b4815734b2c05c0263061cae2cfa (patch) | |
tree | 5bc5588ff4a955c288aea7e65f0efa4279217839 /lib | |
parent | 6101abbb2dd9408cdda666ec491751447dc1ab07 (diff) | |
download | nextcloud-server-bae133bf4f43b4815734b2c05c0263061cae2cfa.tar.gz nextcloud-server-bae133bf4f43b4815734b2c05c0263061cae2cfa.zip |
fix(AppDiscoverFetcher): Do not remove entries as expired that have no expiry date
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php b/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php index 48dba6d48dc..46a18eb4c32 100644 --- a/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php +++ b/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php @@ -61,41 +61,41 @@ class AppDiscoverFetcher extends Fetcher { /** * Get the app discover section entries * - * @param bool $allowUnstable Include also expired and upcoming entries + * @param bool $allowUnstable Include also upcoming entries */ public function get($allowUnstable = false) { $entries = parent::get(false); + $now = new DateTimeImmutable(); - if (!$allowUnstable) { - $now = new DateTimeImmutable(); - - // Remove expired or future entries - return array_filter($entries, function (array $entry) use ($now) { + return array_filter($entries, function (array $entry) use ($now, $allowUnstable) { + // Always remove expired entries + if (isset($entry['expiryDate'])) { try { - $date = new DateTimeImmutable($entry['date'] ?? ''); - if ($date > $now) { + $expiryDate = new DateTimeImmutable($entry['expiryDate']); + if ($expiryDate < $now) { return false; } } catch (\Throwable $e) { - // Invalid date format + // Invalid expiryDate format return false; } + } + // If not include upcoming entries, check for upcoming dates and remove those entries + if (!$allowUnstable && isset($entry['date'])) { try { - $expiryDate = new DateTimeImmutable($entry['expiryDate'] ?? ''); - if ($expiryDate < $now) { + $date = new DateTimeImmutable($entry['date']); + if ($date > $now) { return false; } } catch (\Throwable $e) { - // Invalid expiryDate format + // Invalid date format return false; } - - return true; - }); - } - - return $entries; + } + // Otherwise the entry is not time limited and should stay + return true; + }); } public function getETag(): string|null { |