Index: autocomplete_widgets.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/autocomplete_widgets/Attic/autocomplete_widgets.module,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 autocomplete_widgets.module
--- autocomplete_widgets.module	24 Feb 2009 02:00:13 -0000	1.1.2.2
+++ autocomplete_widgets.module	19 Mar 2009 10:35:05 -0000
@@ -162,7 +162,7 @@
   $element[$field_key] = array(
     '#type' => 'textfield',
     '#default_value' => $value,
-    '#autocomplete_path' => 'autocomplete_widgets/'. $element['#field_name'],
+    '#autocomplete_path' => 'autocomplete_widgets/'. $element['#type_name'] .'/'. $element['#field_name'],
     '#size' => !empty($field['widget']['size']) ? $field['widget']['size'] : 60,
     '#attributes' => array('class' => 'text'),
     // The following values were set by the content module and need
@@ -223,12 +223,10 @@
 /**
  * Menu callback; Retrieve a pipe delimited string of autocomplete suggestions.
  */
-function autocomplete_widgets_json($field_name, $string = '') {
-  $fields = content_fields();
-  $field = $fields[$field_name];
+function autocomplete_widgets_json($type_name, $field_name, $string = '') {
+  $field = content_fields($field_name, $type_name);
   $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
   $matches = array();
-
   $options = _autocomplete_widgets_get_options($field, $string, $match, NULL, 10);
   foreach ($options as $key => $value) {
     // Add a class wrapper for a few required CSS overrides.
@@ -260,10 +258,13 @@
  *     ...
  *   )
  */
-function _autocomplete_widgets_get_options($field, $string = '', $match = 'contains', $keys = array(), $limit = NULL) {
+function _autocomplete_widgets_get_options($field, $string = '', $match = 'contains', $keys = NULL, $limit = NULL) {
   static $results = array();
 
   // Create unique id for static cache.
+  if (!isset($keys) || !is_array($keys)) {
+    $keys = array();
+  }
   $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $keys)) .':'. $limit;
 
   if (!isset($results[$cid])) {
@@ -286,7 +287,7 @@
  *
  * Options are retrieved from the allowed values defined for the field.
  */
-function _autocomplete_widgets_get_options_allowvals($field, $string = '', $match = 'contains', $keys = array(), $limit = NULL) {
+function _autocomplete_widgets_get_options_allowvals($field, $string = '', $match = 'contains', $keys = NULL, $limit = NULL) {
   $function = $field['module'] .'_allowed_values';
   $allowed_values = (array)(function_exists($function) ? $function($field) : content_allowed_values($field));
   if (!isset($limit) || !is_numeric($limit)) {
@@ -296,7 +297,7 @@
   $options = array();
   foreach ($allowed_values as $key => $value) {
     if ($string === '') {
-      if ($keys) {
+      if (isset($keys) && is_array($keys)) {
         if (in_array($key, $keys)) {
           $options[$key] = $value;
           $count++;
@@ -332,7 +333,7 @@
  *
  * Options are retrieved from existing values for the field.
  */
-function _autocomplete_widgets_get_options_flddata($field, $string = '', $match = 'contains', $keys = array(), $limit = NULL) {
+function _autocomplete_widgets_get_options_flddata($field, $string = '', $match = 'contains', $keys = NULL, $limit = NULL) {
   $db_info = content_database_info($field);
   $table = $db_info['table'];
   $column = $field['field_name'] .'_'. key($db_info['columns']);
@@ -348,7 +349,7 @@
     $where[] = 'f.'. $column .' '. (isset($match_operators[$match]) ? $match_operators[$match] : $match_operators['contains']);
     $args[] = $string;
   }
-  else if ($keys) {
+  else if (isset($keys) && is_array($keys)) {
     $where[] = 'f.'. $column .' IN ('. db_placeholders($keys) .')';
     $args = array_merge($args, $keys);
   }
