On my D7.80 I have developed a custom module:
function wrong_answer_menu() {
dd('it entered in hook menu');
$items['wrong-answer/%id'] = array(
'title' => t('Wrong Answer Dashboard'),
'page callback' => 'wrong_answer_dashboard',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
/**
* Callback: hook_menu.
*/
function wrong_answer_dashboard($node_param=NULL) {
dd('it entered in dashboard');
....
}
Everything was fine, I was developing the menu nicely accessing the mydomain.com/wrong-answer and everything was fine.
Then I wanted to add permissions to my custom module, so that only the admin can access this page hence I added the wrong_answer_permission function and in the dashboard function I checked if the user had permission to access the page
/**
* Implements hook_permission().
*/
function wrong_answer_permission() {
return array(
'wrong_answer_' => array(
'title' => t('View the wrong answer'),
),
);
}
function wrong_answer_dashboard($node_param=NULL) {
dd('it entered in dashboard');
if (!user_access('wrong_answer_admin')) {
return;
}
....
}
At this stage, when I accessed the page mydomain.com/wrong-answer I could still access it even though I did not assign the permission to it. Then I cleared the cache from the Performance menu via the admin/config/development/performance, and then I got the error message
The requested page "/wrong-answer/717" could not be found.
I get the same error for acessing just mydomain.com/wrong-answer.
Then I thought it was all fine, I added the permission wrong_answer_admin to the admin role, but then I still got the same error "The requested page .... could not be found.
Afterwards, I:
- cleared the cached
- removed the code that I had added on the permission and checking the user access
- rebuild the registry_file by emptying the table and running the update.php
- assigned the permission to the wrong_answer_admin to all the roles, including anonymous role
- deleted the wrong_answer_admin row in the permissions table in the database
- disabled and re-enabled by custom module
but nothing worked, I still get the error "The requested page cannot be found".
Then I noticed the strangest thing, that whenever I would clear the cache at, I would would get an entry in the drupal_debug.txt
it entered in hook menu
I do not get this entry in the drupal_debug.txt when accessing the wrong-answer page, I only get it when clearing the cache.
Could you please help me understand what is going on? why can't I access the wrong-answer page anymore?
Many thanks