User login

t() call in hook_info in Usernode causes too much locale caching

t() hook node_info Drupal
cannot use t() in custom node declaration?
hook_node_info

Our latest culprit in the Drupal refresh wars: Usernode.

array(19) {
[0]=>
array(4) {
["file"]=>
string(41) "/var/www/d53/modules/locale/locale.module"
["line"]=>
int(172)
["function"]=>
string(20) "locale_refresh_cache"
["args"]=>
array(0) {
}
}
[1]=>
array(4) {
["file"]=>
string(32) "/var/www/d53/includes/common.inc"
["line"]=>
int(732)
["function"]=>
string(6) "locale"
["args"]=>
array(1) {
[0]=>
&string(8) "Usernode"
}
}
[2]=>
array(4) {
["file"]=>
string(74) "/var/www/d53/modules/contributed/usernode-5.x-1.3/usernode/usernode.module"
["line"]=>
int(23)
["function"]=>
string(1) "t"
["args"]=>
array(1) {
[0]=>
&string(8) "Usernode"
}
}
[3]=>
array(2) {
["function"]=>
string(18) "usernode_node_info"
["args"]=>
array(0) {
}
}
[4]=>
array(4) {
["file"]=>
string(32) "/var/www/d53/includes/module.inc"
["line"]=>
int(406)
["function"]=>
string(20) "call_user_func_array"
["args"]=>
array(2) {
[0]=>
&string(18) "usernode_node_info"
[1]=>
&array(0) {
}
}
}
[5]=>
array(4) {
["file"]=>
string(37) "/var/www/d53/modules/node/node.module"
["line"]=>
int(351)
["function"]=>
string(17) "module_invoke_all"
["args"]=>
array(1) {
[0]=>
&string(9) "node_info"
}
}
[6]=>
array(4) {
["file"]=>
string(37) "/var/www/d53/modules/node/node.module"
["line"]=>
int(231)
["function"]=>
string(17) "_node_types_build"
["args"]=>
array(0) {
}
}
[7]=>
array(4) {
["file"]=>
string(37) "/var/www/d53/modules/node/node.module"
["line"]=>
int(433)
["function"]=>
string(14) "node_get_types"
["args"]=>
array(2) {
[0]=>
&string(6) "module"
[1]=>
&object(stdClass)#1 (19) {
["nid"]=>
string(3) "620"
["vid"]=>
string(3) "980"
["type"]=>
string(12) "action_space"
["status"]=>
string(1) "1"
["created"]=>
string(10) "1195811091"
["changed"]=>
string(10) "1195811091"
["comment"]=>
string(1) "0"
["promote"]=>
string(1) "0"
["sticky"]=>
string(1) "0"
["revision_timestamp"]=>
string(10) "1195811091"
["title"]=>
string(5) "alone"
["body"]=>
string(0) ""
["teaser"]=>
string(0) ""
["log"]=>
string(0) ""
["format"]=>
string(1) "0"
["uid"]=>
string(1) "1"
["name"]=>
string(6) "submin"
["picture"]=>
string(0) ""
["data"]=>
string(156) "a:5:{s:23:"subscriptions_subscribe";i:1;s:8:"og_email";s:1:"1";s:18:"subscriptions_auto";i:0;s:20:"subscriptions_teaser";i:1;s:18:"admin_compact_mode";b:0;}"
}
}
}
[8]=>
array(4) {
["file"]=>
string(37) "/var/www/d53/modules/node/node.module"
["line"]=>
int(453)
["function"]=>
string(9) "node_hook"
["args"]=>
array(2) {
[0]=>
&object(stdClass)#1 (19) {
["nid"]=>
string(3) "620"
["vid"]=>
string(3) "980"
["type"]=>
string(12) "action_space"
["status"]=>
string(1) "1"
["created"]=>
string(10) "1195811091"
["changed"]=>
string(10) "1195811091"
["comment"]=>
string(1) "0"
["promote"]=>
string(1) "0"
["sticky"]=>
string(1) "0"
["revision_timestamp"]=>
string(10) "1195811091"
["title"]=>
string(5) "alone"
["body"]=>
string(0) ""
["teaser"]=>
string(0) ""
["log"]=>
string(0) ""
["format"]=>
string(1) "0"
["uid"]=>
string(1) "1"
["name"]=>
string(6) "submin"
["picture"]=>
string(0) ""
["data"]=>
string(156) "a:5:{s:23:"subscriptions_subscribe";i:1;s:8:"og_email";s:1:"1";s:18:"subscriptions_auto";i:0;s:20:"subscriptions_teaser";i:1;s:18:"admin_compact_mode";b:0;}"
}
[1]=>
&string(4) "load"
}
}
[9]=>
array(4) {
["file"]=>
string(37) "/var/www/d53/modules/node/node.module"
["line"]=>
int(541)
["function"]=>
string(11) "node_invoke"
["args"]=>
array(2) {
[0]=>
&object(stdClass)#1 (19) {
["nid"]=>
string(3) "620"
["vid"]=>
string(3) "980"
["type"]=>
string(12) "action_space"
["status"]=>
string(1) "1"
["created"]=>
string(10) "1195811091"
["changed"]=>
string(10) "1195811091"
["comment"]=>
string(1) "0"
["promote"]=>
string(1) "0"
["sticky"]=>
string(1) "0"
["revision_timestamp"]=>
string(10) "1195811091"
["title"]=>
string(5) "alone"
["body"]=>
string(0) ""
["teaser"]=>
string(0) ""
["log"]=>
string(0) ""
["format"]=>
string(1) "0"
["uid"]=>
string(1) "1"
["name"]=>
string(6) "submin"
["picture"]=>
string(0) ""
["data"]=>
string(156) "a:5:{s:23:"subscriptions_subscribe";i:1;s:8:"og_email";s:1:"1";s:18:"subscriptions_auto";i:0;s:20:"subscriptions_teaser";i:1;s:18:"admin_compact_mode";b:0;}"
}
[1]=>
&string(4) "load"
}
}
[10]=>
array(4) {
["file"]=>
string(60) "/var/www/d53/modules/contributed/og-5.x-4.0.tar/og/og.module"
["line"]=>
int(250)
["function"]=>
string(9) "node_load"
["args"]=>
array(1) {
[0]=>
&int(620)
}
}
[11]=>
array(4) {
["file"]=>
string(60) "/var/www/d53/modules/contributed/og-5.x-4.0.tar/og/og.module"
["line"]=>
int(212)
["function"]=>
string(12) "og_set_theme"
["args"]=>
array(1) {
[0]=>
&string(3) "620"
}
}
[12]=>
array(4) {
["file"]=>
string(60) "/var/www/d53/modules/contributed/og-5.x-4.0.tar/og/og.module"
["line"]=>
int(146)
["function"]=>
string(8) "og_theme"
["args"]=>
array(0) {
}
}
[13]=>
array(2) {
["function"]=>
string(7) "og_init"
["args"]=>
array(0) {
}
}
[14]=>
array(4) {
["file"]=>
string(32) "/var/www/d53/includes/module.inc"
["line"]=>
int(406)
["function"]=>
string(20) "call_user_func_array"
["args"]=>
array(2) {
[0]=>
&string(7) "og_init"
[1]=>
&array(0) {
}
}
}
[15]=>
array(4) {
["file"]=>
string(32) "/var/www/d53/includes/common.inc"
["line"]=>
int(1860)
["function"]=>
string(17) "module_invoke_all"
["args"]=>
array(1) {
[0]=>
&string(4) "init"
}
}
[16]=>
array(4) {
["file"]=>
string(35) "/var/www/d53/includes/bootstrap.inc"
["line"]=>
int(885)
["function"]=>
string(22) "_drupal_bootstrap_full"
["args"]=>
array(0) {
}
}
[17]=>
array(4) {
["file"]=>
string(35) "/var/www/d53/includes/bootstrap.inc"
["line"]=>
int(822)
["function"]=>
string(17) "_drupal_bootstrap"
["args"]=>
array(1) {
[0]=>
&int(7)
}
}
[18]=>
array(4) {
["file"]=>
string(22) "/var/www/d53/index.php"
["line"]=>
int(13)
["function"]=>
string(16) "drupal_bootstrap"
["args"]=>
array(1) {
[0]=>
&int(7)
}
}
}

Looking at the code, there doesn't seem to be anything inherently wrong with using t() in the node_info hook. A handbook page on Drupal uses it, and the API models it with t().

So what's special about my installation of locale that line 23 of the usernode module is triggering a locale_refresh_cache?

Also, it's interesting to know (now) that, according to comments in the code (not in the README or anywhere else) that we could have deleted that hook entirely by setting define('USERNODE_CONTENT_TYPE', "usernode"); to our own content type-- why doesn't nodeprofile recommend this?

/**
* Defines the used content type for the nodes.
*
* You may change this to your custom nodetype, if you do so you may also remove
* the next 6 functions, however reimplementing hook_delete would be suggested.
*/

Resolution

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.