The devel_query_put_contents() function is preventing the query log from displaying while I'm trying to do performance tuning on my site.

If I comment out the following line #1082 of the devel_query_put_contents() function, the query log displays as expected:

 file_put_contents($path, @json_encode($queries));

This is happening on a copy of my laptop (Macbook Pro running OSX10.6) that I set up using the Acquia Drupal Control Panel v 1.2.30.

Comments

salvis’s picture

Title: devel_query_put_contents() » devel_query_put_contents() preventing the query log from displaying

Please try the -dev version.

moshe weitzman’s picture

Status: Active » Closed (cannot reproduce)

No reply

ermannob’s picture

Status: Closed (cannot reproduce) » Active

Hi,
I'm experiencing the same problem. I'm using devel 7.x-1.2+32-dev.
My drupal is 7.12 on MAMP (OSX).
I'm having this problem only on one page, generated by a custom module made by me. Looking at the page source (HTML code) the query log is completely missing.

Thanks.

hefox’s picture

the @ on the json_encode meant that a fatal error due to time limit exceeding was never reported, meaning the query log mysteriously didn't appear on some pages.

:(

Kars-T’s picture

Version: 7.x-1.2 » 7.x-1.x-dev

Hi

I can confirm this problem.

Line 1274 latest dev

  file_put_contents($path, @json_encode($queries));

I am checking a really messed up site that seems to enter > 5.000 queries to the query log. json_encode() will just fail. And by this I won't get anything from the shutdown function.

Exact message is:

PHP Warning: json_encode(): recursion detected in /sites/all/modules/contrib/devel/devel.module on line 1274

I don't have an idea because this of course is just too much. Maybe the array should just be truncated? Maybe add a setting about max log size? Or maybe just add a warning text to the admin interface?

salvis’s picture

I wonder why the @ operator is not working here...

Look in Google for your message to get some other ideas about what could be wrong with your data.

dwightaspinwall’s picture

Title: devel_query_put_contents() preventing the query log from displaying » devel_query_put_contents() prevents query output from displaying due to fatal error from json_encode() call

I can also confirm this issue in 7.x-1.x-dev. Certain pages show the query log, others not. In my case the home page didn't show queries (or any other post-body output), even though there were only about 700 queries. Was tricky to track down the problem because the @ suppressed error logging. Because the fatal error comes so late in the page load, it doesn't even appear at all that there is an error. Looks more like a theming or configuration issue.

Not sure what the right approach is for a fix, nor even clear on the purpose of the call to file_put_contents() at all, since commenting out this line causes the queries to appear as normal. Maybe a try/catch with a notice?

willzyx’s picture

Issue summary: View changes
willzyx’s picture

Status: Active » Closed (fixed)

Closing this, since in #2465025: SQL query log doesn't work on pages generated by a view we solve this issue. Feel free to reopen if you think that the problem is still present.