Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-31081 limit query to one course in forum_get_subscribed_forums()

This improves performance on the forum index page. Credit goes to Mark Nielsen.
  • Loading branch information...
commit 302ae13f705c5f27f91f29b6c58cb2515679606c 1 parent 11d8ae7
@skodak skodak authored stronk7 committed
Showing with 3 additions and 2 deletions.
  1. +3 −2 mod/forum/lib.php
View
5 mod/forum/lib.php
@@ -4540,9 +4540,10 @@ function forum_get_subscribed_forums($course) {
$sql = "SELECT f.id
FROM {forum} f
LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = ?)
- WHERE f.forcesubscribe <> ".FORUM_DISALLOWSUBSCRIBE."
+ WHERE f.course = ?
+ AND f.forcesubscribe <> ".FORUM_DISALLOWSUBSCRIBE."
AND (f.forcesubscribe = ".FORUM_FORCESUBSCRIBE." OR fs.id IS NOT NULL)";
- if ($subscribed = $DB->get_records_sql($sql, array($USER->id))) {
+ if ($subscribed = $DB->get_records_sql($sql, array($USER->id, $course->id))) {
foreach ($subscribed as $s) {
$subscribed[$s->id] = $s->id;
}
Please sign in to comment.
Something went wrong with that request. Please try again.