On a more practical level: When I'm building a feature which defines the menu's for my site, should I export the menu_masks variable too?
menu_masks is a Drupal variable used to find the possible ancestors of a menu item. It contains an array of values that are calculated from the paths defined from modules; each values is essentially a binary number where the digit is 1 when the path part doesn't contain a placeholder, and 0 when it contains a placeholder. For example, the number for node/%node/edit is 9 (101 in base 2), while the number for admin/structure/types/manage/%comment_node_type/comment/fields is 123 (1111011 in base 2).
The reason why numbers are used is avoid comparing strings; plus those numbers are easily sorted in a way that a number matching a path without placeholders is placed before a number matching a path with one or more placeholders. (The number for %/%/% would be 0, while the number for admin/appearance/list is 13.)
menu_get_ancestors() doesn't return the ancestors of the path passed as argument, but the possible ancestors. Passing
array('node', '12', 'edit') to the function, I would get the an array containing the following values, as result.
In my test site, only the third, the fifth, and the sixth are paths defined by the modules I installed.
You don't need to export the menu_masks variable: Its content is very specific for the site and it is re-calculated when
menu_rebuild() is called.
Drupal is still able to work correctly even in the case
menu_rebuild() is not yet called, and that Drupal variable has not been set. You should not notice any performance issue, but if that would be the case, you can call
menu_rebuild() or force Drupal to call that function; if you have the Devel module installed, you can easily force Drupal to rebuild its menus.