Signature as found on http://api.drupal.org/api/function/db_rewrite_sql/6:
db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $args = array())

In commentreference.module (D6 stable), function commentreference_autocomplete_value():

<?php
    $value = db_result(db_query(db_rewrite_sql('SELECT c.subject FROM {comments} c WHERE c.cid = %d', 'c', 'cid', $cid), $cid));
?>

Correct would be (I guess):

<?php
    $value = db_result(db_query(db_rewrite_sql('SELECT c.subject FROM {comments} c WHERE c.cid = %d', 'c', 'cid', array($cid)), $cid));
?>

I'm not exactly sure what the $cid is supposed to do in the argument list, but if we want to pass it around, it needs to be wrapped in an array.

------

Why is this relevant:
db_rewrite_sql indirectly calls i18n_db_rewrite_sql(), which does

<?php
  // Disable language conditions for views.
  if (array_key_exists('view', $args)) return;
?>

and this chokes if $args is a comment $cid instead of an array or an object.

Error message (for googlers):
warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in [..]/sites/all/modules/i18n/i18n.module on line 434.

Thanks!

Comments

swentel’s picture

Status: Active » Fixed

Nice catch, committed, thanks! http://drupal.org/cvs?commit=416178

Status: Fixed » Closed (fixed)

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

donquixote’s picture

This might be fixed in -dev, but no new stable since then..
I am using my own patched version with just this one fix, and it seems to work - although my use case is quite niche, i'd say.
Would be nice if I can remove the .drush-lock-update from this module :)