From 301e71f4326e1336cbea85ba6f48d62b51ab19e0 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 5 Aug 2014 09:14:04 +0000 Subject: [PATCH] introduce some stuff to increase inital speed of mail-list by asyncronously calling gatherVacation and getQuotaRoot; increase cache-time on folderExists cache, trust a folder to be existant (or at least fot force the check with IMAP-Server) in get_rows --- .../inc/class.emailadmin_imapbase.inc.php | 21 +++++++-- mail/inc/class.mail_hooks.inc.php | 46 +------------------ mail/inc/class.mail_ui.inc.php | 18 ++++---- 3 files changed, 28 insertions(+), 57 deletions(-) diff --git a/emailadmin/inc/class.emailadmin_imapbase.inc.php b/emailadmin/inc/class.emailadmin_imapbase.inc.php index 73ae6965ef..1159d71b73 100644 --- a/emailadmin/inc/class.emailadmin_imapbase.inc.php +++ b/emailadmin/inc/class.emailadmin_imapbase.inc.php @@ -466,6 +466,7 @@ class emailadmin_imapbase * 1) icServerIMAP_connectionError * 2) icServerSIEVE_connectionError * 3) INSTANCE OF MAIL_BO + * 4) HierarchyDelimiter * * @param int $_profileID=null default profile of user as returned by getUserDefaultProfileID * @return void @@ -483,6 +484,12 @@ class emailadmin_imapbase unset($rawHeadersCache[$_profileID]); egw_cache::setCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$rawHeadersCache, $expiration=60*60*1); } + $HierarchyDelimiterCache = egw_cache::getCache(egw_cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*24*5); + if (isset($HierarchyDelimiterCache[$_profileID])) + { + unset($HierarchyDelimiterCache[$_profileID]); + egw_cache::setCache(egw_cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),$HierarchyDelimiterCache, $expiration=60*60*24*5); + } //reset folderObject cache, to trigger reload self::resetFolderObjectCache($_profileID); //reset counter of deleted messages per folder @@ -556,7 +563,7 @@ class emailadmin_imapbase { unset($folders2return[$_ImapServerId]); } - $folderInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*5); + $folderInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); if (isset($folderInfo[$_ImapServerId])) { unset($folderInfo[$_ImapServerId]); @@ -581,7 +588,7 @@ class emailadmin_imapbase } } egw_cache::setCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return, $expiration=60*60*1); - egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*5); + egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); //egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFolderUsedForMove,$expiration=60*60*1); egw_cache::setCache(egw_cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders,$expiration=60*60*12); @@ -2098,6 +2105,8 @@ class emailadmin_imapbase { throw new egw_exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage());; } + // clear FolderExistsInfoCache + egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); return $newFolderName; @@ -2122,6 +2131,8 @@ class emailadmin_imapbase { throw new egw_exception("Deleting Folder $_foldername failed! Error:".$e->getMessage());; } + // clear FolderExistsInfoCache + egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); return true; } @@ -3049,9 +3060,9 @@ class emailadmin_imapbase if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); return false; } - // reduce traffic within the Instance per User; Expire every 5 Minutes + // reduce traffic within the Instance per User; Expire every 5 hours //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); - if (is_null($folderInfo)) $folderInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*5); + if (is_null($folderInfo)) $folderInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) { @@ -3090,7 +3101,7 @@ class emailadmin_imapbase { $folderInfo[$this->profileID][$_folder] = false; // set to false, whatever it was (to have a valid returnvalue for the static return) } - egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*5); + egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); return (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) ? $folderInfo[$this->profileID][$_folder] : false); } diff --git a/mail/inc/class.mail_hooks.inc.php b/mail/inc/class.mail_hooks.inc.php index 1f564b30a0..8d83d5b788 100644 --- a/mail/inc/class.mail_hooks.inc.php +++ b/mail/inc/class.mail_hooks.inc.php @@ -513,6 +513,7 @@ class mail_hooks unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); $appname = 'mail'; $menu_title = $GLOBALS['egw_info']['apps'][$appname]['title'] . ' '. lang('Menu'); +/* $file = array(); $profileID = 0; if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) @@ -545,6 +546,7 @@ class mail_hooks //error_log(__METHOD__.__LINE__.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); } } +*/ $file=array(); // Destination div for folder tree $file[] = array( @@ -584,51 +586,7 @@ class mail_hooks } // display them all display_sidebox($appname,$menu_title,$file); -/* - unset($file); - if ($preferences && $sieveEnabledServerCounter) - { - $menu_title = lang('Sieve'); - $linkData = array - ( - 'menuaction' => 'mail.mail_sieve.index', - 'ajax' => 'true' - ); - if(empty($preferences['prefpreventeditfilterrules']) || $preferences['prefpreventeditfilterrules'] == 0) - $file['filter rules'] = egw::link('/index.php',$linkData); - $linkData = array - ( - 'menuaction' => 'mail.mail_sieve.editVacation', - 'ajax' => 'true' - ); - if(empty($preferences['prefpreventabsentnotice']) || $preferences['prefpreventabsentnotice'] == 0) - { - $file['vacation notice'] = egw::link('/index.php',$linkData); - } - if((empty($preferences['prefpreventnotificationformailviaemail']) || - $preferences['prefpreventnotificationformailviaemail'] == 0)) - { - $file['email notification'] = egw::link('/index.php','menuaction=mail.mail_sieve.editEmailNotification&ajax=true'); //Added email notifications - } - if ($sieveEnabledServerCounter>=1) - { - if($sieveEnabledServerCounter==1 && ($icServer instanceof defaultimap)) { - if($icServer->enableSieve) - { - if (count($file)) display_sidebox($appname,$menu_title,$file); - unset($file); - } - } - else - { - if (count($file)) display_sidebox($appname,$menu_title,$file); - unset($file); - } - } - - } -*/ if ($GLOBALS['egw_info']['user']['apps']['admin']) { $file = Array( diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index db11b4467a..1c9af7e2d8 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -440,9 +440,8 @@ class mail_ui unset($msg); unset($content['msg']); } - - $quota = $this->mail_bo->getQuotaRoot(); - + // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip + $quota = false;//$this->mail_bo->getQuotaRoot(); if($quota !== false && $quota['limit'] != 'NOT SET') { $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; @@ -454,8 +453,8 @@ class mail_ui $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone"; $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; } - - $vacation = $this->gatherVacation(); + // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip + $vacation = false;//$this->gatherVacation(); //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); if($vacation) { if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) @@ -1478,13 +1477,13 @@ class mail_ui //save selected Folder to sessionData (mailbox)->currentFolder if (isset($query['selectedFolder'])) $this->mail_bo->sessionData['mailbox']=$_folderName; $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) - if ($this->mail_bo->folderExists($_folderName,true)) + if ($this->mail_bo->folderExists($_folderName)) { $toSchema = $this->mail_bo->isDraftFolder($_folderName)||$this->mail_bo->isSentFolder($_folderName)||$this->mail_bo->isTemplateFolder($_folderName); } else { - error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead'); + //error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead'); $query['selectedFolder']=$this->mail_bo->sessionData['mailbox']=$_folderName='INBOX'; } $this->mail_bo->saveSessionData(); @@ -1576,13 +1575,16 @@ class mail_ui $sR=array(); self::callWizard($e->getMessage(), false); } + $response = egw_json_response::get(); // unlock immediately after fetching the rows if (stripos($_GET['menuaction'],'ajax_get_rows')!==false) { //error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']); - $response = egw_json_response::get(); $response->call('app.mail.unlock_tree'); } + // done asynchronously initiating a client->server roundtrip to save time on the initial call + $response->call('app.mail.mail_callRefreshVacationNotice',$this->mail_bo->profileID); + $response->call('app.mail.mail_refreshQuotaDisplay',$this->mail_bo->profileID); if (is_array($sR) && count($sR)>0) { foreach ((array)$sR as $key => $v)