diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php
index 8991606141..9c01efc673 100644
--- a/phpgwapi/inc/class.preferences.inc.php
+++ b/phpgwapi/inc/class.preferences.inc.php
@@ -69,6 +69,7 @@
$this->db->query("SELECT preference_value FROM phpgw_preferences WHERE preference_owner='".$this->account_id."'",__LINE__,__FILE__);
$this->db->next_record();
$pref_info = $this->db->f("preference_value");
+//echo "Pref_Info = ".$pref_info."
\n";
$this->data = Array();
$this->data = unserialize($pref_info);
$this->db->unlock();
@@ -144,13 +145,14 @@
{
global $phpgw, $phpgw_info;
+ $temp_data = $this->data;
if (! $phpgw->acl->check('session_only_preferences',1,'preferences'))
{
$this->db->transaction_begin();
$this->db->query("delete from phpgw_preferences where preference_owner='" . $this->account_id
. "'",__LINE__,__FILE__);
-
- if (phpversion() < "4.0.0")
+
+ if (floor(phpversion()) < 4)
{
$pref_info = addslashes(serialize($this->data));
}
@@ -158,7 +160,6 @@
{
$pref_info = serialize($this->data);
}
-
$this->db->query("insert into phpgw_preferences (preference_owner,preference_value) values ('"
. $this->account_id . "','" . $pref_info . "')",__LINE__,__FILE__);
@@ -170,13 +171,12 @@
$phpgw->session->save_repositories();
}
-/* if ($phpgw_info['server']['cache_phpgw_info'])
+ if ($phpgw_info['server']['cache_phpgw_info'] && $this->account_id == $phpgw_info['user']['account_id'])
{
- $phpgw->session->session_flags = 'U';
- $phpgw->session->update_session_flags();
- } */
-
- return $this->data;
+ $phpgw->session->read_repositories(False);
+ }
+
+ return $temp_data;
}
/*!
@@ -199,7 +199,7 @@
{
return $this->add($app_name,$var,$value);
}
- function commit($update_session_info = False)
+ function commit($update_session_info = True)
{
return $this->save_repository($update_session_info);
}
diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php
index 8e3a9903c4..90ab58b776 100644
--- a/phpgwapi/inc/class.sessions.inc.php
+++ b/phpgwapi/inc/class.sessions.inc.php
@@ -124,7 +124,7 @@
$phpgw_info['user']['account_id'] = $this->account_id;
- $this->read_repositories();
+ $this->read_repositories($phpgw_info['server']['cache_phpgw_info']);
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
{
return False;
@@ -245,7 +245,7 @@
unset ($phpgw_info['server']['default_domain']); // we kill this for security reasons
}
- $this->read_repositories();
+ $this->read_repositories(False);
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
{
return False;
@@ -325,20 +325,43 @@
/*************************************************************************\
* Functions for appsession data and session cache *
\*************************************************************************/
- function read_repositories()
+ function read_repositories($cached='')
{
global $phpgw, $phpgw_info;
$phpgw->acl->acl($this->account_id);
$phpgw->accounts->accounts($this->account_id);
$phpgw->preferences->preferences($this->account_id);
$phpgw->applications->applications($this->account_id);
-
+
+ if(@$cached)
+ {
+ $this->user = $this->appsession('phpgw_info_cache','phpgwapi');
+ if(!empty($this->user))
+ {
+ $phpgw->preferences->data = $this->user['preferences'];
+ }
+ else
+ {
+ $this->setup_cache();
+ }
+ }
+ else
+ {
+ $this->setup_cache();
+ }
+ $this->hooks = $phpgw->hooks->read();
+ }
+
+ function setup_cache()
+ {
+ global $phpgw, $phpgw_info;
+
$this->user = $phpgw->accounts->read_repository();
$this->user['acl'] = $phpgw->acl->read_repository();
$this->user['preferences'] = $phpgw->preferences->read_repository();
$this->user['apps'] = $phpgw->applications->read_repository();
//@reset($this->data['user']['apps']);
-
+
$this->user['domain'] = $this->account_domain;
$this->user['sessionid'] = $this->sessionid;
$this->user['kp3'] = $this->kp3;
@@ -348,7 +371,10 @@
$this->user['account_lid'] = $this->account_lid;
$this->user['userid'] = $this->account_lid;
$this->user['passwd'] = @$this->passwd;
- $this->hooks = $phpgw->hooks->read();
+ if(@$phpgw_info['server']['cache_phpgw_info'])
+ {
+ $this->appsession('phpgw_info_cache','phpgwapi',$this->user);
+ }
}
function save_repositories()
diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php
index 01c714668d..6d7aad36c4 100644
--- a/phpgwapi/inc/functions.inc.php
+++ b/phpgwapi/inc/functions.inc.php
@@ -271,12 +271,54 @@
$phpgw->db->Halt_On_Error = 'yes';
/* Fill phpgw_info["server"] array */
- $phpgw->db->query("select * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__);
- while ($phpgw->db->next_record())
+// An Attempt to speed things up using cache premise
+ $phpgw->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info'",__LINE__,__FILE__);
+ if ($phpgw->db->num_rows())
{
- $phpgw_info['server'][$phpgw->db->f('config_name')] = stripslashes($phpgw->db->f('config_value'));
+ $phpgw_info['server']['cache_phpgw_info'] = stripslashes($phpgw->db->f('config_value'));
}
+ $cache_query = "select content from phpgw_app_sessions where"
+ ." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
+
+ $phpgw->db->query($cache_query,__LINE__,__FILE__);
+ $server_info_cache = $phpgw->db->num_rows();
+
+ if(@$phpgw_info['server']['cache_phpgw_info'] && $server_info_cache)
+ {
+ $cache_query = "select content from phpgw_app_sessions where"
+ ." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
+
+ $phpgw->db->query($cache_query,__LINE__,__FILE__);
+ $phpgw->db->next_record();
+
+ $phpgw_info['server'] = unserialize(stripslashes($phpgw->db->f('content')));
+ }
+ else
+ {
+ $phpgw->db->query("select * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__);
+ while ($phpgw->db->next_record())
+ {
+ $phpgw_info['server'][$phpgw->db->f('config_name')] = stripslashes($phpgw->db->f('config_value'));
+ }
+
+ if($phpgw_info['server']['cache_phpgw_info'])
+ {
+ if($server_info_cache)
+ {
+ $cache_query = "UPDATE phpgw_app_sessions set content='".addslashes(serialize($phpgw_info['server']))."'"
+ ." WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
+ }
+ else
+ {
+ $cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
+ . "'0','0','phpgwapi','config','".addslashes(serialize($phpgw_info['server']))."')";
+ }
+ }
+ $phpgw->db->query($cache_query,__LINE__,__FILE__);
+ }
+ unset($cache_query);
+ unset($server_info_cache);
/************************************************************************\
* Required classes *
\************************************************************************/
diff --git a/preferences/setup/config.inc.php b/preferences/setup/config.inc.php
index 010f91c26b..49d0ef95ec 100644
--- a/preferences/setup/config.inc.php
+++ b/preferences/setup/config.inc.php
@@ -103,3 +103,9 @@