If I run this code on my workstation in the Execute PHP block provided by the devel module:
echo $_SERVER['argc'];
echo php_sapi_name();
I get:
apache2handler
On two of my production servers however (one shared hosting and one a dedicated server) I get different results. If I run that on the home page I get:
0cgi
On a URL with one argument, i.e. http://mysite.com/someurl I get
1cgi
And on a URL with multiple arguments, as in http://mysite.com/someurl/x or http://mysite.com/someurl/x/y I get the same thing:
1cgi
phpinfo() says that register_argc_argv is On.
The issue is of course that on any pages except for the home page, devel_query_display doesn't show anything because devel_verify_cli thinks the interface is CLI. AFAICT.
Comments
Comment #1
cpliakas commentedWe are seeing something similar, and the result is that the
devel_verify_cli()function returns false positives in some situations. Specifically, we are seeing that $_SERVER['argc'] is 1 when we are accessing pages via the web on servers where suphp is installed and the php.ini setting register_argc_argv is On. If you change register_argc_argv to Off, the false positives are eliminated as $_SERVER['argc'] is NULL when accessing via the web interface but a positive integer when running via CLI. I can't say with certainty that it is suphp specific, but it appears to us to be the case. This error may be out of the scope of the Devel module, but it is worth noting thatdevel_verify_cli()doesn't seem to be completely reliable. I understand that the function is forked from Drush, so I am opening an issue there as well pointing to this thread.As a side note, it goes without saying that the Devel module has been an invaluable resource for development, so thanks for a great module.
~Chris
Comment #2
Anonymous (not verified) commentedMarking as duplicate of newer issue: #575058: Query log only shown on front page
Comment #3
moshe weitzman commentedreopening this one has better diagnosis
Comment #4
jordanmagnuson commentedSame issue (query log only showing on front page, "1cgi" on other pages).
Comment #5
moshe weitzman commentedd7 devel is now using drupal_is_cli() which is a core function. does that function work fine for these edge cases? if so, i will backport it to d6 and use it here.
Comment #6
MadtownLems commentedI just copied a site from one server to another, and then started dumping query info to benchmark the servers. It was then I realized that I'm having this issue on ONE of the servers only.
Same database, exact same code set, but one dumps the query info on every page, and one just on the front page.
What can I do to help debug this issue? ( or at least get query info! )
Comment #7
MadtownLems commentedI copied the site to yet another shared hosting server, and here is the same problem as the first. The site only dumps info on the front page. Is there any way to fix this?
Comment #8
locomo commentedI'm experiencing the same behavior with version 6.x-1.19 (query log only showing on front page)
not sure how to troubleshoot - any ideas?
Comment #9
hershel commentedMoshe's suggestion was (apparently) to install Drupal 7 in the same environment (perhaps as a subdomain or in a directory) and install the 7.x version of Devel and see if it works there. If it works, then he will try to backport that feature to the 6.x version.
That would be one way to debug.
Comment #10
Mark B commentedPerhaps someone with more experience of server configurations can comment on how generally applicable this solution is, but on my host I've been checking whether $_SERVER['HTTP_HOST'] is set - it seems to be set for browser requests, and not set for cli requests.
So I've hacked my 6.x-1.19 devel.module to
If enough people tell me this isn't a completely crazy way to check if we're handling a cli request, I'll roll a patch.
Comment #11
hershel commentedAppears to be technically not guaranteed to always work (see http://php.net/manual/en/reserved.variables.server.php ), but in practice most likely it should. I would thus posit that your solution sounds reasonable, Mark B.
Comment #12
moshe weitzman commentedPlease see #5,
Comment #13
kbahey commentedThis is not performance.module related.
Comment #14
Mark B commentedre #5, I'm not currently able to deploy the D7 alpha to our production server. However, inspection of the D7 drupal_is_cli function looks as though it is essentially checking exactly the same server variables:
devel.module 6.x:
D7 drupal_is_cli:
so I would expect the D7 drupal_is_cli function to have exactly the same issue. Perhaps we should instead be looking at porting this patch forward to core.
Comment #15
Jamie Holly commentedI have also encounter this problem. If the server is running PHP as a CGI (very common in shared hosting), then the test fails. The reason is you always get one for argc, which is of course q. One possible workaround would be:
return (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0 && !isset($_SERVER['SERVER_ADDR']));
SERVER_ADDR only gets set when PHP is called from a server (HTTP_HOST should also work). I've tested this method on a couple of different shared hosts I have access to and it seems to work fine.
EDIT:
From the D7 function in Comment #14, the D7 function is checking for server software, which is essentially the same thing.
Comment #16
Jamie Holly commentedAttaching a patch just using the D7 solution.
Comment #17
macdonaldj commentedthanks, intoxination!
this fixed my issue of the log not showing on all pages.
Comment #18
mikeker commentedVerified the fix in #16 works with the Devel 6.x-1.20 release on a standard-issue shared hosting LAMP stack.
Thanks for posting!
Comment #19
moshe weitzman commentedI want to use the core drupal_is_cli() function and replicate it in d6. patch core first if its logic is lacking.
Comment #20
moshe weitzman commentedComment #21
wojtha commentedHmm I'm running 6.x-1.23 where is devel_verify_cli() borrowed from Drupal 7 and I ran in the same issue on Zend Server 5 + Win 7 Pro.
After I reverted the devel_verify_cli() to "borrowed from Drush" state query log display started working again. When I'll have some spare time I'll try to dig deeper.
Comment #22
markchitty commentedI was seeing the same issue (i.e. not seeing the query results) on 6.x-1.23 setup on shared hosting (php as cgi). The patch in #16 fixed this issue for me.
Comment #23
yngens2 commentedIn the newly released 7.x-1.4 version of the module, there is no function devel_verify_cli and the patch naturally doesn't apply anymore.
Comment #24
willzyx commentedClosed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.