[ticket/17347] Use progress bar and test bot deletion only

PHPBB-17347
This commit is contained in:
Marc Alexander 2024-06-21 20:59:04 +02:00
parent 8c77da9c30
commit db40145fd5
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
3 changed files with 23 additions and 12 deletions

View file

@ -159,8 +159,9 @@ $lang = array_merge($lang, array(
'CLI_USER_ADD_SUCCESS' => 'Successfully added user %s.',
'CLI_USER_DELETE_CONFIRM' => 'Are you sure you want to delete %s? [y/N]',
'CLI_USER_DELETE_IDS_CONFIRM' => 'Are you sure you want to delete the user IDs %s? [y/N]',
'CLI_USER_DELETE_IDS_SUCCESS' => 'Successfully deleted user IDs.',
'CLI_USER_DELETE_ID_CONFIRM' => 'Are you sure you want to delete the user IDs %s? [y/N]',
'CLI_USER_DELETE_ID_SUCCESS' => 'Successfully deleted user IDs.',
'CLI_USER_DELETE_ID_START' => 'Deleting users by ID',
'CLI_USER_DELETE_NONE' => 'No users were deleted by user ID.',
'CLI_USER_RECLEAN_START' => 'Re-cleaning usernames',
'CLI_USER_RECLEAN_DONE' => [

View file

@ -132,6 +132,10 @@ class delete_id extends command
{
$this->user_loader->load_users($user_ids);
$progress = $this->create_progress_bar(count($user_ids), $io, $output);
$progress->setMessage($this->language->lang('CLI_USER_DELETE_ID_START'));
$progress->start();
foreach ($user_ids as $user_id)
{
$user_row = $this->user_loader->get_user($user_id);
@ -139,28 +143,34 @@ class delete_id extends command
// Skip anonymous user
if ($user_row['user_id'] == ANONYMOUS)
{
$progress->advance();
continue;
}
else if ($user_row['user_type'] == USER_IGNORE)
{
$this->delete_bot_user($user_row);
continue;
}
if (!function_exists('user_delete'))
else
{
require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
if (!function_exists('user_delete'))
{
require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}
user_delete($mode, $user_row['user_id'], $user_row['username']);
$this->log->add('admin', ANONYMOUS, '', 'LOG_USER_DELETED', false, array($user_row['username']));
}
user_delete($mode, $user_row['user_id'], $user_row['username']);
$this->log->add('admin', ANONYMOUS, '', 'LOG_USER_DELETED', false, array($user_row['username']));
$progress->advance();
$deleted_users++;
}
$progress->finish();
if ($deleted_users > 0)
{
$io->success($this->language->lang('CLI_USER_DELETE_IDS_SUCCESS'));
$io->success($this->language->lang('CLI_USER_DELETE_ID_SUCCESS'));
}
}
@ -187,7 +197,7 @@ class delete_id extends command
if (count($user_ids) > 0)
{
$question = new ConfirmationQuestion(
$this->language->lang('CLI_USER_DELETE_IDS_CONFIRM', implode(',', $user_ids)),
$this->language->lang('CLI_USER_DELETE_ID_CONFIRM', implode(',', $user_ids)),
false
);

View file

@ -86,7 +86,7 @@ class phpbb_console_user_delete_ids_test extends phpbb_console_user_base
$command_tester->execute(array(
'command' => $this->command_name,
'user_ids' => [3, 6],
'user_ids' => [6],
'--delete-posts' => false,
));