commit 8f06fc700a19ce83d90564767b796fe721146a9a
Author: Damien Tournoud <damien@commerceguys.com>
Date:   Fri Feb 3 13:52:35 2012 +0100

    Issue #1276272: Don't display bundle selection if the entity type doesn't have a bundle key.

diff --git a/plugins/selection/EntityReference_SelectionHandler_Generic.class.php b/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
index b99ce33..0d24580 100644
--- a/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
+++ b/plugins/selection/EntityReference_SelectionHandler_Generic.class.php
@@ -38,20 +38,29 @@ class EntityReference_SelectionHandler_Generic implements EntityReference_Select
    */
   public static function settingsForm($field, $instance) {
     $entity_info = entity_get_info($field['settings']['target_type']);
-    $bundles = array();
-    foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
-      $bundles[$bundle_name] = $bundle_info['label'];
-    }
 
-    $form['target_bundles'] = array(
-      '#type' => 'select',
-      '#title' => t('Target bundles'),
-      '#options' => $bundles,
-      '#default_value' => isset($field['settings']['handler_settings']['target_bundles']) ? $field['settings']['handler_settings']['target_bundles'] : array(),
-      '#size' => 6,
-      '#multiple' => TRUE,
-      '#description' => t('The bundles of the entity type that can be referenced. Optional, leave empty for all bundles.')
-    );
+    if (!empty($entity_info['entity keys']['bundle'])) {
+      $bundles = array();
+      foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
+        $bundles[$bundle_name] = $bundle_info['label'];
+      }
+
+      $form['target_bundles'] = array(
+        '#type' => 'select',
+        '#title' => t('Target bundles'),
+        '#options' => $bundles,
+        '#default_value' => isset($field['settings']['handler_settings']['target_bundles']) ? $field['settings']['handler_settings']['target_bundles'] : array(),
+        '#size' => 6,
+        '#multiple' => TRUE,
+        '#description' => t('The bundles of the entity type that can be referenced. Optional, leave empty for all bundles.')
+      );
+    }
+    else {
+      $form['target_bundles'] = array(
+        '#type' => 'value',
+        '#value' => array(),
+      );
+    }
 
     $form['sort']['type'] = array(
       '#type' => 'radios',
