summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wehner2011-11-04 21:50:11 +0100
committerDaniel Wehner2011-11-04 21:50:11 +0100
commit939db64d8071ea534d27a0529d5c37a116c777fd (patch)
treeef9833ad6dcd3b1a59bee6ade4cc6a99d3ed6d5e
parent984e54c7078139adca3f0406367e17f02d423dcc (diff)
#1330716 by markus_petrux, dereine: Views substitutions broken after db_safe() update
-rw-r--r--includes/handlers.inc6
-rw-r--r--includes/view.inc15
-rw-r--r--plugins/views_plugin_query_default.inc2
3 files changed, 22 insertions, 1 deletions
diff --git a/includes/handlers.inc b/includes/handlers.inc
index 9bcba88..b69755b 100644
--- a/includes/handlers.inc
+++ b/includes/handlers.inc
@@ -1619,6 +1619,9 @@ class views_join {
}
$output = " $this->type JOIN $right_table $table[alias] ON $left_field = $table[alias].$this->field";
+ // Load query tokens replacements.
+ $view = views_get_current_view();
+ $replacements = $view->substitutions();
// Tack on the extra.
if (isset($this->extra)) {
@@ -1636,6 +1639,9 @@ class views_join {
$join_table = $info['table'] . '.';
}
+ // Apply query token replacements.
+ $info['value'] = str_replace(array_keys($replacements), $replacements, $info['value']);
+
// And now deal with the value and the operator. Set $q to
// a single-quote for non-numeric values and the
// empty-string for numeric values, then wrap all values in $q.
diff --git a/includes/view.inc b/includes/view.inc
index 4fd5f9b..068a101 100644
--- a/includes/view.inc
+++ b/includes/view.inc
@@ -91,6 +91,11 @@ class view extends views_db_object {
var $override_path = NULL;
/**
+ * Stores all the views substitutions.
+ */
+ var $substitutions = array();
+
+ /**
* Constructor
*/
function __construct() {
@@ -452,6 +457,16 @@ class view extends views_db_object {
}
/**
+ * Get's all the substitutions and store them.
+ */
+ function substitutions($reset = FALSE) {
+ if ($reset || empty($this->substitutions)) {
+ $this->substitutions = module_invoke_all('views_query_substitutions', $this);
+ }
+ return $this->substitutions;
+ }
+
+ /**
* Attach all of the handlers for each type.
*
* @param $key
diff --git a/plugins/views_plugin_query_default.inc b/plugins/views_plugin_query_default.inc
index f029571..89e6cbe 100644
--- a/plugins/views_plugin_query_default.inc
+++ b/plugins/views_plugin_query_default.inc
@@ -1118,7 +1118,7 @@ class views_plugin_query_default extends views_plugin_query{
$items = array();
if ($query) {
- $replacements = module_invoke_all('views_query_substitutions', $view);
+ $replacements = $this->view->substitutions();
$query = str_replace(array_keys($replacements), $replacements, $query);
$count_query = 'SELECT COUNT(*) FROM (' . str_replace(array_keys($replacements), $replacements, $count_query) . ') count_alias';