forked from extern/egroupware
Caching has been reworked and added back in.
This commit is contained in:
parent
12d0ce51e9
commit
f069e2fb06
@ -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."<br>\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);
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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 *
|
||||
\************************************************************************/
|
||||
|
@ -103,3 +103,9 @@
|
||||
<td>Would like like phpGroupWare to check for new version<br>when admins login ?:</td>
|
||||
<td><input type="checkbox" name="newsettings[checkfornewversion]" value="True"<?php echo ($current_config["checkfornewversion"]?" checked":""); ?>></td>
|
||||
</tr>
|
||||
|
||||
<tr bgcolor="e6e6e6">
|
||||
<td>Would like like phpGroupWare to cache the phpgw_info array ?:</td>
|
||||
<td><input type="checkbox" name="newsettings[cache_phpgw_info]" value="True"<?php echo ($current_config["cache_phpgw_info"]?" checked":""); ?>></td>
|
||||
</tr>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user