Posted by robphillips on September 23, 2009 at 6:17pm
Jump to:
| Project: | User Badges |
| Version: | 5.x-1.5 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | NancyDru |
| Status: | closed (fixed) |
Issue Summary
On sites that have a lot of user_load() calls the user badges modules seems to really tally up a large amount of queries due to it's loading operation in hook_user. It doesn't always make sense for users of this module to load badges on any page except the user profile page. So this patch adds a setting into user badges that allows it to be toggled on and off, essentially giving the user an option to save on precious query calls. Please review and let me know if you find anything off-mark with this. Thanks!
| Attachment | Size |
|---|---|
| user_badges_profileonly.patch | 1.58 KB |
Comments
#1
I'm not sure this is the best approach because it will break any modules that need to load badges on other pages. It might be better to use Drupal's cache system (does D5 have this?) so that functionality isn't reduced, or add a hook or something so that other modules can force a load on other pages.
#2
Try this one. It's based on 6.x-1.x-dev, but the code should work on 5.x. It uses simple static caching to avoid loading stuff that has already been loaded before and shouldn't break anything.
#3
Oops. the line
if (isset($badges[$account->uid])) {needs an extra parenthesis, as shown here.#4
Committed to 6.x-1.x-dev.
#5
Automatically closed -- issue fixed for 2 weeks with no activity.