Permalink
Browse files

MDL-26436 message: reviewed use of recordsets in messaging

  • Loading branch information...
1 parent 39d106e commit 9f2e9b535d9adafbd43944633bfecabc9e71efb1 @andyjdavis andyjdavis committed May 10, 2011
Showing with 9 additions and 9 deletions.
  1. +9 −9 message/lib.php
View
@@ -200,6 +200,8 @@ function message_get_blocked_users($user1=null, $user2=null) {
$user2->isblocked = false;
}
+ $blockedusers = array();
+
$userfields = user_picture::fields('u', array('lastaccess'));
$blockeduserssql = "SELECT $userfields, COUNT(m.id) AS messagecount
FROM {message_contacts} mc
@@ -210,18 +212,14 @@ function message_get_blocked_users($user1=null, $user2=null) {
ORDER BY u.firstname ASC";
$rs = $DB->get_recordset_sql($blockeduserssql, array('user1id1' => $user1->id, 'user1id2' => $user1->id));
- $blockedusers = array();
- if (!empty($rs)) {
- foreach($rs as $rd) {
- $blockedusers[] = $rd;
+ foreach($rs as $rd) {
+ $blockedusers[] = $rd;
- if (!empty($user2) && $user2->id == $rd->id) {
- $user2->isblocked = true;
- }
+ if (!empty($user2) && $user2->id == $rd->id) {
+ $user2->isblocked = true;
}
- unset($rd);
- $rs->close();
}
+ $rs->close();
return $blockedusers;
}
@@ -2129,6 +2127,8 @@ function message_mark_messages_read($touserid, $fromuserid){
foreach ($messages as $message) {
message_mark_message_read($message, time());
}
+
+ $messages->close();
}
/**

0 comments on commit 9f2e9b5

Please sign in to comment.