1
votes

I am using Drupal 6.26. When I update my page arguments for example from 150 to 50, I refresh the page and see no changes. I only see the change when I clear the cache from the performance page. The settings for cache are all turned off as I am locally testing Drupal on Windows. Now I know on Drupal 5 you have the boolean flag which is $may_cache but looking at the API this option doesn't exist for Drupal 6.

Is there a way of not clearing the cache every time to see a change?

function usman_menu(){

$items['usman/hello'] = array(
        'page callback' => 'usman_example',
        'access callback' =>'user_access',
        'access arguments' =>array('access content')
);

$items['usman'] = array(
        'page callback' => 'usman_begin',
        'page arguments' => array('150'), 
        'access callback' =>'user_access',
        'access arguments' =>array('access content')
);
return $items;
}

function usman_begin($id = 20, $message = "YES", $optional = "NO"){

print "Loaded " . __FUNCTION__;
print "<br/>";
print "ID is $id, Message is $message, Option is $optional";
}

OK I have learned something about the menu hooks now. I was just playing with code to see how the paths work with arguments and placeholders. It was refreshing quick enough for me to test and had to resort to clearing the cache. I find this weird, considering there is no option to disable such caching temporarily through the performance page, just for a developer.

Thanks.

2

2 Answers

1
votes

I don't know of any way to do that without changing core files (which is not a good idea obviously).

Menu items are cached and won't be refreshed until menu_rebuild() is called, which doesn't happen until you flush the caches (or invoke one of a few other admin tasks).

Whichever way you do it you'll have to clear at least the cache_menu table, otherwise hook_menu() simply won't be invoked.

1
votes

If I understand your question correctly, my answer would be no.

I am assuming you are changing the argument value in 'page arguments' => array('150'). Since this entire definition gets cached and when the same path is accessed next time, the cached data is used and hook_menu is not called.

The only suggestions I can offer are:

  • For quick and dirty testing, override the value of the variable in the function (callback) itself.
  • Use a module/script to clear the cache tables on every reset. e.g. drush cc all, or use devel.