Home
Documentation
Downloads
Demo
Tracker
Development
Translation
Moodle.net
Search
projects
/
moodle.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
57bedae
)
search MDL-25153 fixed performance problem
author
Aparup Banerjee
<nebgor@gmail.com>
Thu, 2 Dec 2010 06:24:50 +0000
(06:24 +0000)
committer
Aparup Banerjee
<nebgor@gmail.com>
Thu, 2 Dec 2010 06:24:50 +0000
(06:24 +0000)
search/query.php
patch
|
blob
|
blame
|
history
diff --git
a/search/query.php
b/search/query.php
index
3480cfc
..
db2898e
100644
(file)
--- a/
search/query.php
+++ b/
search/query.php
@@
-339,13
+339,19
@@
$authorstr = get_string('author', 'search');
$searchables = search_collect_searchables(false, false);
$authorstr = get_string('author', 'search');
$searchables = search_collect_searchables(false, false);
-
+
+ //build a list of distinct user objects needed for results listing.
+ $hitusers = array();
+ foreach ($hits as $listing) {
+ if ($listing->doctype == 'user' and !isset($hitusers[$listing->userid])) {
+ $hitusers[$listing->userid] = $DB->get_record('user', array('id' => $listing->userid));
+ }
+ }
+
foreach ($hits as $listing) {
foreach ($hits as $listing) {
- if ($listing->doctype == 'user'){ // A special handle for users
- //TODO: this is a performance problem, fetch data elsewhere
- $user = (object)array('id'=>$listing->userid);
- $icon = $OUTPUT->user_picture($user);
+ if ($listing->doctype == 'user') { // A special handle for users
+ $icon = $OUTPUT->user_picture($hitusers[$listing->userid]);
} else {
$iconpath = $OUTPUT->pix_url('icon', $listing->doctype);
$icon = "<img align=\"top\" src=\"".$iconpath."\" class=\"activityicon\" alt=\"\"/>";
} else {
$iconpath = $OUTPUT->pix_url('icon', $listing->doctype);
$icon = "<img align=\"top\" src=\"".$iconpath."\" class=\"activityicon\" alt=\"\"/>";