diff --git a/token_custom.module b/token_custom.module index 06de8f0..927c665 100644 --- a/token_custom.module +++ b/token_custom.module @@ -485,11 +485,11 @@ function token_custom_token_render($machine_name, $code, $data, $options) { */ if ($format == 'php_code') { - /* - * Add a random hash to make sure no other encapsulated token_replace call - * will get the same (or change) this $data array. - */ - $static_key = 'token_custom_' . drupal_random_bytes(10); + // Build a stack of static keys. + $static_count = &drupal_static('token_custom_data:count', 0); + + // Generate static key from current stack count. + $static_key = 'token_custom_data:' . $static_count; /* * Store value in static cache and leave it there. @@ -500,6 +500,9 @@ function token_custom_token_render($machine_name, $code, $data, $options) { 'options' => $options, )); + // Push a level onto the static stack. + $static_count ++; + // Add static data to the evaluated code. $code = ' ' . $code; $output = check_markup($code, $format); + + // Pop a level off the static stack. + $static_count --; + drupal_static_reset($static_key); + return $output; } else {