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.