Node displays: racing condition in preprocess_hooks

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

Node displays implements nd_preprocess_node so all data for a node can be rendered into a node region. However, as identified and discussed on http://drupal.org/node/570592, a themer/developer can implement other preprocess functions (see http://drupal.org/node/223430) which will be called later in the theming process. This can cause situations where your data isn't up to date. To overcome this, you need to do 2 things:

1) Paste following snippet at the bottom of the preprocess_hook function.

  /**
   * Node displays preprocess function.
   */
  if (function_exists('_nd_preprocess_node') && variable_get('nd_preprocess_override', FALSE)) {
    _nd_preprocess_node($vars, $hook);
  }

In case the preprocess function lives in a contrib module and it does not exists in template.php of your default theme, add following snippet into that file:

function phptemplate_preprocess_node(&$vars, $hook) {
  /**
   * Node displays preprocess function.
   */
  if (function_exists('_nd_preprocess_node') && variable_get('nd_preprocess_override', FALSE)) {
    _nd_preprocess_node($vars, $hook);
  }
}

2) Open settings.php and add following variable:

$conf['nd_preprocess_override'] = TRUE;

This will make sure nd_preprocess_node in the module will not fire the preprocess helper function, but will be called later on.

Help improve this page

Page status: Not set

You can: