Pass variables from html preprocess function to page preprocess function? In my custom theme's hook_preprocess_page() and hook_preprocess_html() functions, I often need to identify the same information. Rather than essentially running the same if statement checks in both the identify the same info, it would make much more sense to just do it once in both of them and then pass that info to the other preprocess function. How can I do this? I tried the following but it didn't work:

function myTheme_preprocess_page(&amp;$vars){
    $vars['myValue'] = 7;
}

function myTheme_preprocess_html(&amp;$vars){
    //$vars['myValue'] should equal 7...
}


I also tried it the other way around (setting the value in the preprocess html function and then retrieving it in the page preprocess function) but that didn't work either. Which brings up a related question: in what order are these preprocess functions, er, processed? It seems to me that the page preprocess function comes before the html one, is that correct?
You're going to need either a global or static variable to accomplish this...personally I'd recommend going with static and implementing a generic helper function using Drupal's static pattern like so:

function _myTheme_var($var_name, $new_val = NULL) {
  $vars = &amp;drupal_static(__FUNCTION__, array());

  // If a new value has been passed
  if ($new_val) {
    $vars[$var_name] = $new_val;
  }

  return isset($vars[$var_name]) ? $vars[$var_name] : NULL;
}

function myTheme_preprocess_page(&amp;$vars){
  $vars['some_var'] = _myTheme_var('my_var', 7); // Set the value and retrieve it
}

function myTheme_preprocess_html(&amp;$vars){
  $vars['some_var'] = _myTheme_var('my_var'); // Get the value
}


The $vars arrays for each preprocess function are completely different objects in memory so you won't be able to use that array to pass things around. I've seen this sort of pattern used a lot in Drupal core so I think it would be the best way to go.

EDIT

Oh and yes, hook_preprocess_page() is called before hook_preprocess_html()...as far as I'm aware Drupal works in a sort of "inside-out" manner so hook_preprocess_html() would probably be the last one that's run in a page build.