Huge performance issue due to bug
Davy Van Den Bremt - October 13, 2008 - 17:12
| Project: | Advanced User |
| Version: | 5.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
At the top of advuser.module there is a t() defined in a define(). This can not work and has huge performance issues.
define('ADVUSER_SUBSTITUTION_TEXT', t('<strong>Substitution variables</strong> available in subject and email body<br/><em> %user_name, %user_email, %user_status, %user_created, %user_theme, %user_timezone, %user_language, %user_signature, %site, %uri, %google_user (search google for user email), %yahoo_user (search yahoo for user email)</em>'));In function locale() the global $locale isn't set yet when the define function runs. This way the locale cache is rebuilt on every page request (locale_refresh_cache). On a site with a lot of t() calls this means a huge cache_set (in our case 500kb).
function locale($string) {
global $locale;
static $locale_t;
// Store database cached translations in a static var.
if (!isset($locale_t)) {
$cache = cache_get("locale:$locale", 'cache');
if (!$cache) {
locale_refresh_cache();
$cache = cache_get("locale:$locale", 'cache');
}
}The attached patch takes the t() away from the define() and puts a t() around each instance of the constant.
| Attachment | Size |
|---|---|
| advuser.module.patch | 1.74 KB |

#1
Does this affect Drupal 5?
#2
Yes, this was tested in Drupal 5.
#3
#4
Committed patch to HEAD, 5.x-2.x-dev and 6.x-2.x-dev
#5
Automatically closed -- issue fixed for 2 weeks with no activity.