summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2008-03-28 22:04:45 (GMT)
committer Earl Miles2008-03-28 22:04:45 (GMT)
commit104a067d51aa71bd34c5c09f131bd3f889cffdbf (patch)
tree3ce889324fe79139cd5478b8cc35f30a22e99240
parent2275266b74730f64f03c15d65fd8d1bbadb521fa (diff)
#239947: Allow an optional debug signature to views to make it easier to identify where queries come from when perusing a query log.
-rw-r--r--includes/admin.inc9
-rw-r--r--includes/view.inc4
-rw-r--r--views_ui.module3
3 files changed, 14 insertions, 2 deletions
diff --git a/includes/admin.inc b/includes/admin.inc
index 79b9e8d..0e5e89c 100644
--- a/includes/admin.inc
+++ b/includes/admin.inc
@@ -2062,7 +2062,14 @@ function views_ui_disable_page($view) {
* Page callback for the tools - other page
*/
function views_ui_admin_tools() {
- return t('This page is not yet implemented. But try the convert tool.');
+ $form['views_sql_signature'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Add Views signature to all SQL queries'),
+ '#description' => t("All Views-generated queries will include a special 'VIEWS' = 'VIEWS' string in the WHERE clause. This makes identifying Views queries in database server logs simpler, but should only be used when troubleshooting."),
+ '#default_value' => variable_get('views_sql_signature', FALSE),
+ );
+
+ return system_settings_form($form);
}
/**
diff --git a/includes/view.inc b/includes/view.inc
index 7e2f026..b2baf0e 100644
--- a/includes/view.inc
+++ b/includes/view.inc
@@ -472,6 +472,10 @@ class view extends views_db_object {
$this->style_handler->query();
+ if (variable_get('views_sql_signature', FALSE)) {
+ $this->query->add_field(NULL, "'". $this->name .':'. $this->current_display ."'", 'view_name');
+ }
+
$this->build_info['query'] = $this->query->query();
$this->build_info['count_query'] = $this->query->query(TRUE);
$this->build_info['query_args'] = $this->query->get_where_args();
diff --git a/views_ui.module b/views_ui.module
index 15b5708..1b1f7ac 100644
--- a/views_ui.module
+++ b/views_ui.module
@@ -46,7 +46,8 @@ function views_ui_menu() {
);
$items['admin/build/views/tools'] = $base + array(
'title' => t('Tools'),
- 'page callback' => 'views_ui_admin_tools',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('views_ui_admin_tools'),
'type' => MENU_LOCAL_TASK
);
$items['admin/build/views/tools/basic'] = $base + array(