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:
- Install Token and Rules module.
- Create a Rule for event "After updating existing content" and use token
[node:log]
in an action. - Save an existing content without a new revision.
- 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).
Comment | File | Size | Author |
---|---|---|---|
#6 | token-fix_missing_node_log_notice-1546182-6.patch | 669 bytes | hgoto |
|
Comments
Comment #1
obarillet CreditAttribution: obarillet commentedSame 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
Comment #2
obarillet CreditAttribution: obarillet commentedAnd I don't use revisioning, so this is probably a Rules module related bug.
Comment #2.0
obarillet CreditAttribution: obarillet commentedAnonymizing file path
Comment #3
ssoulless CreditAttribution: ssoulless commentedAny update in this problem? Im having exact the same issue, the token should print the most recent log entry in the revisions stack.
Comment #4
hgoto CreditAttribution: hgoto at Studio Umi commentedI changed the project from Rules to Token since this issue is better addressed in Token module.
Comment #5
hgoto CreditAttribution: hgoto at Studio Umi commented(Sorry, this comment is created by mistake.)
Comment #6
hgoto CreditAttribution: hgoto at Studio Umi commentedHere is a patch. I'd like this to be reviewed.
Comment #7
pheudo CreditAttribution: pheudo commentedAbout patch #6 Empty function identifies “0” (0 as a string) as empty.
I think that it's not right way.