I'm trying to add an additional 'After saving content' activity log rule in Commons, which treats nodes of certain types differently to the rest.

However, even though the two log rules are themed totally differently, whichever rule triggers last is the rule that will theme all node activity log messages. It doesn't seem to matter what conditions I use to separate them, the best I can do is make certain messages disappear from any view, if it renders it will always use the last node_insert activity log template by weight.

I don't know if I'm misunderstanding the API and this is something I just can't do?

Comments

lightsurge’s picture

I'm guessing this might be down to the intelligent caching that's going on which is presuming that all messages created on the node_insert event should be themed the same way... but I've tried turning off caching on each of the activity log actions for both node_insert rules, but without success.

Or something to do with this

In the third stage, our action callback is executed (after the Rule is
triggered and the input evaluator runs). At this point we can collect all the
information we've gathered and save it in the database as an event. Then we
check to see if there are any similar events and aggregate those into the final
message objects that will be used in the actual displayed activity stream.
(Note that we "aggregate" events into messages even if there is only one event
to aggregate so that we have exactly one row in the database table for each
message that will get displayed.)

Which sounds like if it goes wrong it could be a bit like when you mess up your washing and everything comes out the same colour.

lightsurge’s picture

I have a feeling the only way I can accomplish what I'm trying to do is use a token to change the appearance of an activity log message between content types.

icecreamyou’s picture

Status: Active » Fixed

Activity Log will only save messages from one template per event in order to make sure you don't see two activity messages for the same event. This only kicks in for templates that actually get invoked when an event occurs, so if you're seeing a template you don't expect, it means that your Rules conditions are wrong. Activity Log has some default actions that correctly use conditions to make sure the right template is used (e.g. personal status updates vs. status messages to groups with attachments, or nodes created in a group vs. not in a group). If you have Rule (A) for "saving a node" and Rule (B) for "saving a wiki node" then if Rule (A) has higher weight it will always be invoked; instead you need to change Rule (A) to "saving a non-wiki node."

Also, use the development release. IIRC there's a fix in there for a problem related to this although I think that was only related to regenerating activity.

lightsurge’s picture

If you have Rule (A) for "saving a node" and Rule (B) for "saving a wiki node" then if Rule (A) has higher weight it will always be invoked; instead you need to change Rule (A) to "saving a non-wiki node."

It sounds like I should be able to do what I'm attempting then. I have rule 1 which is set to only trigger for node type A, and rule 2 is set to trigger only for node type B. I've tried different types of conditions to test if a particular type of condition wasn't working. I used the standard 'node is type' condition, a 'truth' condition, and a custom php condition.

The best I could do with these conditions was prevent a node type from appearing in the activity log (by removing one of my rules).

My conditions seem to be working, but whatever I do, the log messages seem to get themed by the higher weight rule.

This is a vanilla test install of Commons 2.0 btw.... I'll give the activity log dev release a whirl.

lightsurge’s picture

Status: Fixed » Active
StatusFileSize
new24.94 KB
new25.07 KB

Still having this problem with latest Activity Logs and Rules dev releases.

It just doesn't seem to like me splitting up nodes by type, splitting them by whether or not a node is posted in a group obviously works fine.

Attached are my two rules for reference.

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

After upgrading to the development release you might need to try re-creating the Rules in question from scratch. I'm not sure why but sometimes that fixes things.

lightsurge’s picture

I'll have a crack at installing the Commons github dev release to test this and #1338586: FBSS + Activity Log problem... I understand that it includes the latest activity log module.

lightsurge’s picture

With a fresh installation of latest devel Commons 2.x with latest activity logs (6.x-2.x from git) as standard... the issue remains.

Steps to replicate:

  • Fresh install of Commons 2.x dev
  • Add condition to 'Log activity when a node is created in a group' of NOT blog (add template for active group log of "This is not a blog")
  • Clone rule and alter condition to AND is blog (add template for active group log of "This is a blog")
  • Post a node and a discussion into a group
  • Both nodes will be logged in the group stream as 'This is a blog'.
lightsurge’s picture

Status: Postponed (maintainer needs more info) » Active
ezra-g’s picture

Hi @lightsurge - Thanks for trying to test this!

Are you using the 6.x-2.x dev of Commons from the GitHub repository or Drupal.org? We're working to make nightly development snapshot downloads available based on the Drupal.org repository, but in the meantime, the best way to get Commons is building it by Drush make. Development is no longer happening on GitHub.

If you're around and wish to join #drupal-commons in IRC, I'd be happy to help get this setup or provide you with a tarball until we get those generally publicly available.

lightsurge’s picture

I built it with drush make from http://git.drupal.org/project/commons.git with branch 6.x-2.x (wasn't sure if this was the best one to use or dev... you seemed to be committing to 6.x-2.x while laurentc was committing to the dev!)

icecreamyou’s picture

Version: 6.x-2.0-beta1 » 6.x-2.x-dev

I can confirm the problem, although I have no idea why it's working with some conditions (like whether a node is in a group, or whether a status is a personal update or a message to someone else) but not others.

lightsurge’s picture

At least I'm not just missing something. It occurred to me that in terms of troubleshooting, considering that whether or not you use a truth condition, a 'CCK field contains' condition, 'node is type' condition etc etc and it still fails.. this might point towards the earlier conditions taking some kind of quirky precedence.

icecreamyou’s picture

I'm not sure. In theory Activity Log should never record messages for conditions that fail because the relevant actions will never get invoked. However I added "Display a configurable message on this site" actions to my test Rules and the correct message displayed that way. I am not sure what to interpret from that.

crea’s picture

Category: support » bug

I noticed that some rules have duplicate tid in the database - I think this is the reason. Recreating all rules from the start is a no option (they are too complex).
Maybe duplicate tids have something to do with cloning of rules ?

crea’s picture

I think it's because of cloning. Activity Log doesn't seem to process clone form properly. If the tid storage is done by Rules, cloned rules probably have same tids.

crea’s picture

Title: Activity log ignores previous templates and uses the last to theme all activity of that type? » Cloning of a rule leads to multiple actions trying to use same templates

I was able to fix it by rebulding rules_rules table programmatically and ensuring all actions have unique tids.

crea’s picture

Title: Cloning of a rule leads to multiple actions trying to use same templates » Cloning of a rule leads to duplicate template IDs and multiple actions trying to use them
Priority: Normal » Major