Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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!
Comment | File | Size | Author |
---|---|---|---|
user_badges_profileonly.patch | 1.58 KB | robphillips |
Comments
Comment #1
Richard Blackborder CreditAttribution: Richard Blackborder commentedI'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.
Comment #2
NancyDruTry 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.
Comment #3
NancyDruOops. the line
if (isset($badges[$account->uid])) {
needs an extra parenthesis, as shown here.Comment #4
NancyDruCommitted to 6.x-1.x-dev.