Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
97 views
in Q2A Core by

I can see the if `QA_DEBUG_PERFORMANCE` is enabled, that each page shows the debug information.

IMHO, the queries and data should only be shown to the admin.

To achieve this, I would like to check if the site viewer is the admin by:

if (QA_DEBUG_PERFORMANCE && qa_get_logged_in_level() == QA_USER_LEVEL_SUPER) { ...

In `qa-base.php` however, i cannot access the function `qa_get_logged_in_level()`, it is not yet defined. 

Any chance to implement this only for admin?

Q2A version: 1.8.3

1 Answer

+3 votes
by
selected by
 
Best answer

Unfortunately that's not really possible because the timing is measured from the very beginning of the script where we don't yet know which visitor is logged in. If we started the debug mode later it wouldn't be possible to debug any problems with getting the logged in user. It was never intended for use on live sites where your users would see it.

One possible solution would be to add a URL parameter and set the constant when that parameter exists. For example:

define('QA_DEBUG_PERFORMANCE', isset($_GET['debug1234']));

Then open the page with example.com/qa/?debug1234=1

The '1234' is for security, you should change it to something not guessable. And once you're finished analyzing, set it back to false.

by
edited by
Perfect workaround, thanks a lot! Very helpful.
...