Problem/Motivation

Using a token [node:log] sometimes raises the following notice.

Notice: Undefined property: stdClass::$log in token_tokens() (line 423 of /blah/blah/blah/sites/all/modules/token/token.tokens.inc).

Steps to reproduce:

  1. Install Token and Rules module.
  2. Create a Rule for event "After updating existing content" and use token [node:log] in an action.
  3. Save an existing content without a new revision.
  4. You can see the notice occurs.

Proposed resolution

Add a check for the existing of the property log before using it.

-  $replacements[$original] = $sanitize ? filter_xss($node->log) : $node->log;
+  // $node->log is not always set and check if it exists or not.
+  $log = !empty($node->log) ? $node->log : '';
+  $replacements[$original] = $sanitize ? filter_xss($log) : $log;

Remaining tasks

  • Create a patch
  • Review the patch

User interface changes

(None)

API changes

(None)

Data model changes

(None)

Original report by westbywest and obarillet

My setup:
Drupal 7.12
rules 7.x-2.1
revisioning 7.x-1.4

I have a rule triggered on the event "Content revision has been updated," with the resulting action to send an email notification to a site admin.

If I include the token [node:log] (i.e. most recent revision log message) in the email body, I see the following warning when the rule fires if the user submits the node form with a blank revision log. This warning does not appear if the revision log is non-blank.

Notice: Undefined property: stdClass::$log in token_tokens() (line 423 of /blah/blah/blah/sites/all/modules/token/token.tokens.inc).

Comments

obarillet’s picture

Same issue happened to me with Rules 7.x-2.2, and also happened here with 7.x-2.1: http://drupal.org/node/1647744#comment-6404608

obarillet’s picture

Project: Revisioning » Rules
Version: 7.x-1.4 » 7.x-2.1
Component: Code » Rules Engine

And I don't use revisioning, so this is probably a Rules module related bug.

obarillet’s picture

Issue summary: View changes

Anonymizing file path

ssoulless’s picture

Version: 7.x-2.1 » 7.x-2.x-dev
Component: Rules Engine » Rules Core
Priority: Normal » Major
Issue summary: View changes

Any update in this problem? Im having exact the same issue, the token should print the most recent log entry in the revisions stack.

hgoto’s picture

Project: Rules » Token
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Rules Core » Code
Priority: Major » Normal

I changed the project from Rules to Token since this issue is better addressed in Token module.

hgoto’s picture

(Sorry, this comment is created by mistake.)

hgoto’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
669 bytes

Here is a patch. I'd like this to be reviewed.