[ticket/10758] Dependency inject parameters into cache_moderators.

Also add phpbb prefix since the signature is being changed anyway.

PHPBB3-10758
This commit is contained in:
Oleg Pudeyev 2012-12-15 01:19:55 -05:00
parent b6778802b3
commit 5c496674f6
7 changed files with 40 additions and 33 deletions

View file

@ -206,7 +206,7 @@ class acp_forums
($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))))
{ {
copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
$copied_permissions = true; $copied_permissions = true;
} }
/* Commented out because of questionable UI workflow - re-visit for 3.0.7 /* Commented out because of questionable UI workflow - re-visit for 3.0.7
@ -266,7 +266,7 @@ class acp_forums
add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name);
$cache->destroy('sql', FORUMS_TABLE); $cache->destroy('sql', FORUMS_TABLE);
} }
if ($request->is_ajax()) if ($request->is_ajax())
{ {
$json_response = new phpbb_json_response; $json_response = new phpbb_json_response;
@ -768,7 +768,7 @@ class acp_forums
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
{ {
copy_forum_permissions($forum_perm_from, $forum_id, true); copy_forum_permissions($forum_perm_from, $forum_id, true);
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
$auth->acl_clear_prefetch(); $auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE); $cache->destroy('sql', FORUMS_TABLE);

View file

@ -24,7 +24,7 @@ class acp_main
function main($id, $mode) function main($id, $mode)
{ {
global $config, $db, $user, $auth, $template, $request; global $config, $db, $cache, $user, $auth, $template, $request;
global $phpbb_root_path, $phpbb_admin_path, $phpEx; global $phpbb_root_path, $phpbb_admin_path, $phpEx;
// Show restore permissions notice // Show restore permissions notice
@ -129,7 +129,7 @@ class acp_main
set_config('record_online_users', 1, true); set_config('record_online_users', 1, true);
set_config('record_online_date', time(), true); set_config('record_online_date', time(), true);
add_log('admin', 'LOG_RESET_ONLINE'); add_log('admin', 'LOG_RESET_ONLINE');
if ($request->is_ajax()) if ($request->is_ajax())
{ {
trigger_error('RESET_ONLINE_SUCCESS'); trigger_error('RESET_ONLINE_SUCCESS');
@ -184,7 +184,7 @@ class acp_main
update_last_username(); update_last_username();
add_log('admin', 'LOG_RESYNC_STATS'); add_log('admin', 'LOG_RESYNC_STATS');
if ($request->is_ajax()) if ($request->is_ajax())
{ {
trigger_error('RESYNC_STATS_SUCCESS'); trigger_error('RESYNC_STATS_SUCCESS');
@ -251,7 +251,7 @@ class acp_main
} }
add_log('admin', 'LOG_RESYNC_POSTCOUNTS'); add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
if ($request->is_ajax()) if ($request->is_ajax())
{ {
trigger_error('RESYNC_POSTCOUNTS_SUCCESS'); trigger_error('RESYNC_POSTCOUNTS_SUCCESS');
@ -266,7 +266,7 @@ class acp_main
set_config('board_startdate', time() - 1); set_config('board_startdate', time() - 1);
add_log('admin', 'LOG_RESET_DATE'); add_log('admin', 'LOG_RESET_DATE');
if ($request->is_ajax()) if ($request->is_ajax())
{ {
trigger_error('RESET_DATE_SUCCESS'); trigger_error('RESET_DATE_SUCCESS');
@ -346,7 +346,7 @@ class acp_main
} }
add_log('admin', 'LOG_RESYNC_POST_MARKING'); add_log('admin', 'LOG_RESYNC_POST_MARKING');
if ($request->is_ajax()) if ($request->is_ajax())
{ {
trigger_error('RESYNC_POST_MARKING_SUCCESS'); trigger_error('RESYNC_POST_MARKING_SUCCESS');
@ -359,10 +359,10 @@ class acp_main
// Clear permissions // Clear permissions
$auth->acl_clear_prefetch(); $auth->acl_clear_prefetch();
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
add_log('admin', 'LOG_PURGE_CACHE'); add_log('admin', 'LOG_PURGE_CACHE');
if ($request->is_ajax()) if ($request->is_ajax())
{ {
trigger_error('PURGE_CACHE_SUCCESS'); trigger_error('PURGE_CACHE_SUCCESS');
@ -413,7 +413,7 @@ class acp_main
$db->sql_query($sql); $db->sql_query($sql);
add_log('admin', 'LOG_PURGE_SESSIONS'); add_log('admin', 'LOG_PURGE_SESSIONS');
if ($request->is_ajax()) if ($request->is_ajax())
{ {
trigger_error('PURGE_SESSIONS_SUCCESS'); trigger_error('PURGE_SESSIONS_SUCCESS');

View file

@ -656,7 +656,7 @@ class acp_permissions
*/ */
function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id) function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
{ {
global $user, $auth; global $db, $cache, $user, $auth;
global $request; global $request;
$psubmit = request_var('psubmit', array(0 => array(0 => 0))); $psubmit = request_var('psubmit', array(0 => array(0 => 0)));
@ -726,7 +726,7 @@ class acp_permissions
// Do we need to recache the moderator lists? // Do we need to recache the moderator lists?
if ($permission_type == 'm_') if ($permission_type == 'm_')
{ {
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
} }
// Remove users who are now moderators or admins from everyones foes list // Remove users who are now moderators or admins from everyones foes list
@ -745,7 +745,7 @@ class acp_permissions
*/ */
function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id) function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
{ {
global $user, $auth; global $db, $cache, $user, $auth;
global $request; global $request;
// User or group to be set? // User or group to be set?
@ -794,7 +794,7 @@ class acp_permissions
// Do we need to recache the moderator lists? // Do we need to recache the moderator lists?
if ($permission_type == 'm_') if ($permission_type == 'm_')
{ {
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
} }
// Remove users who are now moderators or admins from everyones foes list // Remove users who are now moderators or admins from everyones foes list
@ -858,7 +858,7 @@ class acp_permissions
*/ */
function remove_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id, &$forum_id) function remove_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id, &$forum_id)
{ {
global $user, $db, $auth; global $user, $db, $cache, $auth;
// User or group to be set? // User or group to be set?
$ug_type = (sizeof($user_id)) ? 'user' : 'group'; $ug_type = (sizeof($user_id)) ? 'user' : 'group';
@ -874,7 +874,7 @@ class acp_permissions
// Do we need to recache the moderator lists? // Do we need to recache the moderator lists?
if ($permission_type == 'm_') if ($permission_type == 'm_')
{ {
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
} }
$this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : array(0 => 0))); $this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : array(0 => 0)));
@ -1172,7 +1172,7 @@ class acp_permissions
*/ */
function copy_forum_permissions() function copy_forum_permissions()
{ {
global $auth, $cache, $template, $user; global $db, $auth, $cache, $template, $user;
$user->add_lang('acp/forums'); $user->add_lang('acp/forums');
@ -1187,7 +1187,7 @@ class acp_permissions
{ {
if (copy_forum_permissions($src, $dest)) if (copy_forum_permissions($src, $dest))
{ {
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
$auth->acl_clear_prefetch(); $auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE); $cache->destroy('sql', FORUMS_TABLE);

View file

@ -137,11 +137,13 @@ class acp_styles
*/ */
protected function action_cache() protected function action_cache()
{ {
global $db, $cache, $auth;
$this->cache->purge(); $this->cache->purge();
// Clear permissions // Clear permissions
$this->auth->acl_clear_prefetch(); $this->auth->acl_clear_prefetch();
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
add_log('admin', 'LOG_PURGE_CACHE'); add_log('admin', 'LOG_PURGE_CACHE');

View file

@ -2292,13 +2292,17 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
} }
/** /**
* Cache moderators, called whenever permissions are changed via admin_permissions. Changes of username * Cache moderators. Called whenever permissions are changed
* and group names must be carried through for the moderators table * via admin_permissions. Changes of usernames and group names
* must be carried through for the moderators table
*
* @param phpbb_db_driver $db Database connection
* @param phpbb_cache_driver_interface Cache driver
* @param phpbb_auth $auth Authentication object
* @return null
*/ */
function cache_moderators() function phpbb_cache_moderators($db, $cache, $auth)
{ {
global $db, $cache, $auth, $phpbb_root_path, $phpEx;
// Remove cached sql results // Remove cached sql results
$cache->destroy('sql', MODERATOR_CACHE_TABLE); $cache->destroy('sql', MODERATOR_CACHE_TABLE);

View file

@ -2842,7 +2842,7 @@ function avatar_remove_db($avatar_name)
*/ */
function group_delete($group_id, $group_name = false) function group_delete($group_id, $group_name = false)
{ {
global $db, $phpbb_root_path, $phpEx, $phpbb_dispatcher; global $db, $cache, $auth, $phpbb_root_path, $phpEx, $phpbb_dispatcher;
if (!$group_name) if (!$group_name)
{ {
@ -2913,12 +2913,12 @@ function group_delete($group_id, $group_name = false)
extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars)));
// Re-cache moderators // Re-cache moderators
if (!function_exists('cache_moderators')) if (!function_exists('phpbb_cache_moderators'))
{ {
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
} }
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
add_log('admin', 'LOG_GROUP_DELETE', $group_name); add_log('admin', 'LOG_GROUP_DELETE', $group_name);
@ -3678,7 +3678,7 @@ function group_memberships($group_id_ary = false, $user_id_ary = false, $return_
*/ */
function group_update_listings($group_id) function group_update_listings($group_id)
{ {
global $auth; global $db, $cache, $auth;
$hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_')); $hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_'));
@ -3720,12 +3720,12 @@ function group_update_listings($group_id)
if ($mod_permissions) if ($mod_permissions)
{ {
if (!function_exists('cache_moderators')) if (!function_exists('phpbb_cache_moderators'))
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
} }
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
} }
if ($mod_permissions || $admin_permissions) if ($mod_permissions || $admin_permissions)

View file

@ -1538,6 +1538,7 @@ class install_convert extends module
function finish_conversion() function finish_conversion()
{ {
global $db, $phpbb_root_path, $phpEx, $convert, $config, $language, $user, $template; global $db, $phpbb_root_path, $phpEx, $convert, $config, $language, $user, $template;
global $cache, $auth;
$db->sql_query('DELETE FROM ' . CONFIG_TABLE . " $db->sql_query('DELETE FROM ' . CONFIG_TABLE . "
WHERE config_name = 'convert_progress' WHERE config_name = 'convert_progress'
@ -1547,7 +1548,7 @@ class install_convert extends module
$db->sql_query('DELETE FROM ' . SESSIONS_TABLE); $db->sql_query('DELETE FROM ' . SESSIONS_TABLE);
@unlink($phpbb_root_path . 'cache/data_global.' . $phpEx); @unlink($phpbb_root_path . 'cache/data_global.' . $phpEx);
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
// And finally, add a note to the log // And finally, add a note to the log
add_log('admin', 'LOG_INSTALL_CONVERTED', $convert->convertor_data['forum_name'], $config['version']); add_log('admin', 'LOG_INSTALL_CONVERTED', $convert->convertor_data['forum_name'], $config['version']);