MDL-63887 auth_ldap: fix unclean exit from sync when users not found
authorJake Dallimore <jake@moodle.com>
Wed, 12 Dec 2018 00:53:35 +0000 (08:53 +0800)
committerJake Dallimore <jake@moodle.com>
Wed, 12 Dec 2018 01:42:13 +0000 (09:42 +0800)
We should return, not exit, and we should clean up before we do.

auth/ldap/auth.php

index b3015d4..6e6c7ff 100644 (file)
@@ -753,7 +753,9 @@ class auth_plugin_ldap extends auth_plugin_base {
         $count = $DB->count_records_sql('SELECT COUNT(username) AS count, 1 FROM {tmp_extuser}');
         if ($count < 1) {
             print_string('didntgetusersfromldap', 'auth_ldap');
-            exit;
+            $dbman->drop_table($table);
+            $this->ldap_close();
+            return false;
         } else {
             print_string('gotcountrecordsfromldap', 'auth_ldap', $count);
         }