node_load in drupal gets incorrect node when you are NOT logged in

Posted by Alaa on Stack Overflow See other posts from Stack Overflow or by Alaa
Published on 2010-12-29T17:49:50Z Indexed on 2010/12/29 17:54 UTC
Read the original article Hit count: 216

Filed under:
|
|
|

Hi All,

i have a module and i am using node_load(array('nid' => arg(1)));
now the problem is that this function keep getting its data for node_load from DB cache. how can i force this function to not use DB cache or static value? Example
my link is http://mydomain.com/node/344983
now:
$node=node_load(array('nid'=>arg(1)),null,true);
echo $node->nid;
output:
435632
which is a randomly node id (available in the database)
and everytime i ctrl+F5 my browser, i get new nid!!
Note: if i am logged in, it gives the result correctly, but this problem happens only when i am browsing the website as an anonymous user

i really appreciate any idea!! Thanks

© Stack Overflow or respective owner

Related posts about drupal

Related posts about caching