From 666554527496733a6b681cf4d170841a4d47c08f Mon Sep 17 00:00:00 2001
From: phiberart <phiberart@868380.no-reply.drupal.org>
Date: Wed, 16 May 2012 15:06:46 -0400
Subject: [PATCH] exported boxes contain invalid data

---
 entity_boxes.install            |   19 +++++++++++++++++++
 plugins/entity_boxes_entity.inc |   13 +++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/entity_boxes.install b/entity_boxes.install
index 7c97a3c..47f4510 100644
--- a/entity_boxes.install
+++ b/entity_boxes.install
@@ -145,6 +145,25 @@ function entity_boxes_update_7001() {
 }
 
 /**
+ * Resave all entity_boxes to prune entity data from database
+ */
+function entity_boxes_update_7002() {
+  $boxes = db_select('entity_boxes', 'eb')
+    ->fields('eb')
+    ->execute()
+    ->fetchAllAssoc('entity_boxes_id');
+
+  foreach ($boxes as $box_id => $name) {
+    $bids[] = $box_id;
+  }
+  $entity_boxes = entity_boxes_load_multiple($bids);
+  foreach ($entity_boxes as $box)
+  {
+    $box->save();
+  }
+}
+
+/**
  *  Implements hook_uninstall().
  *  Remove our created bundles on uninstall
  */
diff --git a/plugins/entity_boxes_entity.inc b/plugins/entity_boxes_entity.inc
index 82e5a70..463d88e 100644
--- a/plugins/entity_boxes_entity.inc
+++ b/plugins/entity_boxes_entity.inc
@@ -59,6 +59,19 @@ class entity_boxes_entity extends boxes_box {
     entity_boxes_edit_form_submit($form, $form_state);
     return $form;
   }
+  
+  /**
+   * Implements Boxes_Box::save().
+   * Allows us to prune entity fields from our box options.
+   */
+  public function save() {
+    $fields = field_info_instances('entity_boxes', $this->plugin_key);
+    foreach($fields as $field_id => $field_data) {
+      unset($this->options[$field_id]);
+    }
+    // Save the box via the default implementation.
+    parent::save();
+  }
 
   /**
    * Implementation of boxes_box::render().
-- 
1.7.0.4

