Comments

mattyoung’s picture

jhodgdon’s picture

I'm confused from reading those other issues. Does this just need to be documented in Drupal 6, or does it also apply to Drupal 7?

mattyoung’s picture

I tested this and it's no longer a problem with D7

I wrote a tiny little module to call theme() in hook_init():

hookinitthemebugtest.info:

name = "Hook init theme bug test"
description = "Test if D7 hook_init() still have problem with theme call"
core = 7.x
package = Testing
files[] = hookinitthemebugtest.module

hookinitthemebugtest.module



function hookinitthemebugtest_theme($existing, $type, $theme, $path) {
  return array(
    'xyz' => array(
      'variables' => array('string' => NULL),
      'function' => 'hookinitthemebugtest_xyz',
    ),
  );
}


function hookinitthemebugtest_init() {
	
	
	$x = theme('xyz', t('xxx %here', array('%here' => 'there')));
	drupal_set_message($x,'status');
}



function hookinitthemebugtest_xyz($string) {
	
	return '==========='. $string .'=============';
	
}
jhodgdon’s picture

OK. Thanks for confirming that theme() is ok to call in hook_init() in Drupal 7, as this note says it should be: http://drupal.org/node/405578#comment-2206974

The original issue also mentions t() and node_load() as other functions not to call in hook_init(). Any ideas on that for Drupal 7?

jhodgdon’s picture

Title: Documentation problem with hook_init » hook_init() needs to document what functions are ok/not ok to call
Version: 6.x-dev » 7.x-dev

Looks like this is still a question for Drupal 7 documentation. I don't know the answer... anyone?

If all those are ok in D7, please move this issue back to D6 for doc fixes.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.