mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
- fix cookie shortening
- let the acm handle the module cache - call $cache->save() after destroying data if necessary git-svn-id: file:///svn/phpbb/trunk@5612 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
b8834051eb
commit
b36c02f320
7 changed files with 48 additions and 50 deletions
|
@ -24,7 +24,7 @@ $use_shutdown_function = (@function_exists('register_shutdown_function')) ? true
|
|||
* Run cron-like action
|
||||
* Real cron-based layer will be introduced in 3.2
|
||||
*
|
||||
* @todo: check gc-intervals here too (important!)
|
||||
* @todo check gc-intervals here too (important!)
|
||||
*/
|
||||
switch ($cron_type)
|
||||
{
|
||||
|
|
|
@ -191,6 +191,9 @@ class acm
|
|||
$this->is_modified = true;
|
||||
unset($this->vars[$var_name]);
|
||||
unset($this->var_expires[$var_name]);
|
||||
|
||||
// We save here to let the following cache hits succeed
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ class cache extends acm
|
|||
|
||||
foreach ($parsed_items as $key => $parsed_array)
|
||||
{
|
||||
$parsed_array = $this->get('_' . $key . '_cfg');
|
||||
$parsed_array = $this->get('_cfg_' . $key);
|
||||
|
||||
if (!$parsed_array)
|
||||
{
|
||||
|
@ -327,14 +327,13 @@ class cache extends acm
|
|||
$parsed_array = parse_cfg_file($filename);
|
||||
$parsed_array['filetime'] = @filemtime($filename);
|
||||
|
||||
$this->put('_' . $key . '_cfg', $parsed_array);
|
||||
$this->put('_cfg_' . $key, $parsed_array);
|
||||
}
|
||||
$parsed_items[$key] = $parsed_array;
|
||||
}
|
||||
|
||||
return $parsed_items;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -749,15 +749,12 @@ class acp_modules
|
|||
*/
|
||||
function remove_cache_file()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
global $cache;
|
||||
|
||||
// Sanitise for future path use, it's escaped as appropriate for queries
|
||||
$p_class = str_replace(array('.', '/', '\\'), '', basename($this->module_class));
|
||||
|
||||
if (file_exists($phpbb_root_path . 'cache/' . $p_class . '_modules.' . $phpEx))
|
||||
{
|
||||
@unlink($phpbb_root_path . 'cache/' . $p_class . '_modules.' . $phpEx);
|
||||
}
|
||||
$cache->destroy('_modules_' . $p_class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -250,7 +250,6 @@ class dbal
|
|||
|
||||
/**
|
||||
* Explain queries
|
||||
* @child _sql_report
|
||||
*/
|
||||
function sql_report($mode, $query = '')
|
||||
{
|
||||
|
|
|
@ -112,7 +112,6 @@ function set_config($config_name, $config_value, $is_dynamic = false)
|
|||
if (!$is_dynamic)
|
||||
{
|
||||
$cache->destroy('config');
|
||||
$cache->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -691,25 +690,47 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0)
|
|||
$post_time = ($post_time) ? $post_time : time();
|
||||
$tracking['t'][$topic_id36] = base_convert($post_time - $config['board_startdate'], 10, 36);
|
||||
|
||||
// If the cookie grows larger than 5000 characters we will remove the smallest value
|
||||
if (isset($_COOKIE[$config['cookie_name'] . '_track']) && strlen($_COOKIE[$config['cookie_name'] . '_track']) > 5000)
|
||||
// If the cookie grows larger than 10000 characters we will remove the smallest value
|
||||
// This can result in old topics being unread - but most of the time it should be accurate...
|
||||
if (isset($_COOKIE[$config['cookie_name'] . '_track']) && strlen($_COOKIE[$config['cookie_name'] . '_track']) > 10000)
|
||||
{
|
||||
// echo 'Cookie grown too large' . print_r($tracking, true);
|
||||
//echo 'Cookie grown too large' . print_r($tracking, true);
|
||||
|
||||
// We get the ten most minimum stored time offsets and its associated topic ids
|
||||
$time_keys = array();
|
||||
for ($i = 0; $i < 10 && sizeof($tracking['t']); $i++)
|
||||
{
|
||||
$min_value = min($tracking['t']);
|
||||
$m_tkey = array_search($min_value, $t_ary);
|
||||
$m_tkey = array_search($min_value, $tracking['t']);
|
||||
unset($tracking['t'][$m_tkey]);
|
||||
|
||||
$time_keys[$m_tkey] = $min_value;
|
||||
}
|
||||
|
||||
// Now remove the topic ids from the array...
|
||||
foreach ($tracking['tf'] as $f_id => $topic_id_ary)
|
||||
{
|
||||
if (in_array($m_tkey, array_keys($topic_id_ary)))
|
||||
foreach ($time_keys as $m_tkey => $min_value)
|
||||
{
|
||||
if (isset($topic_id_ary[$m_tkey]))
|
||||
{
|
||||
$tracking['f'][$f_id] = $min_value;
|
||||
unset($tracking['tf'][$f_id][$m_tkey]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->data['is_registered'])
|
||||
{
|
||||
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . intval(base_convert(max($time_keys) + $config['board_startdate'], 36, 10)) . " WHERE user_id = {$user->data['user_id']}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$tracking['l'] = max($time_keys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$user->set_cookie('track', serialize($tracking), time() + 31536000);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
/**
|
||||
* Class handling all types of 'plugins' (a future term)
|
||||
* @package phpBB3
|
||||
*/
|
||||
class p_master
|
||||
{
|
||||
|
@ -44,31 +45,19 @@ class p_master
|
|||
*/
|
||||
function list_modules($p_class)
|
||||
{
|
||||
global $auth, $db, $user;
|
||||
global $auth, $db, $user, $cache;
|
||||
global $config, $phpbb_root_path, $phpEx;
|
||||
|
||||
$get_cache_data = true;
|
||||
|
||||
// Empty cached contents
|
||||
$this->module_cache = array();
|
||||
|
||||
// Sanitise for future path use, it's escaped as appropriate for queries
|
||||
$this->p_class = str_replace(array('.', '/', '\\'), '', basename($p_class));
|
||||
|
||||
if (file_exists($phpbb_root_path . 'cache/' . $this->p_class . '_modules.' . $phpEx))
|
||||
// Get cached modules
|
||||
if (!($this->module_cache = $cache->get('_modules_' . $this->p_class)))
|
||||
{
|
||||
include($phpbb_root_path . 'cache/' . $this->p_class . '_modules.' . $phpEx);
|
||||
$get_cache_data = false;
|
||||
}
|
||||
|
||||
if ($get_cache_data)
|
||||
{
|
||||
global $cache;
|
||||
|
||||
// Get modules
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_class = '" . $db->sql_escape($p_class) . "'
|
||||
WHERE module_class = '" . $db->sql_escape($this->p_class) . "'
|
||||
ORDER BY left_id ASC";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
|
@ -87,17 +76,7 @@ class p_master
|
|||
}
|
||||
unset($rows);
|
||||
|
||||
$file = '<?php $this->module_cache=' . $cache->format_array($this->module_cache) . "; ?>";
|
||||
|
||||
if ($fp = @fopen($phpbb_root_path . 'cache/' . $this->p_class . '_modules.' . $phpEx, 'wb'))
|
||||
{
|
||||
@flock($fp, LOCK_EX);
|
||||
fwrite($fp, $file);
|
||||
@flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
unset($file);
|
||||
$cache->put('_modules_' . $this->p_class, $this->module_cache);
|
||||
}
|
||||
|
||||
// We "could" build a true tree with this function - maybe mod authors want to use this...
|
||||
|
|
Loading…
Add table
Reference in a new issue