From: stronk7 Date: Thu, 5 Apr 2007 22:22:28 +0000 (+0000) Subject: Fixing authdb->close() in some places. Credir goes to Seiti. MDL-9212 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a7e323672d0dc0d12b7059c677298a78e9790a19;p=moodle.git Fixing authdb->close() in some places. Credir goes to Seiti. MDL-9212 Merged from MOODLE_18_STABLE --- diff --git a/auth/db/auth.php b/auth/db/auth.php index 1bc28a580e..4e742c8dd2 100644 --- a/auth/db/auth.php +++ b/auth/db/auth.php @@ -182,6 +182,7 @@ class auth_plugin_db extends auth_plugin_base { } $authdb->Close(); return $result; + } @@ -390,6 +391,9 @@ class auth_plugin_db extends auth_plugin_base { function user_exists($username) { + /// Init result value + $result = false; + $textlib = textlib_get_instance(); $extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->extencoding); @@ -397,46 +401,40 @@ class auth_plugin_db extends auth_plugin_base { $rs = $authdb->Execute("SELECT * FROM {$this->config->table} WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."' "); - $authdb->Close(); if (!$rs) { print_error('auth_dbcantconnect','auth'); - return false; - } - - if ( $rs->RecordCount() ) { + } else if ( $rs->RecordCount() ) { // user exists exterally - return $rs->RecordCount(); - } else { - // user does not exist externally - return false; + $result = $rs->RecordCount(); } + + $authdb->Close(); + return $result; } function get_userlist() { + /// Init result value + $result = array(); + $authdb = $this->db_init(); // fetch userlist $rs = $authdb->Execute("SELECT {$this->config->fielduser} AS username FROM {$this->config->table} "); - $authdb->Close(); if (!$rs) { print_error('auth_dbcantconnect','auth'); - return false; - } - - if ( $rs->RecordCount() ) { - $userlist = array(); + } else if ( $rs->RecordCount() ) { while ($rec = rs_fetch_next_record($rs)) { - array_push($userlist, $rec->username); + array_push($result, $rec->username); } - return $userlist; - } else { - return array(); } + + $authdb->Close(); + return $result; } /**