Views_view_result and Devel possible incompatibility I have experienced a very strange behaviour of Drupal 7. I had Devel module activated, and a View which made the sql logs to disappear from screen. The view was used by views_get_view_result(). When I have changed the exact code to use views_embed_view(), with the same and exact rendering, the SQL logs started to appear again.

Is there some Drupal 7 expert (ninja level suspected) out there that can understand what could happen? The bug was consistent, it always happened in the same View config (I replicated different Views with different names and the behaviour always appeared at the same point).

The configuration that caused the problem was:


Field collection
View with field collection
Contextual filter (here it started to ignore sql log output)
Call to the function views_view_result. Even the call itself, without using the value, caused the problem.


Solution: Call views_view_embed() instead. No problem anymore. Same contextual filters, and blocks used. Exact configuration and exact output than views_view_result().

Note: I need an explanation of why this is happening, and a possible solution. The output of the SQL logging is not sent to the HTML source output of the page.

Code used. The commented lines do not work, and are substituted by the non-commented lines above them. The function is supossed to return an integer.

 function sacar_numero_productos($id_categorias, $marca){
     $marca = str_replace("/", "", $marca);
     $a = views_embed_view("numero_productos", "block_1", $id_categorias, $marca);
    // LINE BELOW DOES WORK BUT DESTROYS THE OUPUT OF SQL QUERIES
    //$a = views_get_view_result("numero_productos", "block_1", $id_categorias, $marca);

return (int)(trim(strip_tags($a)));

   // IF I USE views_get_view_result, this is the return value instead.
   /*if(isset($a[0]-&gt;field_data_field_id_unico_oem_field_id_unico_oem_value) &amp;&amp; (int)$a[0]-&gt;field_data_field_id_unico_oem_field_id_unico_oem_value &gt; 0){
       return (int)$a[0]-&gt;field_data_field_id_unico_oem_field_id_unico_oem_value;
    } // if*/
    return 0;
} // function
The short answer: Devel is not incompatible with Views.

The longer answer:

The difference between views_embed_view and views_get_view_result is essentially that views_embed_view renders the view while views_get_view_result only executes it. The code for the two processes are almost identical, but the difference is that views_embed_view does more as part of the render process. You can see the details in view::render.

The gist of it is that when embedding the view, you get views to do a lot more things, like initializing the theme, invoking more hooks.

Best guess for where your problem lies would be some other module integrating with views and/or devel or some other details you haven't written in your question.

The devel query log works by using the core database log, starting it with hook_boot and getting the info with a shutdown function. There are some scenarios where devel will be silent, fx when doing redirects. There is a good chance, that the issue is related to how devel figures out when to be silent or not. It's near impossible to figure out the exact cause without being able to debug your exact site and configuration as any module / configuration can be the cause to what you are seeing. If you want to investigate you should look into


devel_silent()
devel_shutdown()
devel_shutdown_real()