do not use Session to cache HierarchyDelimiter; remove all logic and rely on mail account object for folder info on special use folders in function emailadmin_imapbase->getSpecialUseFolders; code cleanup for cache-cleanup

This commit is contained in:
Klaus Leithoff 2014-08-04 13:04:44 +00:00
parent 9bba24a40c
commit 2fcb09d458

View File

@ -465,10 +465,7 @@ class emailadmin_imapbase
* *
* 1) icServerIMAP_connectionError * 1) icServerIMAP_connectionError
* 2) icServerSIEVE_connectionError * 2) icServerSIEVE_connectionError
* 3) defaultimap_nameSpace * 3) INSTANCE OF MAIL_BO
* 4) StructureCache (emailStructure Objects)
* 5) SummaryCache (emailSummary Objects)
* 6) INSTANCE OF MAIL_BO
* *
* @param int $_profileID=null default profile of user as returned by getUserDefaultProfileID * @param int $_profileID=null default profile of user as returned by getUserDefaultProfileID
* @return void * @return void
@ -480,18 +477,6 @@ class emailadmin_imapbase
if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false)))
{ {
self::resetConnectionErrorCache($_profileID); self::resetConnectionErrorCache($_profileID);
$structure = egw_cache::getCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($structure[$_profileID]))
{
unset($structure[$_profileID]);
egw_cache::setCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$structure, $expiration=60*60*1);
}
$summary = egw_cache::getCache(egw_cache::INSTANCE,'email','summaryCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($summary[$_profileID]))
{
unset($summary[$_profileID]);
egw_cache::setCache(egw_cache::INSTANCE,'email','summaryCache'.trim($GLOBALS['egw_info']['user']['account_id']),$summary, $expiration=60*60*1);
}
$rawHeadersCache = egw_cache::getCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1); $rawHeadersCache = egw_cache::getCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($rawHeadersCache[$_profileID])) if (isset($rawHeadersCache[$_profileID]))
{ {
@ -508,12 +493,6 @@ class emailadmin_imapbase
egw_cache::setCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, $expiration=60*60*1); egw_cache::setCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, $expiration=60*60*1);
} }
$nameSpace = egw_cache::getSession('email','defaultimap_nameSpace');
if (isset($nameSpace[$_profileID]))
{
unset($nameSpace[$_profileID]);
egw_cache::setSession('email','defaultimap_nameSpace',$nameSpace);
}
if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]);
} }
} }
@ -984,67 +963,25 @@ class emailadmin_imapbase
//error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected);
static $_specialUseFolders; static $_specialUseFolders;
if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = egw_cache::getCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*24*5); if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = egw_cache::getCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*24*5);
if (isset($_specialUseFolders[$this->icServer->ImapServerId]) &&!empty($_specialUseFolders[$this->icServer->ImapServerId])) //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash));
{ //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent));
if(($this->icServer instanceof defaultimap)) //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft));
{ //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template));
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($specialUseFolders[$this->icServer->ImapServerId])); self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
// array('Drafts', 'Templates', 'Sent', 'Trash', 'Junk', 'Outbox'); if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId]))
if (empty($this->icServer->acc_folder_trash) && ($f = array_search('Trash',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_trash = $f;
if (empty($this->icServer->acc_folder_draft) && ($f = array_search('Drafts',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_draft = $f;
if (empty($this->icServer->acc_folder_sent) && ($f = array_search('Sent',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_sent = $f;
if (empty($this->icServer->acc_folder_template) && ($f = array_search('Templates',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_template = $f;
}
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; // make sure this one is set on function call
return $_specialUseFolders[$this->icServer->ImapServerId]; return $_specialUseFolders[$this->icServer->ImapServerId];
} $_specialUseFolders[$this->icServer->ImapServerId]=array();
if(($this->icServer instanceof defaultimap) ) //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]))
{ $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash';
//error_log(__METHOD__.' ('.__LINE__.') '); //if (!empty($this->icServer->acc_folder_draft) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]))
if(($this->hasCapability('SPECIAL-USE'))) $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]='Drafts';
{ //if (!empty($this->icServer->acc_folder_sent) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]))
//error_log(__METHOD__.' ('.__LINE__.') '); $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]='Sent';
try //if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]))
{ $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates';
// do not query IMAP Server for SPECIAL-USE Folders, as we assume thev wizard already did that //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer));
$ret = null;//$this->icServer->getSpecialUseFolders(); self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
} catch (Exception $e) egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, $expiration=60*60*24*5);
{
$ret=null;
}
if (empty($ret))
{
$_specialUseFolders[$this->icServer->ImapServerId]=array();
if (!empty($this->icServer->acc_folder_trash)) $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash';
if (!empty($this->icServer->acc_folder_draft)) $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]='Drafts';
if (!empty($this->icServer->acc_folder_sent)) $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]='Sent';
if (!empty($this->icServer->acc_folder_template)) $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates';
}
else
{
foreach ($ret as $k => $f)
{
if (isset($f['ATTRIBUTES']) && !empty($f['ATTRIBUTES']) &&
!in_array('\\nonexistent',$f['ATTRIBUTES']))
{
foreach (self::$autoFolders as $i => $n) // array('Drafts', 'Templates', 'Sent', 'Trash', 'Junk', 'Outbox');
{
if (in_array('\\'.strtolower($n),$f['ATTRIBUTES'])) $_specialUseFolders[$this->icServer->ImapServerId][$f['MAILBOX']] = $n;
}
}
}
}
egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, $expiration=60*60*24*5);
}
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
if (empty($this->icServer->acc_folder_trash) && ($f = array_search('Trash',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_trash = $f;
if (empty($this->icServer->acc_folder_draft) && ($f = array_search('Drafts',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_draft = $f;
if (empty($this->icServer->acc_folder_sent) && ($f = array_search('Sent',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_sent = $f;
if (empty($this->icServer->acc_folder_template) && ($f = array_search('Templates',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_template = $f;
}
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; // make sure this one is set on function call
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
return $_specialUseFolders[$this->icServer->ImapServerId]; return $_specialUseFolders[$this->icServer->ImapServerId];
} }