douqian6315 2015-02-04 14:59
浏览 39

Drupal hook_menu没有重新评估

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()); ?> through a PHP filter and it outputs the menu items array as expected.

EDIT:

Also I just tried <?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.

  • 写回答

1条回答 默认 最新

  • duanmeng1858 2015-02-05 08:49
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大