I've a
if(!$may_cache) { $item[] = array( 'path' => 'some/path', 'callback' => 'somefunction', ); }
function somefunction() { $result=db_query("..."); ... $output.=$somedynamicstuff; return $output; }
but the result get cached anyway.
Cache is set to normal.
What could it be?
thanks
Quoting Ivan Sergio Borgonovo mail@webthatworks.it:
I've a
if(!$may_cache) { $item[] = array( 'path' => 'some/path', 'callback' => 'somefunction', ); }
function somefunction() { $result=db_query("..."); ... $output.=$somedynamicstuff; return $output; }
but the result get cached anyway.
Cache is set to normal.
What could it be?
Could the problem be your assumption that the $may_cache in the hook_menu affects the form? Or am I missing your question?
-- Earnie -- http://r-feed.com/ -- http://for-my-kids.com/ -- http://www.4offer.biz/ -- http://give-me-an-offer.com/
On Sun, 19 Apr 2009 14:02:54 +0000 Earnie Boyd earnie@users.sourceforge.net wrote:
Quoting Ivan Sergio Borgonovo mail@webthatworks.it:
I've a
if(!$may_cache) { $item[] = array( 'path' => 'some/path', 'callback' => 'somefunction', ); }
function somefunction() { $result=db_query("..."); ... $output.=$somedynamicstuff; return $output; }
but the result get cached anyway.
Cache is set to normal.
What could it be?
Could the problem be your assumption that the $may_cache in the hook_menu affects the form? Or am I missing your question?
This is D5. And yeah even if the snippet didn't use a *form* there is a form involved in the real case.
So let's make the snippet more complete and add the steps to reproduce the problem.
/* hook_menu */ if(!$may_cache) { $item[] = array( 'path' => 'some/path1', 'callback' => 'stuffthatchangedb', ); $item[] = array( 'path' => 'some/path2', 'callback' => 'drupal_get_form', 'callback arguments' => array('stuffthatdependsondb'), ); }
function stuffthatchangedb() { db_query('insert values(someid, somefield) values(default, 97); drupal_goto('some/path2'); }
function stuffthatdependsondb() { $result = db_query("select someid, somefield from table1;"); while($row = db_fetch_array($result)) { $form['something'][$row['someid']] = array( '#type' => 'textfield', '#default_value" => $row['somefield'], ); } return $form; }
I visit some/path1. some/path1 add a record to table1 I get redirected to some/path2. I visit once more some/path1 some/path1 add a record to table1 some/path2 still show the content of the first time I visited it.
Real code is even more complicated... stuffthatchangedb is actually another form but suffice to say... I know it is doing it's duty and records get added to "table1", so my expectation is I'd see them in stuffthatdependsondb form, since drupal_get_form is called from the !$may_cache part of the menu hook.
If I disable the cache I don't incur in this problem.
Still I'd expect that stuff generated in the !$may_cache section of the menu don't get cached.
Quoting Ivan Sergio Borgonovo mail@webthatworks.it:
This is D5.
Yes, you said that before.
And yeah even if the snippet didn't use a *form* there is a form involved in the real case.
So let's make the snippet more complete and add the steps to reproduce the problem.
/* hook_menu */ if(!$may_cache) {
$may_cache only affects the items returned for the $menu.
$item[] = array( 'path' => 'some/path1', 'callback' => 'stuffthatchangedb', ); $item[] = array( 'path' => 'some/path2', 'callback' => 'drupal_get_form', 'callback arguments' => array('stuffthatdependsondb'), );
So the above will not be cached in the menu's cache.
}
function stuffthatchangedb() { db_query('insert values(someid, somefield) values(default, 97); drupal_goto('some/path2'); }
function stuffthatdependsondb() { $result = db_query("select someid, somefield from table1;"); while($row = db_fetch_array($result)) { $form['something'][$row['someid']] = array( '#type' => 'textfield', '#default_value" => $row['somefield'], ); } return $form; }
I visit some/path1. some/path1 add a record to table1 I get redirected to some/path2. I visit once more some/path1 some/path1 add a record to table1 some/path2 still show the content of the first time I visited it.
This has nothing to do with $menu_cache. It has to do with your page cache or the browser cache since you have caching set to normal. Reduce the cache lifetime in settings.php.
-- Earnie -- http://r-feed.com/ -- http://for-my-kids.com/ -- http://www.4offer.biz/ -- http://give-me-an-offer.com/
On Sun, 19 Apr 2009 16:14:05 +0000 Earnie Boyd earnie@users.sourceforge.net wrote:
This has nothing to do with $menu_cache. It has to do with your page cache or the browser cache since you have caching set to normal. Reduce the cache lifetime in settings.php.
"your page cache"? Is there a way to just say: "don't cache this" on a menu item base for anonymous users? If not on a "page" base? Where "page" is the function returning the $output?
reducing the cache lifetime is not going to work (the cache lifetime should be 0)... and it has a huge cost site-wide.
thanks