In some situations you are rendering fields for a term which is not yet saved and is missing some properties. In my case, I use field_extrawidgets, with this patch: #1305268: Contents of a read-only field is hidden on the term/entity edit form, and thus cannot be edited.. When I open the term create form, I get notices and warnings because $entity->vid is missing.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MiroslavBanov created an issue. See original summary.

MiroslavBanov’s picture

Status: Active » Needs review
FileSize
718 bytes

I am adding an isset() check.

The vocabulary_machine_name property does exist, but I find it safer to just prevent the error with isset() check.

This can also be quite easily reproduced without field_extrawidgets:

1. Create a vocabulary (test_vocab) with an additional text field

2. run the following code

  $t = entity_create("taxonomy_term", array("vocabulary_machine_name" => "test_vocab"));
  entity_view("taxonomy_term", array($t)); '

You will get a couple of warnings for array_flip(): Can only flip STRING and INTEGER values! entity.inc. And this patch will remove the warnings.

Status: Needs review » Needs work

The last submitted patch, 2: undefined_term_vid-i18n-2691553-2.patch, failed testing.

MiroslavBanov’s picture

Status: Needs work » Needs review
FileSize
774 bytes

Created the patch from the sub-module for some reason. Trying again