* All apps: run link notifications after processing and returning control to user to speed up saving of entries with links to (big) projects

This commit is contained in:
Ralf Becker 2014-02-20 11:29:51 +00:00
parent 1297c32fb2
commit a7f65672c8
2 changed files with 34 additions and 5 deletions

View File

@ -393,7 +393,7 @@ class asyncservice
{ {
return False; // cant obtain semaphore return False; // cant obtain semaphore
} }
if ($jobs = $this->read()) if (($jobs = $this->read()))
{ {
foreach($jobs as $id => $job) foreach($jobs as $id => $job)
{ {
@ -401,6 +401,8 @@ class asyncservice
// //
if ($GLOBALS['egw_info']['user']['account_id'] != $job['account_id']) if ($GLOBALS['egw_info']['user']['account_id'] != $job['account_id'])
{ {
// run notifications, before changing account_id of enviroment
egw_link::run_notifies();
// unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data
foreach($GLOBALS as $name => $value) foreach($GLOBALS as $name => $value)
{ {
@ -410,7 +412,7 @@ class asyncservice
$lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
unset($GLOBALS['egw_info']['user']); unset($GLOBALS['egw_info']['user']);
if ($GLOBALS['egw']->session->account_id = $job['account_id']) if (($GLOBALS['egw']->session->account_id = $job['account_id']))
{ {
$GLOBALS['egw']->session->account_lid = $GLOBALS['egw']->accounts->id2name($job['account_id']); $GLOBALS['egw']->session->account_lid = $GLOBALS['egw']->accounts->id2name($job['account_id']);
$GLOBALS['egw']->session->account_domain = $domain; $GLOBALS['egw']->session->account_domain = $domain;

View File

@ -251,14 +251,18 @@ class egw_link extends solink
} }
/** /**
* Called by egw::egw_final to store the title-cache in the session * Called by egw::shutdown to store the title-cache in session and run notifications
* *
* Would probably better called shutdown as well.
*/ */
static function save_session_cache() static function save_session_cache()
{ {
//error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache)); //error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache));
$GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi',self::$title_cache); $GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi',self::$title_cache);
$GLOBALS['egw']->session->appsession('link_file_access_cache','phpgwapi',self::$file_access_cache); $GLOBALS['egw']->session->appsession('link_file_access_cache','phpgwapi',self::$file_access_cache);
// send out notifications about added, changed or removed links
self::run_notifies();
} }
/** /**
@ -1342,6 +1346,13 @@ class egw_link extends solink
self::delete_cache($app,$id); self::delete_cache($app,$id);
} }
/**
* Stores notifications to run after regular processing is done
*
* @var array
*/
private static $notifies = array();
/** /**
* notify an application about a new or deleted links to own entries or updates in the content of the linked entry * notify an application about a new or deleted links to own entries or updates in the content of the linked entry
* *
@ -1359,17 +1370,33 @@ class egw_link extends solink
{ {
if ($link_id && isset(self::$app_register[$notify_app]) && isset(self::$app_register[$notify_app]['notify'])) if ($link_id && isset(self::$app_register[$notify_app]) && isset(self::$app_register[$notify_app]['notify']))
{ {
ExecMethod(self::$app_register[$notify_app]['notify'],array( self::$notifies[] = array(
'method' => self::$app_register[$notify_app]['notify'],
'type' => $type, 'type' => $type,
'id' => $notify_id, 'id' => $notify_id,
'target_app' => $target_app, 'target_app' => $target_app,
'target_id' => $target_id, 'target_id' => $target_id,
'link_id' => $link_id, 'link_id' => $link_id,
'data' => $data, 'data' => $data,
)); );
} }
} }
/**
* Run notifications called by egw_link::save_session_cache from egw::shutdown, after regular processing is finished
*/
static public function run_notifies()
{
foreach(self::$notifies as $args)
{
$method = $args['method'];
unset($args['method']);
//error_log(__METHOD__."() calling $method(".array2string($args).')');
ExecMethod($method, $args);
}
self::$notifies = array();
}
/** /**
* notifies about unlinked links * notifies about unlinked links
* *