Currently, Field API attachers and "manage field" links, etc. are being added even if the "bundle of" entity is not fieldable. Sometimes you might want to have a bundle even if there are no fields involved. In this case the whole thing breaks at some parts of the code. This patch should solve that behavior.

Comments

Status: Needs review » Needs work

The last submitted patch, bundle of.patch, failed testing.

fubhy’s picture

StatusFileSize
new3.75 KB
fago’s picture

Status: Needs work » Needs review
fago’s picture

Status: Needs review » Needs work
+++ b/entity.module
@@ -307,6 +307,22 @@ function entity_import($entity_type, $export) {
+ * Checks wether an entity type is fieldable or not.

Let's save the "or not".

+++ b/entity.module
@@ -307,6 +307,22 @@ function entity_import($entity_type, $export) {
+ * ¶
+ * @param $entity_type

Whitespace in empty line.

+++ b/entity.module
@@ -307,6 +307,22 @@ function entity_import($entity_type, $export) {
+function entity_fieldable($entity_type) {

Let's use a more correct function name, .e.g.
entity_type_is_fieldable().

+++ b/includes/entity.controller.inc
@@ -290,17 +290,21 @@ class EntityAPIController extends DrupalDefaultEntityController implements Entit
+      // Check if the entity that we are a bundle of is fieldable.
+      if (!empty($info['fieldable'])) {

That's check twice as it is checked in the if() again.

fubhy’s picture

Status: Needs work » Needs review
StatusFileSize
new3.33 KB

Oki!

fubhy’s picture

StatusFileSize
new3.33 KB

Ooops, I forgot the whitespace.

fago’s picture

Status: Needs review » Needs work
+++ b/includes/entity.controller.inc
@@ -290,17 +290,18 @@ class EntityAPIController extends DrupalDefaultEntityController implements Entit
+      $info = entity_get_info($this->entityInfo['bundle of']);

A left-over?

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new4.79 KB

This wasn't applying because of a change to entity.ui.inc, so I rerolled it and removed the line that fago pointed out.

Since the entity.api.php documentation indicated that only fieldable entities could take the 'bundle of' key, I changed the wording there. I tried to make it as clear as possible, but someone else will have to let me know if I succeeded in making it clear.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me! I personally would have written

+++ b/entity.moduleundefined
@@ -307,6 +307,22 @@ function entity_import($entity_type, $export) {
+  if (!empty($info['fieldable'])) {
+    return TRUE;
+  }
+  return FALSE;

return !empty($info['fieldable']);

but I'm super terse like that ;)

fubhy’s picture

Status: Reviewed & tested by the community » Needs work

The first one is easier to read, but I agree that the one line return is still better. Let's get that in, or?

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new4.75 KB

Sure thing.

fago’s picture

Status: Needs review » Fixed

thanks all! Committed.

Status: Fixed » Closed (fixed)

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