Closed (won't fix)
Project:
Auto Assign Role
Version:
5.x-1.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Jul 2009 at 15:43 UTC
Updated:
7 Jul 2009 at 15:52 UTC
//(…) common.inc:1865
// Load all enabled modules
module_load_all(); //<- here autoassignrole.module is included
// Initialize the localization system. Depends on i18n.module being loaded already.
$locale = locale_initialize(); //<- here, $locale is initialized
// Let all modules take action before menu system handles the reqest
module_invoke_all('init'); //<- here, i suggest autoassignrole.module to be initialized
from the common.inc module_load_all() 'includes' any module. in the autoassignrole.module this leads to the function call of t().
//(…) autoassignrole.module:3
define("AUTOASSIGNROLE_ROLE", "");
define("AUTOASSIGNROLE_ROLE_ACTIVE", 0);
define("AUTOASSIGNROLE_ROLE_USER_ACTIVE", 0);
define("AUTOASSIGNROLE_ROLE_USER", "");
define("AUTOASSIGNROLE_ROLE_USER_MULTIPLE", 0);
define("AUTOASSIGNROLE_ROLE_USER_DESCRIPTION", "");
define("AUTOASSIGNROLE_ROLE_USER_TITLE", t("Role")); //<- here t() is called
define("AUTOASSIGNROLE_ROLE_SORT", "SORT_ASC");
however, t() needs the locale module to be initialized or at least, t() needs the $locale to be initialized. otherwise, locale tries to refresh the cache on every page load.
in my opinion this is implemented wrongly. t() must only be called after $locale is initialized by locale_initialize() in the common.inc, which means an implementation of the hook_init() for autoassignrole.module to wrap the initialization code in the module.
//wrap initialization in hook_init()
function autoassignrole_init()
{
define("AUTOASSIGNROLE_ROLE", "");
define("AUTOASSIGNROLE_ROLE_ACTIVE", 0);
define("AUTOASSIGNROLE_ROLE_USER_ACTIVE", 0);
define("AUTOASSIGNROLE_ROLE_USER", "");
define("AUTOASSIGNROLE_ROLE_USER_MULTIPLE", 0);
define("AUTOASSIGNROLE_ROLE_USER_DESCRIPTION", "");
define("AUTOASSIGNROLE_ROLE_USER_TITLE", t("Role"));
define("AUTOASSIGNROLE_ROLE_SORT", "SORT_ASC");
}
Comments
Comment #1
cyberswat commentedThis has already been fixed in the d6 dev branch ... I'm not maintaining d5 anymore so if you'd like to submit a patch I'll commit it.