Building a view programmatically fails when filtering specific nids but not others I am quite stuck with this, so I hope you can help me out…

I have a view which filters (contextual filter) by 'nid'. I have two 'filter criteria's (view ui):


Published
Node type


I want to embed that view in a page programmatically through an Ajax call. I have discovered it sometimes returns the correct node and sometimes not. It depends on the specific node so for example it always retrieves the node nid = '4' and it never does for nid = '35'

Trying to figure out where the problem comes from I have tried few things. For example: I have tried to embed the view using panels, just for testing, using arguments for the contextual filter. It always work (always retrieve the correct node) this way. But when I call the view programmatically from a form building function (the one I use inside 'drupal_get_form()'), it just work with some nodes (some values of nid). 

I am using devel for debugging and, when the view doesn't returns results,

$view-&gt;build_info['fail'] = TRUE


Here is the way I call the view:

$view = views_get_view('proyecto_en_arquitecto');
$view-&gt;init(); 
$view-&gt;set_display('block_1');
$view-&gt;set_arguments('35');
$view-&gt;execute();
dpm($view);  //Here is where I can see the building process fails


I am lost as I don't have a clue of why it just works with some nodes…

I hope you can point me to the right direction.

Thanks in advance for your help and let me know if you need further information.
The argument to the $views-&gt;set_arguments() function should be an array containing the arguments, even if only one, so, try:

$view-&gt;set_arguments(array(35));


or

$view-&gt;set_arguments(array($nid));


instead of passing the value in directly.

As to why it was working before sometimes, I am betting it was working with nids 1 thru 9 only, because there, for example, if $nid='4', $nid[0]=='4' is also true, but if $nid='35', $nid[0]=='35' is false (it is '3') but I leave this to another discussion, but look up "php strings as arrays" if you want to delve into it further.  This Strings as Arrays Q&amp;A gives a brief description/introduction.