Skip to content

Enabling SQL profiler on Response should be by setting enable_sql_profiler and not by debug #14219

@nicoaravena

Description

@nicoaravena

Hi there! I've been working on a fork of piwik (2.x) and I notice that when you enable the debug option, the database profiler it start to work and searching the origin of this I found in core/Tracker/Response.php this:

class Response
{
    private $timer;

    private $content;

    public function init(Tracker $tracker)
    {
        ob_start(); // we use ob_start only because of Common::printDebug, we should actually not really use ob_start

        if ($tracker->isDebugModeEnabled()) {
            $this->timer = new Timer();

            TrackerDb::enableProfiling();
        }
    }
...

The problem is that the function isDebugModeEnabled() search for a global where it depends on the debug value in the config.php.ini and it should be validated by the setting enable_sql_profiler (as I mention in the title)

My propose is this:

    public function init(Tracker $tracker)
    {
        // remove ob_start();
        if ((bool) TrackerConfig::getConfigValue('enable_sql_profiler')) {
            $this->timer = new Timer();

            TrackerDb::enableProfiling();
        }
    }

Also notice that ob_start(); cause some problems with the printDebug function (specifically with the CLI), it is completely necessary? I think this could be removed also.

I forgot to say that I search in both branch version (2.x-dev and 3.x-dev) and this is untouched between those version changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help wantedBeginner friendly issues or issues where we'd highly appreciate community's help and involvement.c: PlatformFor Matomo platform changes that aren't impacting any of our APIs but improve the core itself.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions