Commit b178a859 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1773707: Catching exception in delete users script

behatnotneeded

Change-Id: I9f2bf9d7db925e135107659e2d8e4e8b38d5f7ef
parent c6f82f81
......@@ -155,7 +155,14 @@ if ($records = get_records_sql_array($selectsql . $joinsql . $wheresql, $values)
if (!$dryrun) {
$cli->cli_print("--- " . date('Y-m-d H:i:s', time()) . " ---");
foreach ($records as $record) {
try {
$DB_IGNORE_SQL_EXCEPTIONS = true;
delete_user($record->id);
$DB_IGNORE_SQL_EXCEPTIONS = false;
}
catch (SQLException $e) {
$cli->cli_print(get_string('cli_deleteinactiveusers_userunabletodelete', 'admin', $record->username, $record->id));
}
if ($cleanusers) {
try {
$DB_IGNORE_SQL_EXCEPTIONS = true;
......
......@@ -1343,6 +1343,7 @@ $string['cli_deleteinactiveusers_neverloggedin'] = 'Delete users that have never
$string['cli_param_baddate'] = 'The supplied date "%s" is not valid.';
$string['cli_deleteinactiveusers_usercount'] = 'There are "%s" users to delete';
$string['cli_deleteinactiveusers_userunabletoclean'] = 'Unable to fully delete user "%s" (ID %s)';
$string['cli_deleteinactiveusers_userunabletodelete'] = 'Unable to delete user "%s" (ID %s)';
$string['cli_deleteinactiveusers_nouserstodelete'] = 'There are no users to delete.';
$string['cli_deleteinactiveusers_onlydryrun1'] = 'This is only a dry run with the following settings
Institution: %s
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment