Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-3.x-dev
Component:
Views Data
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Mar 2011 at 23:26 UTC
Updated:
18 Mar 2011 at 23:11 UTC
Jump to comment: Most recent file
Comments
Comment #1
threewestwinds commentedOk, a bit more searching has revealed that in views_plugin_query_default.inc, line 1149
$this->view is NULL
when build() creates the count_query (which is later called and causes the error).
query() looks for view->base_database at line 1149, but can't find it because view is NULL at that point. So we end up looking at the default database for a table that doesn't exist.
I don't know where $this->view is supposed to be set, but apparently it's happening too late in the process for count_query to access the data is needs.
Comment #2
dawehnerHere is a patch for 7.x-3.x, applies against 6.x-3.x, too.
Comment #3
threewestwinds commentedApparently my diagnosis of the problem was not quite right, since the patch does fix what I thought was wrong, but the error still happens.
With the given patch applied, the lifecycle of $count_query is as follows (all in views_plugin_query_default):
From line 1255, build() calls $this->query(TRUE)
At line 1159 in query(), the $options variable is set properly, with $options['target'] = 'whatever'
$query is returned, and back at line 1255, build() stores it in $view->build_info['count_query']
At line 1268, execute() stores $view->build_info['count_query'] as $count_query
At 1296, $count_query is replaced by $count_query->countQuery()
At 1309, $count_query is passed to $this->pager->execute_count_query()
At line 140 of views_plugin_pager.inc, $count_query->execute() is called, causing a PDO error by querying the wrong database.
I don't know where the problem is occurring. As far as I can tell, the database is set properly, and the same object persists until it's called. #2 is definitely a step in the right direction though, since without it $options at line 1159 is an empty array instead of array('target' => 'whatever').
Comment #4
dawehnerHere is an additional fix to fix the real problem in d7.
Comment #5
dawehnerCommited two patches to fix this issue in d7.
The patch for addting $this->view was added to d6, too.
Thanks for helping to test the fix.