<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Unfortunately, situation stayed the same.<br>
<br>
I created a screenshot of the output of the function, so people can see
what exactly is in the node object:<br>
<br>
<a class="moz-txt-link-freetext" href="http://i.imgur.com/7ig0B.png">http://i.imgur.com/7ig0B.png</a><br>
<br>
Brian<br>
<br>
On 10-07-23 10:12 AM, Justin Ellison wrote:
<blockquote
 cite="mid:AANLkTi=fd1NO0PDJK6vRMjnbWKjqQV+_MN+dQJfYeNcG@mail.gmail.com"
 type="cite">Try sticking this in your function:
  <div><br>
  </div>
  <div>static $nodecount = 0;</div>
  <div>$node = node_load($nid);&nbsp;</div>
  <div>$nodecount++;</div>
  <div>if ($nodecount % 50 == 0) {</div>
  <div>&nbsp;&nbsp;node_load(NULL,NULL,TRUE);</div>
  <div>}</div>
  <div>&nbsp;&nbsp;<br>
  <br>
  <div class="gmail_quote">On Fri, Jul 23, 2010 at 8:46 AM, Brian Vuyk <span
 dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:brian@brianvuyk.com">brian@brianvuyk.com</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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?<br>
    <br>
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:<br>
    <br>
&lt;?php<br>
    <br>
function migration_fix_photos($nid) {<br>
&nbsp;$node = node_load($nid);<br>
&nbsp;dpm($node);<br>
&nbsp;drupal_set_message('NID is ' . $nid);<br>
}<br>
?&gt;<br>
    <br>
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-&gt;title, $node-&gt;nid, $node-&gt;uid and $node-&gt;type are
missing from the object, among other portions.<br>
    <br>
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.<br>
    <br>
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).<br>
    <br>
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
&nbsp;requests the browser is making.<br>
  </blockquote>
  </div>
  <br>
  </div>
</blockquote>
<br>
</body>
</html>