* @param string $string
*/
public static function debug_query($string) {
- if (!defined('CIVICRM_DEBUG_LOG_QUERY')) {
- // TODO: When its updated to support getenv(), call CRM_Utils_Constant::value('CIVICRM_DEBUG_LOG_QUERY', FALSE)
- define('CIVICRM_DEBUG_LOG_QUERY', getenv('CIVICRM_DEBUG_LOG_QUERY'));
- }
- if (CIVICRM_DEBUG_LOG_QUERY === 'backtrace') {
+ $debugLogQuery = CRM_Utils_Constant::value('CIVICRM_DEBUG_LOG_QUERY', FALSE);
+ if ($debugLogQuery === 'backtrace') {
CRM_Core_Error::backtrace($string, TRUE);
}
- elseif (CIVICRM_DEBUG_LOG_QUERY) {
- CRM_Core_Error::debug_var('Query', $string, TRUE, TRUE, 'sql_log' . CIVICRM_DEBUG_LOG_QUERY, PEAR_LOG_DEBUG);
+ elseif ($debugLogQuery) {
+ CRM_Core_Error::debug_var('Query', $string, TRUE, TRUE, 'sql_log' . $debugLogQuery, PEAR_LOG_DEBUG);
}
}
/**
* Determine the value of a constant, if any.
*
- * If the specified constant is undefined, return a default value.
+ * If the specified constant is undefined, check for an environment
+ * variable, defaulting the passed in default value.
*
* @param string $name
* @param mixed $default
* (optional)
* @return mixed
*/
- public static function value($name, $default = NULL) {
+ public static function value(string $name, $default = NULL) {
if (defined($name)) {
return constant($name);
}
- else {
- return $default;
+ if (($value = getenv($name)) !== FALSE) {
+ define($name, $value);
+ return $value;
}
+ return $default;
}
}