mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Re-jiggle where acl_option caching is done, move to common in-keeping with config
git-svn-id: file:///svn/phpbb/trunk@3341 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
8c31649706
commit
5bea3ea3b4
2 changed files with 48 additions and 125 deletions
|
@ -37,7 +37,6 @@ if ( !get_magic_quotes_gpc() )
|
||||||
}
|
}
|
||||||
|
|
||||||
require($phpbb_root_path . 'config.'.$phpEx);
|
require($phpbb_root_path . 'config.'.$phpEx);
|
||||||
//require($phpbb_root_path . 'config_cache.'.$phpEx);
|
|
||||||
|
|
||||||
if (!defined('PHPBB_INSTALLED'))
|
if (!defined('PHPBB_INSTALLED'))
|
||||||
{
|
{
|
||||||
|
@ -47,10 +46,10 @@ if ( !defined('PHPBB_INSTALLED') )
|
||||||
|
|
||||||
// Include files
|
// Include files
|
||||||
require($phpbb_root_path . 'includes/acm/cache_' . $acm_type . '.'.$phpEx);
|
require($phpbb_root_path . 'includes/acm/cache_' . $acm_type . '.'.$phpEx);
|
||||||
|
require($phpbb_root_path . 'db/' . $dbms . '.'.$phpEx);
|
||||||
require($phpbb_root_path . 'includes/template.'.$phpEx);
|
require($phpbb_root_path . 'includes/template.'.$phpEx);
|
||||||
require($phpbb_root_path . 'includes/session.'.$phpEx);
|
require($phpbb_root_path . 'includes/session.'.$phpEx);
|
||||||
require($phpbb_root_path . 'includes/functions.'.$phpEx);
|
require($phpbb_root_path . 'includes/functions.'.$phpEx);
|
||||||
require($phpbb_root_path . 'db/' . $dbms . '.'.$phpEx);
|
|
||||||
|
|
||||||
// User related
|
// User related
|
||||||
define('ANONYMOUS', 0);
|
define('ANONYMOUS', 0);
|
||||||
|
@ -90,10 +89,6 @@ define('POST_ANNOUNCE', 2);
|
||||||
define('LASTREAD_NORMAL', 0); // not used at the moment
|
define('LASTREAD_NORMAL', 0); // not used at the moment
|
||||||
define('LASTREAD_POSTED', 1);
|
define('LASTREAD_POSTED', 1);
|
||||||
|
|
||||||
// Error codes
|
|
||||||
define('MESSAGE', 200);
|
|
||||||
define('ERROR', 201);
|
|
||||||
|
|
||||||
// Private messaging
|
// Private messaging
|
||||||
define('PRIVMSGS_READ_MAIL', 0);
|
define('PRIVMSGS_READ_MAIL', 0);
|
||||||
define('PRIVMSGS_NEW_MAIL', 1);
|
define('PRIVMSGS_NEW_MAIL', 1);
|
||||||
|
@ -140,7 +135,7 @@ define('USERS_TABLE', $table_prefix.'users');
|
||||||
define('WORDS_TABLE', $table_prefix.'words');
|
define('WORDS_TABLE', $table_prefix.'words');
|
||||||
define('POLL_OPTIONS_TABLE', $table_prefix.'poll_results');
|
define('POLL_OPTIONS_TABLE', $table_prefix.'poll_results');
|
||||||
define('POLL_VOTES_TABLE', $table_prefix.'poll_voters');
|
define('POLL_VOTES_TABLE', $table_prefix.'poll_voters');
|
||||||
|
// Unnecessary
|
||||||
define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
|
define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
|
||||||
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
|
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
|
||||||
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
|
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
|
||||||
|
@ -148,64 +143,61 @@ define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
|
||||||
// Set PHP error handler to ours
|
// Set PHP error handler to ours
|
||||||
set_error_handler('msg_handler');
|
set_error_handler('msg_handler');
|
||||||
|
|
||||||
// Experimental cache manager
|
// Instantiate some basic classes
|
||||||
$cache = new acm();
|
$user = new user();
|
||||||
|
$auth = new auth();
|
||||||
|
|
||||||
// Need these here so instantiate them now
|
// Need these here so instantiate them now
|
||||||
|
$cache = new acm();// Experimental cache manager
|
||||||
$template = new Template();
|
$template = new Template();
|
||||||
$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
|
||||||
|
|
||||||
/*
|
// Grab global variables, re-cache if necessary
|
||||||
// Obtain boardwide default config (rebuilding cache if reqd)
|
if (!($config = $cache->get('config')))
|
||||||
if ( empty($config) )
|
|
||||||
{
|
|
||||||
require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
|
||||||
$config = config_config();
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "SELECT *
|
|
||||||
FROM " . CONFIG_TABLE . "
|
|
||||||
WHERE is_dynamic = 1";
|
|
||||||
$result = $db->sql_query($sql, false);
|
|
||||||
|
|
||||||
while ( $row = $db->sql_fetchrow($result) )
|
|
||||||
{
|
|
||||||
$config[$row['config_name']] = $row['config_value'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-cache acl options if reqd
|
|
||||||
if ( empty($acl_options) )
|
|
||||||
{
|
|
||||||
require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
|
||||||
$auth_admin = new auth_admin();
|
|
||||||
$acl_options = $auth_admin->acl_cache_options();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!$config = $cache->get('config'))
|
|
||||||
{
|
{
|
||||||
$config = array();
|
$config = array();
|
||||||
|
|
||||||
$sql = 'SELECT * FROM ' . CONFIG_TABLE;
|
/*
|
||||||
|
WHERE is_dynamic = 1';
|
||||||
|
*/
|
||||||
|
$sql = 'SELECT *
|
||||||
|
FROM ' . CONFIG_TABLE;
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$config[$row['config_name']] = $row['config_value'];
|
$config[$row['config_name']] = $row['config_value'];
|
||||||
}
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
$cache->put('config', $config);
|
$cache->put('config', $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cache->exists('acl_options'))
|
if (!($acl_options = $cache->get('acl_options')))
|
||||||
{
|
{
|
||||||
$acl_options = $cache->get('acl_options');
|
$acl_options = array();
|
||||||
|
|
||||||
|
$sql = "SELECT auth_value, is_global, is_local
|
||||||
|
FROM " . ACL_OPTIONS_TABLE . "
|
||||||
|
ORDER BY auth_option_id";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$global = $local = 0;
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if (!empty($row['is_global']))
|
||||||
|
{
|
||||||
|
$acl_options['global'][$row['auth_value']] = $global++;
|
||||||
}
|
}
|
||||||
else
|
if (!empty($row['is_local']))
|
||||||
{
|
{
|
||||||
require_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
$acl_options['local'][$row['auth_value']] = $local++;
|
||||||
$auth_admin = new auth_admin();
|
}
|
||||||
$acl_options = $auth_admin->acl_cache_options();
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$cache->put('acl_options', $acl_options);
|
||||||
|
$auth->acl_clear_prefetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -215,10 +207,6 @@ if (time() - $config['cache_interval'] >= $config['cache_last_gc'])
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Instantiate some basic classes
|
|
||||||
$user = new user();
|
|
||||||
$auth = new auth();
|
|
||||||
|
|
||||||
// Show 'Board is disabled' message
|
// Show 'Board is disabled' message
|
||||||
if ($config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN'))
|
if ($config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -688,20 +688,6 @@ class auth_admin extends auth
|
||||||
$this->acl_clear_prefetch();
|
$this->acl_clear_prefetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
function acl_clear_prefetch($user_id = false)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$where_sql = ($user_id) ? "WHERE user_id = $user_id" : '';
|
|
||||||
|
|
||||||
$sql = "UPDATE " . USERS_TABLE . "
|
|
||||||
SET user_permissions = ''
|
|
||||||
$where_sql";
|
|
||||||
$db->sql_query($sql);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a new option to the list ... $options is a hash of form ->
|
// Add a new option to the list ... $options is a hash of form ->
|
||||||
// $options = array(
|
// $options = array(
|
||||||
// 'local' => array('option1', 'option2', ...),
|
// 'local' => array('option1', 'option2', ...),
|
||||||
|
@ -802,58 +788,7 @@ class auth_admin extends auth
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->acl_cache_options($options);
|
$cache->destroy('acl_options');
|
||||||
}
|
|
||||||
|
|
||||||
function acl_cache_options($options = false)
|
|
||||||
{
|
|
||||||
global $db, $cache;
|
|
||||||
|
|
||||||
$options = array();
|
|
||||||
|
|
||||||
if (!$options)
|
|
||||||
{
|
|
||||||
$sql = "SELECT auth_value, is_global, is_local
|
|
||||||
FROM " . ACL_OPTIONS_TABLE . "
|
|
||||||
ORDER BY is_global, is_local, auth_value";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$global = $local = 0;
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
if (!empty($row['is_global']))
|
|
||||||
{
|
|
||||||
$options['global'][$row['auth_value']] = $global++;
|
|
||||||
}
|
|
||||||
if (!empty($row['is_local']))
|
|
||||||
{
|
|
||||||
$options['local'][$row['auth_value']] = $local++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Re-cache options
|
|
||||||
$cache_str = "\$acl_options = array(\n";
|
|
||||||
foreach ($options as $type => $options_ary)
|
|
||||||
{
|
|
||||||
$cache_str .= "\t'$type' => array(\n";
|
|
||||||
foreach ($options_ary as $option_value => $option_id)
|
|
||||||
{
|
|
||||||
$cache_str .= "\t\t'$option_value' => " . $option_id . ",\n";
|
|
||||||
}
|
|
||||||
$cache_str .= "\t),\n";
|
|
||||||
}
|
|
||||||
$cache_str .= ");";
|
|
||||||
|
|
||||||
config_cache_write('\$acl_options = array\(.*?\);', $cache_str);
|
|
||||||
$this->acl_clear_prefetch();
|
|
||||||
*/
|
|
||||||
$cache->put('acl_options', $options);
|
|
||||||
$this->acl_clear_prefetch();
|
|
||||||
|
|
||||||
return $options;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue