I exported all my message types, fields, ... as features and imported them.

But somehow the message_type was not created/activated.
Which resulted in this error?

EntityMetadataWrapperException: Unknown data property message_text. in EntityStructureWrapper->getPropertyInfo() (line 339 of /data/www/sas-webstore/www/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).

What can I do?

Can I activate it somehow?

Comments

thim’s picture

Not sure why this happened but I ran

the following code via the /devel/php and then the message_text field was created

  // Create the message text field for our message type category.
  $instance = array(
    'field_name' => MESSAGE_FIELD_MESSAGE_TEXT,
    'bundle' => 'commerce_order_message',
    'entity_type' => 'message_type',
    'label' => t('Message text'),
    'description' => t('This is the text of all messages of this type.'),
    'required' => TRUE,
    'settings' => array(
      'text_processing' => 1,
      // Mark that this field can be rendered using Message::getText().
      'message_text' => TRUE,
    ),
  );
  if ($existing_instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'])) {
    field_update_instance($instance);
  }
  else {
    field_create_instance($instance);
  }

  // Add a display name field.
  $field = array(
    'field_name' => 'message_order_display_name',
    'type' => 'text',
    'module' => 'text',
    'cardinality' => '1',
    'translatable' => TRUE,
    'settings' => array(
      'max_length' => '255',
      // Mark that this field can be rendered using Message::getText().
      'message_text' => TRUE,
    ),
  );
  if (field_info_field($field['field_name'])) {
    field_update_field($field);
  }
  else {
    field_create_field($field);
  }
  $instance = array(
    'field_name' => $field['field_name'],
    'bundle' => 'commerce_order_message',
    'entity_type' => 'message_type',
    'label' => t('Display name'),
    'description' => t('The name of this message type as displayed in logs.'),
    'required' => TRUE,
    'settings' => array(
      'text_processing' => 0,
    ),
  );
  if ($existing_instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'])) {
    field_update_instance($instance);
  }
  else {
    field_create_instance($instance);
  }

  // Add text format if it doesn't exist.
  if (!filter_format_load('commerce_order_message')) {
    $format = (object) array(
      'format' => 'commerce_order_message',
      'name' => 'Commerce Order Message',
      'weight' => 0,
      'filters' => array(
        // HTML filter.
        'filter_html' => array(
          'weight' => 1,
          'status' => 1,
        ),
      ),
    );
    filter_format_save($format);
  }

I'm going to put it in a update_hook and in the install_hook of my module.

vasike’s picture

Version: 7.x-1.8 » 7.x-1.9

there's a similar issue on Commerce Message issue queue : #2053821: EntityMetadataWrapperException error every time new orders are entered.

rbosscher’s picture

I've had the same error.
Reinstalling the message module resolved the issue.

that0n3guy’s picture

Re-installing seemed to take care of this for me too (I am on v1.7 though).

geek-merlin’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Priority: Normal » Major

Setting major as this makes the module unusable.
For me this is fixed by #2108283: Entity language info missing.
Please review so we can get this in.

harings_rob’s picture

Issue summary: View changes

Running #1 solved the error message, but the message description is empty (even when creating a new)

harings_rob’s picture

removing, unsinstalling, installing commerce kickstart orders and commerce message solved this.

maxplus’s picture

Problem also solved for me by just disabling and back enabling the Commerce Message, Message and Message Notify modules

EDIT:

problem is not solved, only when I keep Commerce Message disabled...

gowlj’s picture

same problem here, disabling/enabling modules did not resolve.
error if fired by opening /content/message or orders in quick edit mode.
(the last issue is partially fixed by hiding in commerce/config/order/display the field EVA: Commerce Message: Order messages - Entity content)

alexmcl’s picture

Solution from #7 by easycombvba worked for me

geek-merlin’s picture

Here's a shortdut that helped me:

module_load_include('install', 'commerce_message');
commerce_message_install();
andyg8’s picture

I've just encountered the same error after updating to Views 7.x-3.11 and Drupal 7.37 with rc3 and dev. I've disabled all the Message modules and re-enabled to no avail. In dev I don't seem to get the fatal error, just the order's history table is empty.
In rc3 the fatal error seems to occur the first time I try to load an order from within admin. After navigating away from the order and coming back to it no error - just the Order history table is empty.
Any recent thoughts on this issue?

peezy’s picture

In case it helps anyone else using Commerce Kickstart who sees this error, I found this post on DrupalCommerce.org, which had a simple solution: hide the EVA Commerce Message field from display on Orders. Here are the detailed steps:

  1. Go to http://yoursite.com/admin/commerce/config/order/
  2. Click the "Manage Display" tab
  3. Find the "EVA: Commerce Message: Order messages - Entity content" field
  4. Change that field's format from visible to hidden
  5. Click Save
millionleaves’s picture

#13 helped me on a non-Kickstart Commerce site on which I just enabled Message and Commerce Message - thanks. Reading through this and similar issues, I'm guessing this all comes back to whether you've got translation enabled for the site (I do).

millionleaves’s picture

Update... different site to #14.

I was experiencing this issue in line 354 instead of 336. Upgraded to latest -dev of Commerce Message. No change.

#13 didn't help.

#11 did the trick but had the same result described in #6. I'm not relying on the Messages, they did have some use. Now they're all blank - old and new.

Donit’s picture

Uninstalling, removing and installing Commerce Message again did the trick for me - but at a high price: all messages lost.

torgosPizza’s picture

Hi folks,

I had the "message_text" entity property disappear on me for some unknown reason (I've been doing a lot of patching and cache-clearing) which ended up in the same EntityMetadataWrapper Exception as seen here and other places. Somehow this only affected message types provided by Commerce Message, so I think the actual bug lies there. This was reinforced by the fact that my custom-coded message types still had their Message text fields, but none of the Commerce Message types did.

So while I can't easily determine why it happened, here is a snippet of code that should fix it. Basically we just need to re-add the field instances to the Commerce Message types, and then invoke the default_message_types hook to add their default values back in.

module_load_include('inc', 'commerce_message', 'commerce_message.message');

// Re-add any missing field instances.
commerce_message_message_field_refresh();

// Add default values back.
module_invoke_all('default_message_type');

After executing this script (I used drush scr) the Message text field returned with its default values, and I simply had to reconfigure them to our own needs. A pain, to be sure, but it beats uninstalling and reinstalling the module! Especially since doing so triggers a bunch of SQL updates and deletions, which can take quite some time on huge DBs such as ours with millions of message rows.

Hopefully this snippet can help others in a similar situation. If I can determine when and how the message text field got deleted, I will file a follow-up bug report.

bluegeek9’s picture

Status: Active » Closed (outdated)