I have been pulling my hair out over this one for days...

I made a module which creates a page.

The module works fine as far as I can tell until I go and clear the sites cache.

At this point the page becomes un-accessible.

I tried rebuilding the sites permissions to no effect.

Frustrated I rewrote the module from scratch by copying and pasting the code into a new module.

It works fine, until I was forced to refresh the cache again to update some java script libraries...

Is there another rebuild that I am missing besides permissions that could be failing?

I have tried disabling and re-enabling the module and the permissions as well.

Comments

joshi.rohit100’s picture

Which module page are you talking about ?
admin/module or your custom menu created in custom module.

If custom menu in custom module, please can you share the code ?

Jaypan’s picture

You should always show code. Otherwise we are just guessing.

Did you put the page callback in a file other than the .module file?

If so, you need to add the 'file' attribute to your hook_menu() definition.

If not, you need to show us some code so we aren't trying to guess what you did.

earnshae’s picture

The thing is I didn't change the code I just cleared the cache and it stopped working.

Anyways here is the code from the from the hook_menu function which is what I believe is relevant:

function avif_view_ownership_menu() {

   $items['avif/view/ownership/%display'] = array(
      'title' => t('Fund Ownership Report'),
      'page callback' => 'view_ownership_page',
      'access arguments' => array('access avif ownership'),
   );

	return $items;
}

And here is the code from the hook_permission which may also have some effect:

function avif_view_ownership_permission() {
 $perms = array(
    'access avif ownership' => array(
      'title' => t('access avif ownership'),
      'description' => t('Enable to allow the user/role to view fund family ownership levels.'),
    ),    
  );

  return $perms;
}

The call back function is in the same file I can post it to if it is relevent.

earnshae’s picture

I was looking at the following code from page_example_menu
...

  $items['examples/page_example/arguments/%/%'] = array(
    'title' => 'Page example with arguments',
    'page callback' => 'page_example_arguments',
    'page arguments' => array(3, 4),
    'access arguments' => array('access arguments page'),
    'type' => MENU_CALLBACK,
  );

Could it be the lack of:

    'type' => MENU_CALLBACK,

or

    'page arguments' => array(3, 4),

I based my code off of the form api menu callbacks so I didn't think to include these two items?

Jaypan’s picture

Did you put the page callback in a file other than the .module file?

earnshae’s picture

The page call back is in the .module file.

joshi.rohit100’s picture

Have you checked the autoload part for %dispplay ?

earnshae’s picture

What do you mean by auto load?

earnshae’s picture

Is there a table in drupal somewhere, that stores the url's given by the menu function?

My gut is telling me that if I look at that table I will probably find one or more corrupted records.

earnshae’s picture

So I have looked and found that for some reason all my other modules have information stored in the menu router table but not this one.

Could there be a problem with the calling of the menu function perhaps?

Jaypan’s picture

What's the machine name of your module?

earnshae’s picture

Ok here is where I am at:

I have files named:

avif_report_ownership.info
avif_report_ownership.module

The contents of the info file:

name = Fund Ownership Report
description = A module that allows the user to view a ownership report.
core = 7.x
package = AVIF Reports
version = 20140322

The contents of the module file:

<?php

function avif_report_ownership_permission(){
 $perms = array(
    'access avif report' => array(
      'title' => t('access avif report_ownership'),
      'description' => t('Enable to allow the user/role to view fund family ownership levels.'),
    ),    
  );

  return $perms;

}

function avif_report_ownership_menu(){
   $item=array();
   
   $items['avif/report/ownership/'] = array(
      'title' => t('Fund Ownership Report'),
      'page callback' => 'report_ownership_page',
      'access callback' => 'user_access',
      'access arguments' => array('access avif report'),
   );
   
   return $items;


}

function report_ownership_page(){
   $page = array();
   return $page;
}

Result, The following error:

The requested page "/avif/report/ownership/" could not be found.

... and me pulling my hair out...

earnshae’s picture

Okay so far this seems to be working at this url:

site/avif/ownership/report/

for some reason %display seems to have something to do with it.... I wonder if it was a reserved word some where or some such.

<?php

function avif_report_ownership_permission(){
 $perms = array(
    'access avif report' => array(
      'title' => t('access avif report_ownership'),
      'description' => t('Enable to allow the user/role to view fund family ownership levels.'),
    ),    
  );

  return $perms;

}

function avif_report_ownership_menu(){
   $item=array();
  
   $items['avif/ownership/report/%'] = array(
    'title' => 'Ownership Report',
    'page callback' => 'ownership_report',
    'page arguments' => array(3),
    'access arguments' => array('access avif report'),
    'type' => MENU_CALLBACK,
   );

   
   return $items;


}

function ownership_report($display) {
   $page = array();
   drupal_set_message($display);
   return $page;
}

nevets’s picture

Think of '%' being anonymous argument, it can be any value. When you use a named argument like display there needs to be an auto loader as mentioned earlier. In this case it is expect a function called display_load(). It is generally used to convert and argument from a string/number to an object. So then the callback function would expect the object.

Jaypan’s picture

This:

   $items['avif/report/ownership/'] = array(

Should not have a trailing slash. It should be this:

   $items['avif/report/ownership'] = array(
earnshae’s picture

It's always the little things :|

Thanks allot.