Thanks a lot, glad that I asked this before pulling my hairs out coz for some reason It never occurred to me that it could be a bug in views. :)<div><br></div><div> It worked after applying the patch. </div><div><br></div>
<div> Thanks again!<br>
<br><br><div class="gmail_quote">On Sat, Jun 4, 2011 at 10:17 PM, Earl Miles <span dir="ltr"><<a href="mailto:merlin@logrus.com">merlin@logrus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You're in a batch, and Views has a bug with batches. It's fixed in the<br>
-dev version: See <a href="http://drupal.org/node/829550" target="_blank">http://drupal.org/node/829550</a><br>
<div><div></div><div class="h5"><br>
On 6/4/2011 7:59 AM, Dipen wrote:<br>
> Hi,<br>
><br>
> I am badly stuck at this one, I am trying to convert a cron function<br>
> to batched drush execution to overcome memory limits etc. I could<br>
> have gone for queued cron execution but in my initial assessment I<br>
> found batched drush execution simpler. Anyways, I am using<br>
> views_savedsearches to allow my users to keep a tab on their exposed<br>
> filters, since the data keeps coming in for their criteria I am also<br>
> using notifications_views_savedsearches (which comes in the same<br>
> package) to notify them if they have subscribed to their saved<br>
> searches. So All is good except the amount of content is huge for<br>
> hook_cron of notifications_views_savedsearches to process without<br>
> memory errors which prompted me to convert it into batched drush<br>
> execution.<br>
><br>
> So I got to a good start and quickly deconstructed (almost) the<br>
> notifications_views_savedsearches_cron implementation into batch<br>
> process to be run by drush. Everything is fine, except that<br>
> $view->execute() doesn't return any result for my implementation but<br>
> does yield results in the original implementation. This is the place<br>
> I am stuck, few things to note here:<br>
><br>
> 1> $view Object just before calling $view->execute() is exactly same<br>
> for both implementations ( old cron and new batch worker process ), I<br>
> ran a diff couple of times. Please note that both functions have<br>
> practically same code except that I had to write couple of extra<br>
> function to make batch work. 2> On further investigation found out<br>
> that query and count query are same too but args are different.<br>
><br>
> Am I wrong to assume that calling execute() on two identical view<br>
> objects can lead to different results? Atleast thats what I am<br>
> experiencing? (There is no additional processing on the view object,<br>
> they are exactly same before execute() is called on them)<br>
><br>
> On further investigation found out that the view object of my batch<br>
> worker process has $this->exposed_data empty and thats the reason<br>
> for args to be malformed and for query to returning empty result. I<br>
> haven't been able to find out much on why is exposed_data set in one<br>
> view and not in other when they were identical before calling<br>
> execute() on them, looking at call stack, I found out much of the<br>
> query building and pre processing is done in $this->build and<br>
> $this->_build($key) and thats where $this->exposed_data is bailing<br>
> out on me.<br>
><br>
> Some of the debugged Arrays:<br>
><br>
> $args for the cron function (the one thats working) - Array ( [0] =><br>
> drealty_property [1] => 0 [2] => 100000000 [3] => 0 [4] => 0 [5] =><br>
> 39 )<br>
><br>
> $this->exposed_data returns a healthy array<br>
><br>
> One thats not working ( my batched execution $args) :<br>
><br>
> Array ( [0] => drealty_property [1] => [2] => [3] => [4] => [5] =><br>
> [6] => )<br>
><br>
> $this->exposed_data doesn't return anything.<br>
><br>
><br>
> Code of both functions is almost same and the $view object just prior<br>
> to $view->execute() is exactly identical.<br>
><br>
> Has anyone faced anything similar? Could it be due to the batch API?<br>
> I am using drush_backend_batch_process() to process my batch.<br>
> Everything else is working except that my batch process doesn't have<br>
> anything in $view->result. I haven't been able to find where does<br>
> $this->exposed_data get set.<br>
><br>
> Crux of code for both function is:<br>
><br>
> $vs = views_savedsearches_load($subscription['sid']); // Retrieving<br>
> exposed filter setting for the subscriber using helper function of<br>
> views_savedsearches<br>
><br>
> $view_name = db_result(db_query("SELECT name FROM {views_view} WHERE<br>
> vid = %d", $vs->vid));<br>
><br>
> $view = views_get_view($view_name);<br>
><br>
> if (is_object($view) && is_object($vs)) { if ($view instanceof view)<br>
> {<br>
><br>
> // Apply $vs->filters $view->set_exposed_input($vs->filters);<br>
><br>
> // The original code limits this value to 10 which is not much useful<br>
> as new data at any point of time is anytime more than 10<br>
> $view->pager['items_per_page'] = 0;<br>
><br>
> // Run the query // $view at this point in both functions is<br>
> exactly same ( did a diff ) $view->execute('default');<br>
><br>
> $view->result is empty for my batch process but has values for the<br>
> old cron function. I am pretty sure(?), that I am not making a silly<br>
> variable in scope mistake.<br>
><br>
><br>
> Thanks in Advance<br>
><br>
><br>
><br>
> ---------------------------------- Dipen Chaudhary QED42 : We build<br>
> beautiful and scalable web strategies ( <a href="http://www.qed42.com" target="_blank">www.qed42.com</a><br>
</div></div>> <<a href="http://www.qed42.com" target="_blank">http://www.qed42.com</a>> ) Blog: <a href="http://dipenchaudhary.com" target="_blank">dipenchaudhary.com</a><br>
> <<a href="http://dipenchaudhary.com" target="_blank">http://dipenchaudhary.com</a>> Twitter: <a href="http://twitter.com/dipench" target="_blank">http://twitter.com/dipench</a><br>
><br>
<br>
</blockquote></div><br></div>