1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-11 03:04:09 +02:00

[ticket/13162] Use db tools for truncating

PHPBB3-13162
This commit is contained in:
Marc Alexander
2023-12-17 19:49:23 +01:00
parent c31ac7348a
commit 59f387e828
21 changed files with 103 additions and 118 deletions

View File

@@ -27,7 +27,7 @@ class acp_forums
function main($id, $mode)
{
global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;
global $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log;
global $phpbb_admin_path, $phpbb_container, $phpbb_root_path, $phpEx, $phpbb_log;
$user->add_lang('acp/forums');
$this->tpl_name = 'acp_forums';
@@ -210,7 +210,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'))))
{
copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
$copied_permissions = true;
}
/* Commented out because of questionable UI workflow - re-visit for 3.0.7
@@ -789,7 +789,7 @@ class acp_forums
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
{
copy_forum_permissions($forum_perm_from, $forum_id, true);
phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
$auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE);

View File

@@ -574,16 +574,8 @@ class acp_icons
// The user has already selected a smilies_pak file
if ($current == 'delete')
{
switch ($db->get_sql_layer())
{
case 'sqlite3':
$db->sql_query('DELETE FROM ' . $table);
break;
default:
$db->sql_query('TRUNCATE TABLE ' . $table);
break;
}
$db_tools = $phpbb_container->get('dbal.tools');
$db_tools->sql_truncate_table($table);
switch ($mode)
{

View File

@@ -281,16 +281,8 @@ class acp_main
break;
case 'db_track':
switch ($db->get_sql_layer())
{
case 'sqlite3':
$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
break;
default:
$db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
break;
}
$db_tools = $phpbb_container->get('dbal.tools');
$db_tools->sql_truncate_table(TOPICS_POSTED_TABLE);
// This can get really nasty... therefore we only do the last six months
$get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60);
@@ -370,7 +362,7 @@ class acp_main
// Clear permissions
$auth->acl_clear_prefetch();
phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_CACHE');
@@ -388,19 +380,11 @@ class acp_main
}
$tables = array(CONFIRM_TABLE, SESSIONS_TABLE);
$db_tools = $phpbb_container->get('dbal.tools');
foreach ($tables as $table)
{
switch ($db->get_sql_layer())
{
case 'sqlite3':
$db->sql_query("DELETE FROM $table");
break;
default:
$db->sql_query("TRUNCATE TABLE $table");
break;
}
$db_tools->sql_truncate_table($table);
}
// let's restore the admin session

View File

@@ -679,7 +679,7 @@ class acp_permissions
function set_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id)
{
global $db, $cache, $user, $auth;
global $request;
global $request, $phpbb_container;
$psubmit = $request->variable('psubmit', array(0 => array(0 => 0)));
@@ -747,7 +747,7 @@ class acp_permissions
// Do we need to recache the moderator lists?
if ($permission_type == 'm_')
{
phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
}
// Remove users who are now moderators or admins from everyones foes list
@@ -768,7 +768,7 @@ class acp_permissions
function set_all_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id)
{
global $db, $cache, $user, $auth;
global $request;
global $request, $phpbb_container;
// User or group to be set?
$ug_type = (count($user_id)) ? 'user' : 'group';
@@ -817,7 +817,7 @@ class acp_permissions
// Do we need to recache the moderator lists?
if ($permission_type == 'm_')
{
phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
}
// Remove users who are now moderators or admins from everyones foes list
@@ -883,7 +883,7 @@ class acp_permissions
*/
function remove_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id, &$forum_id)
{
global $user, $db, $cache, $auth;
global $user, $db, $cache, $auth, $phpbb_container;
// User or group to be set?
$ug_type = (count($user_id)) ? 'user' : 'group';
@@ -900,7 +900,7 @@ class acp_permissions
// Do we need to recache the moderator lists?
if ($permission_type == 'm_')
{
phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
}
$this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : array(0 => 0)));
@@ -1202,7 +1202,7 @@ class acp_permissions
*/
function copy_forum_permissions()
{
global $db, $auth, $cache, $template, $user, $request;
global $db, $auth, $cache, $phpbb_container, $template, $user, $request;
$user->add_lang('acp/forums');
@@ -1217,7 +1217,7 @@ class acp_permissions
{
if (copy_forum_permissions($src, $dest))
{
phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
$auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE);