[development] node_load() oddness

Steven Jones steven.jones at computerminds.co.uk
Fri Jul 23 13:51:06 UTC 2010


Hi Brian,

What happens if you bypass the static caching in node_load, by
changing your node_load call to:

$node = node_load($nid, NULL, TRUE);

Does that change anything?


Regards
Steven Jones
ComputerMinds ltd - Perfect Drupal Websites

Phone : 024 7666 7277
Mobile : 07702 131 576
Twitter : darthsteven
http://www.computerminds.co.uk



On 23 July 2010 14:46, Brian Vuyk <brian at brianvuyk.com> wrote:
> Can anyone think of a situation where a node_load() contained in a function
> returns partial results when the function is called from a batch script?
>
> I have a simple function that I am calling the from a batch API script that
> processes through a bunch of nodes to fix filepaths in certain migrated
> content. I've begun experiencing a strange issue while testing it; I've
> boiled it down to the following test case:
>
> <?php
>
> function migration_fix_photos($nid) {
>  $node = node_load($nid);
>  dpm($node);
>  drupal_set_message('NID is ' . $nid);
> }
> ?>
>
> When I call this function with a given NID from a batch script, on some
> runs, the $node object returned by $node_load is only partially loaded - it
> has 3 of the 10-12 CCK fields the node should contain, also, $node->title,
> $node->nid, $node->uid and $node->type are missing from the object, among
> other portions.
>
> The behavior changes between runs of the batch script. I can run a testing
> run, and only get partially loaded nodes. I can re-run the batch script, and
> they are fully loaded. Note that this changes per-run of the batch script,
> not per-call of the function. That is, when the batch script operates on
> 2000 nodes, the partial node_load() will or will not happen for all 2000
> times the above function is run. I could run the batch script again, and get
> perfectly normal results for all 2000 nodes next time.
>
> If I call the above function directly, it shows correct results every time.
> This only happens when called from a batch script. Note that the $nid
> argument is always shown as correct (tested with the drupal_set_message()
> call).
>
> Does anyone have any ideas why this is happening? I have tried using Xdebug,
> but I can't determine how to attach onto the background AJAX  requests the
> browser is making.
>


More information about the development mailing list