aboutsummaryrefslogtreecommitdiffstats
path: root/include/dba/dba_driver.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-09 01:12:24 -0700
committerredmatrix <git@macgirvin.com>2016-05-09 01:12:24 -0700
commit6f486a3393fe33db70ef2f1684dd3b79768d1137 (patch)
tree4d6967687dcc9b1c9bbbdb443b0038146c31335a /include/dba/dba_driver.php
parent94accd8a4c7500ee4f5c268fe7e84ad3ed9a6675 (diff)
downloadvolse-hubzilla-6f486a3393fe33db70ef2f1684dd3b79768d1137.tar.gz
volse-hubzilla-6f486a3393fe33db70ef2f1684dd3b79768d1137.tar.bz2
volse-hubzilla-6f486a3393fe33db70ef2f1684dd3b79768d1137.zip
prevent recursion in the database driver when debugging is enabled and the system config is not yet loaded - caused by calling get_config and making db calls within the logger function; which we then attempt to log...
Diffstat (limited to 'include/dba/dba_driver.php')
-rwxr-xr-xinclude/dba/dba_driver.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index 3c5b0b67e..8e205a4aa 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -59,8 +59,9 @@ abstract class dba_driver {
const NULL_DATE = '0000-00-00 00:00:00';
const UTC_NOW = 'UTC_TIMESTAMP()';
- protected $debug = 0;
protected $db;
+
+ public $debug = 0;
public $connected = false;
public $error = false;
@@ -302,10 +303,10 @@ function q($sql) {
$stmt = vsprintf($sql, $args);
if($stmt === false) {
if(version_compare(PHP_VERSION, '5.4.0') >= 0)
- logger('dba: vsprintf error: ' .
+ db_logger('dba: vsprintf error: ' .
print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 1), true),LOGGER_NORMAL,LOG_CRIT);
else
- logger('dba: vsprintf error: ' . print_r(debug_backtrace(), true),LOGGER_NORMAL,LOG_CRIT);
+ db_logger('dba: vsprintf error: ' . print_r(debug_backtrace(), true),LOGGER_NORMAL,LOG_CRIT);
}
return $db->q($stmt);
}
@@ -314,7 +315,7 @@ function q($sql) {
* This will happen occasionally trying to store the
* session data after abnormal program termination
*/
- logger('dba: no database: ' . print_r($args,true),LOGGER_NORMAL,LOG_CRIT);
+ db_logger('dba: no database: ' . print_r($args,true),LOGGER_NORMAL,LOG_CRIT);
return false;
}
@@ -385,7 +386,19 @@ function db_getfunc($f) {
if(isset($lookup[$f]) && isset($lookup[$f][ACTIVE_DBTYPE]))
return $lookup[$f][ACTIVE_DBTYPE];
- logger('Unable to abstract DB function "'. $f . '" for dbtype ' . ACTIVE_DBTYPE, LOGGER_DEBUG, LOG_ERR);
+ db_logger('Unable to abstract DB function "'. $f . '" for dbtype ' . ACTIVE_DBTYPE, LOGGER_DEBUG, LOG_ERR);
return $f;
}
+// The logger function may make DB calls internally to query the system logging parameters.
+// This can cause a recursion if database debugging is enabled.
+// So this function preserves the current database debugging state and then turns it off while
+// doing the logger() call
+
+function db_logger($s,$level = LOGGER_NORMAL,$syslog = LOG_INFO) {
+ global $db;
+ $saved = $db->debug;
+ $db->debug = false;
+ logger($s,$level,$syslog);
+ $db->debug = $saved;
+} \ No newline at end of file