the hook_views_pre_execute(&$view) used for create/change the view's sql not work with view vers 6.x-3.x while work with 6.x-2.x
the function is called but the code for change the sql not work (isn't called)

function nameofyourmodule_views_pre_execute(&$view) {
drupal_set_message($view->name);
//if($view->name=="groups_list2") {
$view->build_info['query']="SELECT node.nid AS nid FROM node";
//$view->build_info['query']="SELECT node.nid AS nid FROM node LIMIT 2";
//} 
 }

I noticed that in views\includes\view.inc
in 6.x-2 there is this code (row 695):

// Let modules modify the view just prior to executing it.
foreach (module_implements('views_pre_execute') as $module) {
$function = $module . '_views_pre_execute';
$function($this);
}

$query = db_rewrite_sql($this->build_info['query'], $this->base_table, $this->base_field, array('view' => &$this));
$count_query = db_rewrite_sql($this->build_info['count_query'], $this->base_table, $this->base_field, array('view' => &$this));

$args = $this->build_info['query_args'];

vpr($query);

while in 6.x-3.x ther is only this (row 825):

// Let modules modify the view just prior to executing it.
foreach (module_implements('views_pre_execute') as $module) {
$function = $module . '_views_pre_execute';
$function($this);
}

in 6.x-2 there is more code; I also add this code in 6.x-3 but problem remain

Comments

alb created an issue. See original summary.

alb’s picture

Issue summary: View changes
alb’s picture

Issue summary: View changes
alb’s picture

Issue summary: View changes
alb’s picture

Issue summary: View changes
alb’s picture

Issue summary: View changes
alb’s picture

I also noticed that in the file views\includes\admin.inc in 6.x-3 there is this code (row 426):

// Get information from the preview for display.
 if (empty($view->build_info['fail'])) {
      $rows = $view->query->get_preview_info();
      ...

_
I changed with those of 6.x-2:

if (!empty($view->build_info['query'])) {
 $rows = array();
 $query = db_prefix_tables($view->build_info['query']);
  if ($view->build_info['query_args']) {
  _db_query_callback($view->build_info['query_args'], TRUE);
  $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
 }
 $rows[] = array('<strong>' . t('Query') . '</strong>', '<pre>' . check_plain($query) . '</pre>'); 
....

but problem remain
I changed because noticed that after this row:
// Get information from the preview for display.
views 6.x-2 and views 7.x-3 use the same code
if (!empty($view->build_info['query'])) {
while 6.x-3 no

zalak.addweb’s picture

Issue tags: +views
Chris Matthews’s picture

Status: Active » Closed (outdated)

The Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue