PDO Exceptions in logging


#1

@fox,
Not sure if this is bug or change in requirements but some of the users for auth_ldap are complaining about logging exceptions when sending the logs to an SQL database.

If they change to file or syslog logging, they don’t get the error.


#2

it’s probably because of this:

2. classes/logger.php(28): log_error(1024, User: admin authentication successful, , , )

you’re using system logging for something other than error messages and until current behavior is changed, somehow, it won’t work because any SQL logging enforces a PDO rollback (i think there’s no way to know if PDO transaction is currently active), which might cause a PDO exception if there’s no running transaction OR abort current transaction if there is.

(although i’m looking at the code now and we’re try-catching that one. maybe the actual cause here is different - $lineno not being an integer because, again, it’s not actually a crash report).

why? because otherwise it would be impossible to log to the database while inside a transaction which is (maybe) pending an abort because some kind of error (maybe database-related) has occurred.

i agree that this is kinda broken but tt-rss normally uses system error log for otherwise fatal errors so it mostly works.

most likely a different approach is needed here, for example, another separate PDO connection used exclusively for SQL logging might work. ideas welcome, as usual.

here’s another recent thread on the subject: Proper way to do Logging in a plugin?

the changeset which was referenced in your github issue changed PDO to use exceptions other than PHP old-school errors for logging, because of this: Intermittent PDOException


Proper way to do Logging in a plugin?
#3

alright so in your particular case

2. classes/logger.php(28): log_error(1024, User: admin authentication successful, , , )

you’re not specifying $lineno which should be an integer which is why it fails, i guess that logging essay i wrote above doesn’t apply

e: i’ve pushed some logging-related improvements, documented in the linked thread.