fix(config): refresh a category cache stored with another type
If cache-categories was stored with a type other than mixed or array, for example set by hand with occ, the typed read throws. Treat that as a missing cache so it is refreshed instead of breaking the menu and the settings page.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace OCA\SideMenu\Service;
|
|||||||
use OC\App\AppStore\Fetcher\CategoryFetcher;
|
use OC\App\AppStore\Fetcher\CategoryFetcher;
|
||||||
use OCA\SideMenu\AppInfo\Application;
|
use OCA\SideMenu\AppInfo\Application;
|
||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
|
use OCP\Exceptions\AppConfigTypeConflictException;
|
||||||
use OCP\IAppConfig;
|
use OCP\IAppConfig;
|
||||||
use OCP\ICache;
|
use OCP\ICache;
|
||||||
use OCP\ICacheFactory;
|
use OCP\ICacheFactory;
|
||||||
@@ -137,7 +138,12 @@ class CategoryRepository
|
|||||||
return $categories;
|
return $categories;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$stored = $this->appConfig->getValueArray(Application::APP_ID, self::CACHE_KEY, [], lazy: true);
|
try {
|
||||||
|
$stored = $this->appConfig->getValueArray(Application::APP_ID, self::CACHE_KEY, [], lazy: true);
|
||||||
|
} catch (AppConfigTypeConflictException) {
|
||||||
|
// Stored with another type, e.g. set by hand; refreshed below
|
||||||
|
$stored = [];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($stored['expires'], $stored['categories']) && $stored['expires'] > $this->timeFactory->getTime()) {
|
if (isset($stored['expires'], $stored['categories']) && $stored['expires'] > $this->timeFactory->getTime()) {
|
||||||
return $stored['categories'];
|
return $stored['categories'];
|
||||||
|
|||||||
Reference in New Issue
Block a user