The custom_pub_schema_alter function causes the init_theme() function to load. Because the schema alters happen before hook_init gets triggered, this means that theme_init gets called before hook_init.

This causes an issue because the admin_theme is set/detected in system_init. At that point, since the theme engine is already loaded, it will use the site's default theme instead of the admin theme.

More detailed view of what's going on:
custom_pub_schema_alter:

function custom_pub_schema_alter(&$schema) {
	$types = variable_get('custom_pub_types', array());
	foreach ($types as $type => $name) {
		$schema['node']['fields'][$type] = array(
        'description' => t('Custom publishing option @name',array('@name' => $name)),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0);
	}
}

The call to t() uses the % character for its token. If you look at the definition for t(), meaning that it will pass through the theme('placeholder') function. See common.inc lines 929-942:

switch ($key[0]) {
        case '@':
          // Escaped only.
          $args[$key] = check_plain($value);
          break;

        case '%':
        default:
          // Escaped and placeholder.
          $args[$key] = theme('placeholder', $value);
          break;

        case '!':
          // Pass-through.

Any call to theme() causes a call to init_theme. Once init_theme is called for the first time, the global $theme value is set, meaning that the theme for the page is set.

Possible work-arounds:
Change the call to t() to use the Escaped-only token, '@', or to use the pass-through, '!'.

CommentFileSizeAuthor
#1 custom_pub.patch667 bytescraigmc
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

craigmc’s picture

FileSize
667 bytes

Patch attached, changed to use '@'.

Note: Patch generated from root of Drupal install.

arcaneadam’s picture

Status: Active » Closed (fixed)