Score:-1

hook_menu() items disappeared and no longer work

id flag

I'm feel like I'm losing my mind here. I have written a custom module and implemented hook_menu to add custom admin pages. Last week this worked perfectly - this week they stopped working then vanished altogether. I can't understand what the problem is and I can't even get simple pages to work now.

This is the code I am using.

nhs_session_judge.module

/**
 * Implements hook_menu().
 */
function nhs_session_judge_menu() {
  $items['admin/session-judging'] = array(
    'title' => 'Your judging',
    'page callback' => 'your_judging_page',
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

/**
 * Custom page callback
 */
function your_judging_page() {
  $content['raw_markup'] = array(
    '#type' => 'markup',
    '#markup' => '<p>This table shows at-a-glance the session bids you have already scored and those yet to be judged.</p>',
  );

  // …

  return $content;
}

If I use a backup of the database and visit the page, it works.

If I make a change, I get this error.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'your_judging_page' not found or invalid function name in menu_execute_active_handler()

If I clear the cache, the menu item disappears. Visiting the page by entering the URL directly in the browser address bar just redirects to /admin.

Does anyone know what's going on here? I can't make any changes/fixes to this because as soon as I do it breaks.

Score:0
id flag

Think I figured it out. I had a backup of the nhs_session_judge.module file in sites/all/modules/custom/bak/nhs_session_judge.module and I guess drupal was reading it instead of the sites/all/modules/custom/nhs_session_judge/nhs_session_judge.module I was working on, hence why my changes were ignored then lost.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.