Remove folder typedata in-memory cache

Summary:
This caused the syncroton Ping command to miss new task folders.
Because the Ping command is long running we use:

    rcube::get_instance()->get_storage()->clear_cache('mailboxes', true);

To clear the cache before listing the folders. However, this doesn't
clear the in-memory cache in kolab_storage.

In list_folders we then ended up in the branch returning the folder list directly from
that outdated in-memory cache and thus missed the update.

Since we already cache the folder list and metadata it doesn't seem necessary to
cache it again. Removing it thus gives us a single place to invalidate it.

Differential Revision: https://git.kolab.org/D2143
This commit is contained in:
Christian Mollekopf 2021-01-21 09:42:40 +01:00
parent d4c00a9555
commit b4b3a48893

View file

@ -47,7 +47,6 @@ class kolab_storage
private static $with_tempsubs = true;
private static $subscriptions;
private static $ldapcache = array();
private static $typedata = array();
private static $ldap = array();
private static $states;
private static $config;
@ -869,7 +868,8 @@ class kolab_storage
return array();
}
// In some conditions we can skip LIST command (?)
// If we only want groupware folders and don't care about the subscription state,
// then the metadata will already contain all folder names and we can avoid the LIST below.
if (!$subscribed && $filter != 'mail' && $prefix == '*') {
foreach ($folderdata as $folder => $type) {
if (!preg_match($regexp, $type)) {
@ -1106,11 +1106,6 @@ class kolab_storage
return false;
}
// return cached result
if (is_array(self::$typedata[$prefix])) {
return self::$typedata[$prefix];
}
$type_keys = array(self::CTYPE_KEY, self::CTYPE_KEY_PRIVATE);
// fetch metadata from *some* folders only
@ -1153,10 +1148,7 @@ class kolab_storage
return false;
}
// keep list in memory
self::$typedata[$prefix] = array_map(array('kolab_storage', 'folder_select_metadata'), $folderdata);
return self::$typedata[$prefix];
return array_map(array('kolab_storage', 'folder_select_metadata'), $folderdata);
}
/**
@ -1185,13 +1177,6 @@ class kolab_storage
{
self::setup();
// return in-memory cached result
foreach (self::$typedata as $typedata) {
if (array_key_exists($folder, $typedata)) {
return $typedata[$folder];
}
}
$metadata = self::$imap->get_metadata($folder, array(self::CTYPE_KEY, self::CTYPE_KEY_PRIVATE));
if (!is_array($metadata)) {