I created a very simple page-view with only one field and a nodereference as an argument.
Some pages (for example /admin/views/) are broken thereafter with the following sql-error. This is only the case with nodereference arguments and only when page-view is selected
Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /www/httpd/html/drupal47/includes/database.mysql.inc on line 120
$view = new stdClass();
$view->name = 'aaa';
$view->description = '';
$view->access = array ();
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'list';
$view->url = 'test/$arg';
$view->use_pager = TRUE;
$view->nodes_per_page = '10';
$view->sort = array (
);
$view->argument = array (
array (
'type' => 'content: field_artist',
'argdefault' => '1',
'title' => '',
'options' => '',
'wildcard' => '',
'wildcard_substitution' => '',
),
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => '',
'handler' => 'views_handler_field_nodelink',
),
);
$view->filter = array ();
$view->exposed_filter = array ();
$view->requires = array(node);
$views[$view->name] = $view;
Comments
Comment #1
merlinofchaos commentedYou probably what the url to be just 'test'; test/$arg might have some strange results.
The error you got indicates a node_load() happened without an argument, if that helps.
Comment #2
marcoBauli commentedyes, same happens here:
if i set a 'nodereference' as argument for a view, but then call
www.mysite.com/viewname/nodereference_ID
and the ID of that node does not exists (mistake, node has been deleted...), instead of a blank page or of the custom message for empty views, that Warning appears.
Comment #3
merlinofchaos commentedI think that means this is a bug with the nodereference code which doesn't do a safety check when performing a node_load? I'm not completely sure.
Comment #4
karens commentedAs Earl said, you need to be sure that you do *not* put '$arg' into the page_url. There are very few times when you need $arg, and you probably should not ever use it for any argument you are defining in the view. I did some tests with nodereference fields and they work fine as arguments so long as you do not put '$arg' into the url, but throw all kinds of errors if it is there.
Example: I put 'test' into the page url field and add the nodereference field as an argument, then go to 'test/2' where 2 is a nid that does not exist, and I get page not found and no sql errors.
I'm marking this fixed, but you can re-open if you get errors and you do not have '$arg' in the url.
Comment #5
karens commentedWoops!! My comments collided with Earl's and I ended up undoing his issue change. I'm going to move this back to CCK as he originally did, just in case it does turn out to be a CCK issue, but I think it is just a misunderstanding of how to use $arg in an url.
Comment #6
merlinofchaos commentedI think you're probably right, Karen. And hey, you actually tested it, so you definitely have the weight of knowledge.
Comment #7
(not verified) commented