简体   繁体   中英

Drupal hook_menu not re-evaluated

I have recently deployed an update to a staging site where-by I am completely unable to get hook_menu() to re-evaluate. The hook already existed before the update and was providing one item. After the update it should provide 2 items however no matter what I cannot get the hook to fire.

The new code works fine on my local dev environment of Ubuntu/LAMP however the staging platform is IIS7 / PHP FastCGI.

I have tried clearing the cache by sys>dev>performance, by the various links provided by the admin menu, by cache_clear_all() and drupal_flush_all_caches() in index.php .

I've tried stopping/starting/restarting IIS.

There doesn't appear to be any running opcode caching as far as I can tell from phpinfo() , no relevant mentions of "cache" or "apc".

I've added die() commands into the mymodule_menu() code and it seems that the hook is not firing at all. The menu_router table receives no new entry, although it retains the single previously-existing menu item.

I know the module is running as I can put die() into the previously existing menu item's page callback and it kills PHP.

I also know that new hooks have been evaluated as the same code update provided also provides a mymodule_page_alter() hook which fires successfully.

Starting to reach the end of my tether! What else can I try?

EDIT:

Another thing I've done is prove that mymodule_hook() is named correctly. I've run <?php print_r(mymodule_menu()); ?> <?php print_r(mymodule_menu()); ?> through a PHP filter and it outputs the menu items array as expected.

EDIT:

Also I just tried <?php print_r(module_implements('menu')); ?> <?php print_r(module_implements('menu')); ?> through a PHP filter and I can see mymodule in the array.

EDIT:

My hook_menu implementation:

/**
 * Implements hook_menu().
 */
function mymodule_menu() {
  $items = array();
  $items['google-search'] = array(
    'page callback' => 'mymodule_google_search_page',
    'access callback' => TRUE,
    'title' => 'Search Results'
  );
  $items['mymodule-header-footer'] = array(
    'page callback' => 'mymodule_header_footer',
    'access callback' => TRUE,
    'title' => 'Header and Footer'
  );
  return $items;
}

From the above /google-search worked before and continues to work. /mymodule-header-footer is the offending item.

OK problem solved. In menu_rebuild() there's a transaction rollback try/catch and there was an error during menu_rebuild() that exposed the issue that backup and migrate module's schema was missing. This was due to a production engineer deploying backup and migrate module to production, but not feeding it upstream. Somehow the backup and migrate module was flagged as enabled, even though the schema had not been created on staging. Still mysterious, but uninstalling/reinstalling the module allows menu_rebuild() to complete successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM