Some token discussion started over here. #1079134: Add triggers when states are entered/exited

I am creating this new issue so that token and trigger work can progress independently. I have started revising the token patches in the trigger issue and will post that work here. So far I am finding tokening more complicated than I first expected due to the amount of similar information WB Moderation adds to a node object.

Comments

stevector’s picture

Status: Active » Needs work
StatusFileSize
new0 bytes

Here's an updated token patch.

Part of the difficulty here is that we can have multiple revision objects inside of $node->workbench_moderation. We also have state information directly on the node in the the form of $node->workbench_moderation_state_current and $node->workbench_moderation_state_new

I've account for those in those patch.

Do we need some kind of smart token that will switch between working off of moderation objects and information $node->workbench_moderation_state_current depending on the context?

Shadlington’s picture

Subbing

dave reid’s picture

@stevector: Patch is empty.

stevector’s picture

StatusFileSize
new5.56 KB

Sorry about that. Glad I still had the local branch.

rbishop’s picture

kukle’s picture

sub

Vandalf’s picture

subscribing

binford2k’s picture

I'm seeing some odd behaviour with this patch. This happens with the current 7.1.1 release and with the -dev snapshot and with the 2.x branch. When you try to edit a new draft and hit save, you're redirected to /node/XX/edit and nothing gets saved. It shows the last revision saved. If you moderate a draft, nothing happens. In either case, nothing shows up in the log.

binford2k’s picture

Hmm. I take it back. After using devel.module to clear the cache all works. I thought the cache was supposed to clear on module un/install?

binford2k’s picture

Due to (I presume) the redundant node_save() discussed here #1084436: doesn't seem to handle file attachments at all, the content updated rule fires twice. On the first firing, $node->workbench_moderation_state_current is set. On the second, it is not.

However, when the STATE is changed only, then only the second call occurs, the one where $node->workbench_moderation_state_current is NOT set. I am working around it with this snippet:

          if (!empty ($node->workbench_moderation_state_current)) {
            watchdog('workbench_moderation', 'Using original data');
            $replacements[$original] = $sanitize ? check_plain($node->workbench_moderation_state_current) : $node->workbench_moderation_state_current;
          }
          elseif (!empty ($node->workbench_moderation['current']->from_state)) {
            watchdog('workbench_moderation', 'Using alternate data');
            $replacements[$original] = $sanitize ? check_plain($node->workbench_moderation['current']->from_state) : $node->workbench_moderation['current']->from_state;
          }

but this is a hacky solution at best.

After adding #1226688: Rules Integration Support then the rule for state transition fires only once. But just like above, when editing a draft, $node->workbench_moderation_state_current is set and when changing state, it is not. Ideas?

milesw’s picture

acbramley’s picture

Status: Needs work » Closed (duplicate)

Dupe of #2144993