How to reproduce:

  1. create a view with a 'Node: ID' argument
  2. pass some string as the argument ('all' for example)
  3. views fails printing something like
        * warning: implode() [function.implode]: Bad arguments. in /home/#####/www/public/sites/all/modules/views/modules/views_node.inc on line 698.
        * user 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 ')) AND ('applylocalizer'='applylocalizer') )' at line 1 query: SELECT node.nid, localizernode.language AS localizernode_language, node.title AS node_title, node.changed AS node_changed FROM node node LEFT JOIN localizernode localizernode ON node.nid = localizernode.nid LEFT JOIN localizernode loc ON loc.nid=node.nid LEFT JOIN(SELECT -100 AS weight, CAST('en' AS CHAR(10)) AS language UNION SELECT 1 AS weight, CAST('ru' AS CHAR(10)) AS language) lanw ON lanw.language=loc.language LEFT JOIN (select pid, MIN(weight) AS minweight from localizernode loc2 LEFT JOIN (SELECT -100 AS weight, CAST('en' AS CHAR(10)) AS language UNION SELECT 1 AS weight, CAST('ru' AS CHAR(10)) AS language) lanw2 on lanw2.language=loc2.language group by pid) loc1 ON loc.pid=loc1.pid WHERE (lanw.weight=loc1.minweight) AND ( (node.status = '1') AND (node.type IN ('page','page_with_links','products_list_page')) AND (node.nid IN ()) AND ('applylocalizer'='applylocalizer') ) in /home/#####/www/public/includes/database.mysqli.inc on line 151.
    

Problem is in the following code:

    case 'filter':
      $args = _views_break_phrase($arg);
      //if ($args) {
				if ($args[0] == 'and') {
					$operator = $argtype['options'] ? '!=' : '=';
					foreach ($args[1] as $arg) {
						$query->add_where("node.nid $operator %d", $arg);
					}
				}
				else {
					$query->add_where("node.nid IN (%s)", implode(',', $args[1]));
				}
			//}
      break;

_views_break_phrase($arg); returns NULL if $arg is not numeric and NULL value is not handled further.

Problem is solved by adding commented out lines (see above).

Although it works for me, I doubt if it is correct because it should honor argument's default ('summary','page not found','empty text'). This patch works only for 'display all values' setting.

CommentFileSizeAuthor
views_node.inc-nid_arg_handling-pastk.patch957 bytespastk

Comments

merlinofchaos’s picture

Status: Needs work » Needs review

Actually, I believe your fix is correct. An invalid argument should not trigger the default action.

sun’s picture

Status: Needs review » Needs work

Please re-roll adhering to http://drupal.org/coding-standards

rc2020’s picture

Interestingly enough I get a similar error when specifing a node NID argument, and having the argument display code set to use the argument because i'm using a block view instead of a page view.

With the argument display code set as:
// Make the first argument 1 if not already set
if (!$args[0]) {
$args[0] = 1;
}
return $args;

which is according to the views manual, I set the view type as block view with the node: NID argument, and save the view.

When I enable it in the block menu, I get this error:

* warning: implode() [function.implode]: Invalid arguments passed in /home/######/public_html/modules/views/modules/views_node.inc on line 677.
* user 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 ')) LIMIT 0, 1' at line 1 query: SELECT DISTINCT(node.nid), location.name AS location_name, location.latitude AS location_latitude, location.longitude AS location_longitude, node.type AS gmap_node_type FROM node node LEFT JOIN location_instance location_instance_node ON node.vid = location_instance_node.vid LEFT JOIN location location ON location_instance_node.lid = location.lid WHERE (node.nid IN ()) LIMIT 0, 1 in /home/lifeunde/public_html/includes/database.mysql.inc on line 172.

Im going to install the patch and see what happens.

esmerel’s picture

Status: Needs work » Closed (won't fix)

No patch resubmitted, nobody's working on 1.x patches at this point.