Enable Debug, SQL Explain and Load time

Discussion forum for Extension Writers regarding Extension Development.
Erpenator
Registered User
Posts: 40
Joined: Tue Nov 03, 2009 6:45 pm

Enable Debug, SQL Explain and Load time

Post by Erpenator »

I am currently on phpbb 3.3.0-b2 and I am trying to enable the debug mode, the SQL explain and load times on my (development) forum. I am aware the settings are changed for this version of phpBB and you can't uncomment these lines in your config.php anymore:

Code: Select all

@define('PHPBB_DISPLAY_LOAD_TIME', true);
@define('DEBUG', true);
@define('DEBUG_CONTAINER', true);
From what I understand you need to add a config.yml file to one of your extensions and include:

Code: Select all

parameters:
    debug.load_time: true
    debug.sql_explain: true
    debug.memory: true
    debug.show_errors: true
    debug.exceptions: true
When I create a new file in /ext/myextensioname/myextension/config/config.yml and include the code above my forum stops working as soon as I upload the file. Since I can't see the error I don't know why. Removing the file and clearing the cache will bring back the forum online again.

Do I need to include these lines as well in my config.yml to make it work?

Code: Select all

imports:
    - { resource: ../default/config.yml }
I can see that in /config/development/config.yml the settings that I am looking it's included. But even when I copy that config.yml file and put in in my extensions directory the forum is unreachable.

Code: Select all

imports:
    - { resource: ../default/config.yml }

core:
    require_dev_dependencies: true
    allow_install_dir: true

    debug:
        exceptions: true
        load_time: true
        sql_explain: true
        memory: true
        show_errors: true

    twig:
        debug: true
        auto_reload: true
        enable_debug_extension: true

    session:
        log_errors: true
I've checked all the files with a tool and all files are exactly the same and up to date with phpbb 3.3.0-b2.

I can't find how to switch to "development" mode instead of the standard "production" I am currently in or add the config that is needed to see the debug output. Anyone got an idea what I am doing wrong?
Last edited by Erpenator on Wed Dec 18, 2019 1:29 pm, edited 2 times in total.
User avatar
KevC
Support Team Member
Support Team Member
Posts: 72617
Joined: Fri Jun 04, 2004 10:44 am
Location: Oxford, UK

Re: Enable Debug, SQL Explain and Load time

Post by KevC »

Erpenator wrote: Wed Dec 18, 2019 11:09 am I am currently on phpbb 3.3.2-b2
That's not even out yet.
If you're testing the 3.3 release you should post on the Area51 development site.
-:|:- Support Request Template -:|:-
Image
"Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb"
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Enable Debug, SQL Explain and Load time

Post by mrgoldy »

If you want a development environment, for your local test board, you can do the following:
In your config.php file change the following line:
from: @define('PHPBB_ENVIRONMENT', 'production');
to: @define('PHPBB_ENVIRONMENT', 'development');

Those are 'environment' parameters, so they are for your entire board.
You should not be copying these parameters to your extension in any manner.

This is for phpBB 3.3.x (important!) Just to clarify.
As for this version, these parameters are no longer in config.php but moved to config/development/config.yml.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
Erpenator
Registered User
Posts: 40
Joined: Tue Nov 03, 2009 6:45 pm

Re: Enable Debug, SQL Explain and Load time

Post by Erpenator »

KevC wrote: Wed Dec 18, 2019 11:18 am
Erpenator wrote: Wed Dec 18, 2019 11:09 am I am currently on phpbb 3.3.2-b2
That's not even out yet.
If you're testing the 3.3 release you should post on the Area51 development site.
You are correct, I meant 3.3.0-b2 and fixed it in the original post to prevent confusion.
mrgoldy wrote: Wed Dec 18, 2019 1:09 pm If you want a development environment, for your local test board, you can do the following:
In your config.php file change the following line:
from: @define('PHPBB_ENVIRONMENT', 'production');
to: @define('PHPBB_ENVIRONMENT', 'development');

Those are 'environment' parameters, so they are for your entire board.
You should not be copying these parameters to your extension in any manner.

This is for phpBB 3.3.x (important!) Just to clarify.
As for this version, these parameters are no longer in config.php but moved to config/development/config.yml.
Thank you for your useful reply! When I use the @define('PHPBB_ENVIRONMENT', 'development'); I need to execute php ../composer.phar install --dev . When I do does this mean I can't upload these files to the production anymore before updating to production mode again with composer?

Is it still possible to have PHPBB_DISPLAY_LOAD_TIME on the production site? It usually helps to pinpoint slow pages or page types on the site?
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Enable Debug, SQL Explain and Load time

Post by mrgoldy »

You should not have to execute any commands. It should be working immediately, perhaps after purging the cache.

And for your production board, that should not yet be on 3.3.0-b2. It's not advisable to use beta version on live sites!
However, eventually, I suppose you can add the same parameters in your config/production/config.yml.

Code: Select all

core:
    debug:
        load_time: true
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
Erpenator
Registered User
Posts: 40
Joined: Tue Nov 03, 2009 6:45 pm

Re: Enable Debug, SQL Explain and Load time

