When the token module is active and the email notification in private messages is enabled and the workflow module is enabled I get above error.

Deactivating the token module or the notification module solves the problem. However I need them both

My error with backtrace gave:
EntityMetadataWrapperException: Unknown data property recipient.(/sites/all/modules/contrib/workflow/workflow.entity.inc on line 311) in EntityStructureWrapper->getPropertyInfo() (line 345 of //sites/all/modules/contrib/entity/includes/entity.wrapper.inc).

So looking in the workflow module I found it is trying to replace the tokens in the workflow.tokens.inc. Therefore I made a little patch which seems to work and has no problems with other modules. It works for me.

diff --git a/sites/all/modules/contrib/workflow/workflow.tokens.inc b/sites/all/modules/contrib/workflow/workflow.tokens.inc
index 085cfa0..549dc75 100644
--- a/sites/all/modules/contrib/workflow/workflow.tokens.inc
+++ b/sites/all/modules/contrib/workflow/workflow.tokens.inc
@@ -154,7 +154,7 @@ function workflow_tokens($type, $tokens, array $data = array(), array $options =
   // The 'node' tokens have already been replaced with 'entity'.
   // Skip for easier debugging.
   // @todo: is this always the case, or only if Entity Tokens is enabled?
-  if ($type == 'node' || $type == 'user' || $type == 'term') {
+  if ($type == 'node' || $type == 'user' || $type == 'term' || $data['entity_type'] =='privatemsg_message') {
     return $replacements;
   }

Have never created a patch here so do it this way for review since got some deadlines to make.
Hopefully this helps to determine what exactly is wrong.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wouser’s picture

The patch provided works but throws the error below 10 times in a row on every page.

**Private Messages will not allow sending individual messages to users with the above error, here is more documentation via PM: https://www.drupal.org/node/2399367

Does anyone else have any suggestions for fixing this issue, I wish I had the knowledge to help.

Error:
"Notice: Undefined index: entity_type in workflow_tokens() (line 157 of /usr/home/justme53/public_html/""/sites/all/modules/workflow/workflow.tokens.inc)."

erald’s picture

Actually had the same problem and changed the patch

so on top of above patch I patched..

   // The 'node' tokens have already been replaced with 'entity'.
   // Skip for easier debugging.
   // @todo: is this always the case, or only if Entity Tokens is enabled?
-  if ($type == 'node' || $type == 'user' || $type == 'term' || $data['entity_type'] =='privatemsg_message') {
+  if (isset($data['entity_type'])) {
+  	if ($data['entity_type'] =='privatemsg_message') {
+  		return $replacements;
+  	}
+  }
+  if ($type == 'node' || $type == 'user' || $type == 'term' ) {
     return $replacements;
   }

basically reverting the earlier patch and adding a few lines to avoid the mentioned error.

Just forgot to publish this here..

wouser’s picture

Thank you Erald for posting this.
I've tested this patch and it works, I am still able to send messages and no annoying errors.

Not sure if this is related but I received an error after implementing this patch: Strict warning: Declaration of hs_taxonomy_views drupal. There is an issue related to this: http://r.search.yahoo.com/_ylt=A0LEVv7rOhhVgVoAy8cnnIlQ;_ylu=X3oDMTEzMW0...
However, I've never seen this error previously.

wouser’s picture

Status: Active » Needs review
GuyPaddock’s picture

Status: Needs review » Needs work

Workflow shouldn't be coupled to Private Message like this. The logic should be robust enough to deal with other entity types without having to explicitly whitelist them here.

GuyPaddock’s picture

Looking at related issues and the implementation workflow_tokens(), this is a mess. This code is hard to follow and makes a lot of assumptions that don't hold true (like assuming it should handle tokens for things it doesn't control).

I'm in a crunch at the moment preparing a project for a client that uses both Privatemsg Notifications and Workflow, and so I don't have the time at the moment to rewrite this function, but I'm running with the attached patch to disable Workflow tokens entirely in the interim since my project doesn't need them.

This is not a viable long term solution -- people need tokens -- but I'm posting this here until I can write a proper patch to address token support shortcomings.

GuyPaddock’s picture

Assigned: Unassigned » GuyPaddock

Assigning to me.

kyoder’s picture

Any updates on this?

GuyPaddock’s picture

Assigned: GuyPaddock » Unassigned

No; unfortunately, I have not been able to make sense of the existing code. It's spaghetti code.

Unassigning from me, for the moment, in case anyone else wants to take it. If I can fix it, I'll provide a patch here.

erald’s picture

We abandoned the workflow module completely so my problem on this is solved for now. But is not a long term solution either.

kyoder’s picture

FileSize
1.7 KB

here's a patch that fixed this issue for me, without disabling workflow tokens

Leeteq’s picture

@erald; in case you abandoned workflow module for some other solution/module(s)/workaround, do you care to share which one(s), as that may be interesting for other projects in their evaluation stage?

erald’s picture

@Leeteq: Because I encountered this problem including problems I had with creating views for the workflow.( We had the workflow connected to users not nodes) We decided to create our own workflow module where we use nodes referenced to the user. That in combination with a custom module (hook to alter forms) to change the role of the user we were able to create any view we needed without problems. In combination with rules and some custom rule actions we are sending private messages and creating some workflow messages on changes of the user role. Now I can even send bulk mails and have a message in the workflow of the message.
The scripts I had to create were actually quite simple and we have a good working solution which overcomes the limitations and problems with the workflow module which is not really suited to use for users.

  • johnv committed 537456e on 7.x-2.x authored by kyoder
    Issue #2413593 by GuyPaddock, kyoder: EntityMetadataWrapperException in...
johnv’s picture

Component: Code » Tokens
Status: Needs work » Fixed

#11 is committed. Thanks.

Status: Fixed » Closed (fixed)

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