diff --git a/classes/DataWarehouse/Query/Query.php b/classes/DataWarehouse/Query/Query.php index a6e1176771..98bee0bbc6 100644 --- a/classes/DataWarehouse/Query/Query.php +++ b/classes/DataWarehouse/Query/Query.php @@ -21,6 +21,7 @@ class Query public $filterParameterDescriptions; private $pdoparams; private $pdoindex; + private $log; /** * Tracks whether or not role restrictions have been applied to this query. @@ -118,7 +119,13 @@ public function __construct($realm_name, $this->roleParameterDescriptions = array(); $this->filterParameterDescriptions = array(); - + $this->log = \CCR\Log::factory('xms.query', array( + 'console' => false, + 'db' => false, + 'mail' => false, + 'file' => LOG_DIR . '/query.log', + 'fileLogLevel' => PEAR_LOG_DEBUG + )); } @@ -229,6 +236,13 @@ public function execute($limit = 10000000) { $query_string = $this->getQueryString($limit); + + $debug = \xd_utilities\filter_var(\xd_utilities\getConfiguration('general', 'sql_debug_mode'), FILTER_VALIDATE_BOOLEAN); + if ($debug == true) { + $class = get_class($this); + $this->log->debug(sprintf("%s: \n%s", $class, $query_string)); + } + $time_start = microtime(true); $results = DB::factory($this->_db_profile)->query($query_string, $this->pdoparams); diff --git a/libraries/utilities.php b/libraries/utilities.php index 79a71b5717..2892da3441 100644 --- a/libraries/utilities.php +++ b/libraries/utilities.php @@ -554,3 +554,17 @@ function checkForCenterLogo($apply_css = true) return $use_center_logo; } + +/** + * A temporary shim function to use while our supported PHP version is < 5.4.8 + * + * @param mixed $value to be filtered + * @param int $filter the type of filter to apply + * @param mixed $options the options to be supplied to the filter + * @return bool|mixed false if the value is logically false, else the results of + * \filter_var($value, $filter, $options) + */ +function filter_var($value, $filter = FILTER_DEFAULT, $options = null) +{ + return ( false === $value ? false : \filter_var($value, $filter, $options) ); +}