First off, thanks for this module! The working parts are really a god send. It is however throwing a few errors.

Notice: Use of undefined constant MENU_MAX_PARTS - assumed 'MENU_MAX_PARTS' in _subdomain_id_from_path() (line 649 of /var/www/mysite/html/sites/all/modules/subdomain/subdomain.module).
Notice: Use of undefined constant MENU_MAX_PARTS - assumed 'MENU_MAX_PARTS' in _subdomain_id_from_path() (line 649 of /var/www/mysite/html/sites/all/modules/subdomain/subdomain.module).

Comments

inventlogic’s picture

Getting this error as well when I update modules.

Was this fixed as I have the latest version installed?

inventlogic’s picture

Title: Lots of errors from this module at the moment » MENU_MAX_PARTS called from menu.inc but menu.inc not included in function

In the subdomain.module file the function _subdomain_id_from_path on line 594 (approximately) is attempting to use functions and constants defined in the menu.inc include.

I think it is producing errors because the _subdomain_id_from_path is not a hook function so it cannot depend on automatic includes from the underlying main drupal functions the hook is calling.

I tried to fix this error by doing the following:

Edit the subdomain.module file and add after function _subdomain_id_from_path($type, $path) {
the following line: require_once('includes/menu.inc');

I think this works ok but I am not sure it is the correct Drupal way of accessing the menu.inc functions and constants.

The code from the function that is causing the problem is the following

    // Fallback on searching the menu system. We don't try this first since we want to try and avoid searching the DB.
    if (empty($id)) {
      $map = arg(NULL, $path);
      $parts = array_slice($map, 0, MENU_MAX_PARTS);
      $ancestors = menu_get_ancestors($parts);
      $router_item = FALSE;

      // See if we've seen a matching menu router item already for one of the ancestors
      foreach ($ancestors as $ancestor) {
        if (isset($router_items[$ancestor])) {
          $router_item = $router_items[$ancestor];
          break;
        }
      }

It seems to have been partly snagged from the menu_get_item function

 if (!isset($router_items[$path])) {
    // Rebuild if we know it's needed, or if the menu masks are missing which
    // occurs rarely, likely due to a race condition of multiple rebuilds.
    if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
      menu_rebuild();
    }
    $original_map = arg(NULL, $path);

    $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
    $ancestors = menu_get_ancestors($parts);
    $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();

So I suppose the question is can the value of the $router_item be gotten through standard Drupal hook functions?
Any help comments appreciated.

bartezz’s picture

Added require_once('includes/menu.inc'); as a temp workaround as mentioned, seems to fix this issue for now but ofcourse prob is just a temp workaround...

Cheers