Give modules a chance to handle or process database errors.
This can be useful to implement addional logging backends and/or
alerting mechanisms. Another option is to fully override Phorum's
default database error handling by handling the error and then
calling exit() from the hook to prevent the default Phorum code
from running.
Note: If you decide to use the full override scenario, then
it is best to make your module run the database_error hook
last, so other modules can still run their hook handling
before the script exits. To accomplish this, add this to your
module info:
priority: run hook database_error after *
Call time:
At the start of the function
phorum_database_error
(which you can find in
common.php
). This function is called from
the database layer when some database error occurs.
Hook input:
The error message that was returned from the database layer. This error is not HTML escaped, so if you send it to the browser, be sure to preprocess it using htmlspecialchars().
Hook output:
Same as input.
Example code:
function phorum_mod_foo_database_error($error) { // Log database errors to syslog facility "LOCAL0". openlog("Phorum", LOG_PID | LOG_PERROR, LOG_LOCAL0); syslog(LOG_ERR, $error); return $error; }