I created a quite simple view (only body) on a CCK type (only core and a file field) with i18n module enabled. First experiments are quite succesful, but setting "use empty text" for standard behavior for an argument produces this error:

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 'LEFT JOIN i18n_node i18n ON node.nid = i18n.nid WHERE (i18n.language ='de' OR i1' at line 1 query: LEFT JOIN i18n_node i18n ON node.nid = i18n.nid WHERE (i18n.language ='de' OR i18n.language ='de' OR i18n.language ='' OR i18n.language IS NULL) in C:\Programme\xampp\htdocs\drupal5\includes\database.mysql.inc on line 172.

Reverting to another standard behavior or deleting the argument will fix this.

Comments

catch’s picture

Project: Views (for Drupal 7) » Internationalization
Version: 5.x-1.6 » 5.x-2.x-dev

moving here on the assumption this is an i8n bug

cestmoi’s picture

Version: 5.x-2.x-dev » 5.x-2.2

I have similar error when using the bookimport mdoule (Drupal 5.5):

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 'LEFT JOIN i18n_node i18n ON n.nid = i18n.nid WHERE (i18n.language ='ar' OR i18n' at line 1 query: UPDATE book SET nid=441, parent=555, weight=0 LEFT JOIN i18n_node i18n ON n.nid = i18n.nid WHERE (i18n.language ='ar' OR i18n.language ='' OR i18n.language IS NULL) AND ( vid='441' ) in C:\Program Files\EasyPHP\www\drupar\includes\database.mysql.inc on line 172.

I don't have this problem on another test site with Drupal 5.3 and i18n ver 5.x-1.x-dev

jmlavarenne’s picture

Adding myself here because I have the same issue when using empty text in views.

harineel’s picture

i also got the same problem

agentrickard’s picture

Status: Active » Needs review

function i18n_views_filter_handler() is missing the first parameter, $op.

agentrickard’s picture

The proper code is:

/**
 * Filter handler callback. Manages language selection mode
 */
function i18n_views_filter_handler($op, $filterdata, $filterinfo, &$query) {
  if ($op == 'handler' && $filterdata['field'] == 'i18n.selection' && $mode = $filterdata['value']) {
    // If this filter is used, rollback value set in pre_query and set the new one.
    i18n_selection_mode('reset');
    i18n_selection_mode($mode);
  }
}

Apologies for the lack of a proper patch. Not sure if this actually fixes the error.

agentrickard’s picture

The error is in i18n_db_rewrite_sql() which is rewriting an empty query for Views that had a NULL result.

agentrickard’s picture

There are cases where Views passes an empty query to db_rewrite_sql -- this might be considered a views bug.

Fix is to alter function i18n_bd_rewrite_sql() line 730 of i18n.module:

  if (empty($query) || $mode == 'off') return;
agentrickard’s picture

StatusFileSize
new2.03 KB

Here is the patch.

agentrickard’s picture

Project: Views (for Drupal 7) » Internationalization
Version: 5.x-1.6 » 5.x-2.2
StatusFileSize
new378 bytes

@catch

I think this is actually a Views bug.

This patch addresses Views passing an empty query to db_rewrite_sql.

[edit] patch is malformed -- testing [/edit]

agentrickard’s picture

Project: Internationalization » Views (for Drupal 7)
Version: 5.x-2.2 » 5.x-1.6
agentrickard’s picture

Project: Internationalization » Views (for Drupal 7)
Version: 5.x-2.2 » 5.x-1.6
StatusFileSize
new1.07 KB

Here's the patch -- guards against passing an empty $query to db_rewrite_sql().

agentrickard’s picture

StatusFileSize
new1.17 KB

Improved version of the patch.

eMPee584’s picture

Status: Needs review » Reviewed & tested by the community

agentrickard: your patch from #13 seems to be a good solution, thx!

sun’s picture

Status: Reviewed & tested by the community » Fixed
agentrickard’s picture

Already fixed by an issue with a higher node id. Odd. But hey, a fix is a fix.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.