Post by Erpenator »

Adding that code to the config/production/config.yml seems to work. When I tried to add the other options (on the development forum) that I found on your site like sql_explain: true that didn't seemed to work, not sure why.

But for now at least I can show the load times. Thank you again!
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Enable Debug, SQL Explain and Load time

Post by mrgoldy »

Have you tried adding them under the core: rather than parameters: ?
Haven't had much time to play with it myself yet though..
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: Enable Debug, SQL Explain and Load time

Post by 3Di »

Erpenator wrote: Wed Dec 18, 2019 3:37 pm Adding that code to the config/production/config.yml seems to work. When I tried to add the other options (on the development forum) that I found on your site like sql_explain: true that didn't seemed to work, not sure why.

But for now at least I can show the load times. Thank you again!
That's how it works, we have it on our 3.3.0-b2 live test board as
.\config\production\config.yml

2019-12-18 17_45_51- config.yml.png
note the dots instead of tabs, important.

And purge the cache after each edit when working with .yaml files.

On a side note, that's how the Quick Install extension does it as well.
You do not have the required permissions to view the files attached to this post.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Erpenator
Registered User
Posts: 40
Joined: Tue Nov 03, 2009 6:45 pm

Re: Enable Debug, SQL Explain and Load time

Post by Erpenator »

That was the first option I found and tried before posting this question here. So I've done some more testing and it seems that this works:

Code: Select all

parameters:
    debug.load_time: true
    debug.memory: true
So with a tab and a space after the :

Using the dots doesn't work (and to me that makes sense). I can't include debug.sql_explain: true in the config or else the forum will stop working. But as long as I leave it out it the above config file seems to work fine.

This works as well:

Code: Select all

core:
  debug:
    load_time: true
    memory: true
    show_errors: true
    exceptions: true
So to show the full config file that works for me in /yourforumfolder/config/production/config.yml

Code: Select all

imports:
    - { resource: ../default/config.yml }
core:
  debug:
    load_time: true
    memory: true
    show_errors: true
    exceptions: true
Why debug.sql_explain: true is causing any problems I don't know?
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: Enable Debug, SQL Explain and Load time

Post by 3Di »

Check the YAML syntax here https://yamlchecker.com/

Is it a fresh install or an upgrade from 3.2?
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Erpenator
Registered User
Posts: 40
Joined: Tue Nov 03, 2009 6:45 pm

Re: Enable Debug, SQL Explain and Load time

Post by Erpenator »

3Di wrote: Wed Dec 18, 2019 6:34 pm Check the YAML syntax here https://yamlchecker.com/

Is it a fresh install or an upgrade from 3.2?
It's an upgrade where I compared all the files with my IDE and made sure they are the same as the full package that I downloaded here https://area51.phpbb.com/downloads/. yamlchecker.com shows my config.yml is valid.

I had another look why the sql_explain wasn't working once I enabled it and I think I found the problem. The error that is generated is :
PHP Fatal error: Uncaught Error: Call to undefined method Symfony\\Component\\HttpFoundation\\Request::variable() in /phpbb/db/driver/driver.php:1042

It seems that this line
if (is_object($request) && !$request->variable('explain', false))

and in particular !$request->variable('explain', false) is causing the problem. It's an old implementation of Symfony I think? When you comment those lines the sql_explain is visible in the footer, and everything seems to work.

I can see the same code in the GitHub repository as well: https://github.com/phpbb/phpbb/blob/mas ... driver.php
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: Enable Debug, SQL Explain and Load time

Post by 3Di »

The upgrade procedure is the same as per 3.2 (see KB), which implies also to completely delete the old vendor folder and upload the new one.
No need to modify the core code, the code I posted in the tutorial I wrote should work without problem.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Erpenator
Registered User
Posts: 40
Joined: Tue Nov 03, 2009 6:45 pm

Re: Enable Debug, SQL Explain and Load time

Post by Erpenator »

3Di wrote: Wed Dec 18, 2019 10:07 pm The upgrade procedure is the same as per 3.2 (see KB), which implies also to completely delete the old vendor folder and upload the new one.
No need to modify the core code, the code I posted in the tutorial I wrote should work without problem.
I am aware of that, but I want to see / better understand what changed in the code so I do it step by step and file by file. This sometimes makes it easier to understand how to update extensions and to see in what areas you need to do some recoding.
All files are replaced and updated and exactly the same as the full package that I downloaded, but it does not resolve the problem. If you want I can install a fresh version of the forum software to see if the problem still exists.

As a side note: I can see that the code that I highlighted in my previous post is both on Github as in the zip of the full package.
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 6799
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James

Re: Enable Debug, SQL Explain and Load time

Post by HiFiKabin »

phpbb.com (this board) is for supported versions only. As was mentioned by KevC earlier this is a subject for Area51 as 3.3.x has not been released, nor is it ready for release (as indicated by its Bete2 status)
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 6799
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James

Re: Enable Debug, SQL Explain and Load time

Post by HiFiKabin »

Unlocked due to the release and subsequent discussion of 3.3.0-RC1

Return to “Extension Writers Discussion”