Download & Extend

declared variables should be moved into init hook

Project:Feedjit
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

On the beginning of the module file there are variables which are declared directly in file, which using t() function.
It's not good idea to to that.

global $_feedjit_color_names, $_feedjit_schemes;
$_feedjit_color_names = array('bc', 'tc', 'brd1', 'lnk', 'hc');
$_feedjit_schemes = array( // in color.module format
  '#FFFFFF,#494949,#336699,#494949,#336699' => t('Feedjit Neutral'),
  '#E8F6BE,#666666,#C4C4C4,#666666,#7F7F7F' => t('Feedjit Green'),
...
);

During loading the files, module making mysql access and slowing down loading process and some functionality can be not available in this time (like caching, other handling, etc).
It's better to move this code into init or boot hook.

Like:

/**
* Implementation of hook_init().
*/
function feedjit_init() {
    global $_feedjit_color_names, $_feedjit_schemes;
    $_feedjit_color_names = array('bc', 'tc', 'brd1', 'lnk', 'hc');
...
}

Comments

#1

True. If I was going to start messing around with this module, I should probably add:

- fetch colorsets in a hook, allowing other modules to add new alternatives

- allow user-configurable colorsets

nobody click here