MDL-60666 auth_ldap: One transaction per user

This commit is contained in:
Peter Sistrom
2022-09-05 14:35:26 +04:00
committed by Ilya Tregubov
parent 2b22716dc2
commit 6fe4eb2a86
+4 -9
View File
@@ -866,11 +866,8 @@ class auth_plugin_ldap extends auth_plugin_base {
if (!empty($users)) {
print_string('userentriestoupdate', 'auth_ldap', count($users));
$transaction = $DB->start_delegated_transaction();
$xcount = 0;
$maxxcount = 100;
foreach ($users as $user) {
$transaction = $DB->start_delegated_transaction();
echo "\t"; print_string('auth_dbupdatinguser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id));
$userinfo = $this->get_userinfo($user->username);
if (!$this->update_user_record($user->username, $updatekeys, true,
@@ -878,12 +875,11 @@ class auth_plugin_ldap extends auth_plugin_base {
echo ' - '.get_string('skipped');
}
echo "\n";
$xcount++;
// Update system roles, if needed.
$this->sync_roles($user);
$transaction->allow_commit();
}
$transaction->allow_commit();
unset($users); // free mem
}
} else { // end do updates
@@ -903,8 +899,8 @@ class auth_plugin_ldap extends auth_plugin_base {
if (!empty($add_users)) {
print_string('userentriestoadd', 'auth_ldap', count($add_users));
$transaction = $DB->start_delegated_transaction();
foreach ($add_users as $user) {
$transaction = $DB->start_delegated_transaction();
$user = $this->get_userinfo_asobj($user->username);
// Prep a few params
@@ -939,9 +935,8 @@ class auth_plugin_ldap extends auth_plugin_base {
// Add roles if needed.
$this->sync_roles($euser);
$transaction->allow_commit();
}
$transaction->allow_commit();
unset($add_users); // free mem
} else {
print_string('nouserstobeadded', 'auth_ldap');