? Success

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
16 Jun 2015

As a followup to the "Handle DB errors" by @alikon. As requested by @wilsonge :smile:

I just added logging to the catches where they were missing.
And I changed one place where the error message still was shown to use the new way of showing a generic message and logging the error.

Should be simple to review.

avatar Bakual Bakual - open - 16 Jun 2015
avatar Bakual Bakual - change - 16 Jun 2015
Milestone Added:
avatar mbabker
mbabker - comment - 16 Jun 2015

IMO this is unnecessary. Every database driver has error handling similar to that of MySQLi which already logs errors.

avatar Bakual
Bakual - comment - 16 Jun 2015

Looks like you are right (as always), but unfortunately it doesn't seem to log anything. Looks like the logger for that category databasequery isn't specified and thus nothing is written in any logfile.

Or am I to stupid to get that log?

avatar wilsonge
wilsonge - comment - 16 Jun 2015

I think you need to enable that in the debug plugin

avatar Bakual
Bakual - comment - 16 Jun 2015

If I add

        JLog::addLogger(
            array(
                'text_file' => 'databasequery.errors.php'
            ),
            JLog::ALL,
            array('databasequery')
        );

before

        // If an error occurred handle it.
        if (!$this->cursor)

it works.
So I guess that logger needs to be defined first somewhere.

avatar wilsonge
wilsonge - comment - 16 Jun 2015

So I guess we need actually remove the extra logs we have added at 5bbb0ed and 06b38e2

avatar Bakual
Bakual - comment - 16 Jun 2015

Found why it doesn't work.
The plugin explicitely excludes that category from the "log almost everything" logger:
https://github.com/joomla/joomla-cms/blob/staging/plugins/system/debug/debug.php#L104

Anyone knows why?

So we either add a new option to the plugin or just remove that exclusion?

avatar Bakual
Bakual - comment - 16 Jun 2015

@wilsonge Yes, looks like it. Can do a PR as soon as we decided what to do with our debug plugin :smile:

avatar wilsonge
wilsonge - comment - 16 Jun 2015

That log everything option was only added in 3.4 as part of #5319 - so it's not like a bug or anything - looks like in the past it just wasn't possible

avatar Bakual
Bakual - comment - 16 Jun 2015

I think @nikosdion excluded it by accident because he thought it would be the category for the actual queries (the other option to log all queries to a file), while it is in fact only for the query errors.

avatar mbabker
mbabker - comment - 16 Jun 2015

If your logger is set to handle messages of priority JLog::DEBUG then that category will also log every executed query.

avatar mbabker
mbabker - comment - 16 Jun 2015

Well, more specifically, a combination of the database driver being in debug mode and a logger set to catch those messages - https://github.com/joomla/joomla-cms/blob/3.4.1/libraries/joomla/database/driver/mysqli.php#L539-L556

avatar Bakual
Bakual - comment - 16 Jun 2015

Ah I see.
If we remove the category from the exlude, then it would show only the errors while global debug is off, but log all queries if debug is turned on. Not ideal either indeed.

avatar nikosdion
nikosdion - comment - 16 Jun 2015

That's why I removed the query logging. If you're running a site in debug mode (typical when developing) you create a supermassive log which has some very undesired consequences.

avatar Bakual
Bakual - comment - 16 Jun 2015

yeah, makes sense.
I'm thinking if we could create a new logging category for database query errors (databasequeryerrors) which are included in the "log everything". Because chances are high you want to see those but don't want to see all the other queries.

avatar nikosdion
nikosdion - comment - 16 Jun 2015

Yes we could, but it does break b/c with existing third party database drivers. It's not just the custom db drivers for people who want to set up master-slave in MySQL but also the custom db drivers in 3PD extensions (e.g. site translation software). Are we allowed to do that in J! 3.5?

avatar zero-24 zero-24 - change - 16 Jun 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 16 Jun 2015
Category Modules
avatar zero-24 zero-24 - change - 16 Jun 2015
Status New Pending
avatar Bakual
Bakual - comment - 16 Jun 2015

The custom drivers would behave as today. Meaning database errors would only be logged if they have debug enabled and queries logged.
Our own drivers would instead log the errors with debug either on or off as long as "log almost everything" enabled.
It shouldn't break anything.
I'll try to do a PR tomorrow so we have something to discuss :smile:

avatar Bakual
Bakual - comment - 17 Jun 2015

See #7187
Hope that solves it without any side effects.

Closing this PR for now as I think the other is a better approach.

avatar Bakual Bakual - change - 17 Jun 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-06-17 11:45:12
Closed_By Bakual
avatar Bakual Bakual - close - 17 Jun 2015
avatar Bakual Bakual - close - 17 Jun 2015
avatar zero-24 zero-24 - change - 17 Jun 2015
Milestone Removed:
avatar Bakual Bakual - head_ref_deleted - 13 Jul 2015

Add a Comment

Login with GitHub to post a comment