I'm using Feeds and Activity 6.2.x on a site and whenever an item is imported via feeds, the node shows up just fine, but the activity event isn't recorded properly.

Instead of recording that user X posted node Y, when a feed item is imported, it says that Anonymous user posted a node and none of the node object info comes through into the view item.

So for some reason, when Feeds imports stuff, its not triggering the activity module like it should.

Comments

alex_b’s picture

Project: Feeds » Activity
Version: 6.x-1.0-alpha13 » 6.x-2.x-dev

Can we get quick guidance by the activity module maintainer? Feeds is invoking node prepare and insert hooks when creating a node, it is not invoking validate and submit hooks as it isn't submitting any forms. Where is activity module hooking into the node API?

Scott Reynolds’s picture

Category: bug » support
Status: Active » Needs review

Sorry guys been a very hectic week+

The solution is simple but really unfortunate. You will have to implement hook_activity_record_alter() in your own custom module.

function CUSTOM_MODULE_activity_record_alter(&$record, $context) {
  if ($context['hook'] == 'nodeapi' && $context['op'] == 'insert' && context['node'] && context['node']->type == 'feed_item') {
     record->uid = $context['node']->uid;
  }
}

This is ugly and we know it. It is resolved in the upcoming 7-3 branch. But that doesn't help you much right now.

bflora’s picture

Hey guys,

I know it's not proper Drupal procedure, but can I drop that code snippet in comment #2 into any old enabled module file isntead of creating a new module just for that function?

Yes, it's hacky and I'm a bad person for even asking, but as far as quick fixes go, can I just drop that into any enabled module file and have it start doing it's thing? I'm not 100% familiar with how Drupal "reads" the code in its different active modules.

sirkitree’s picture

Project: Activity » Feeds
Version: 6.x-2.x-dev » 6.x-1.x-dev

Sure you could throw it into Feeds module, maybe even create a patch for them.

function feeds_activity_record_alter(&$record, $context) {
  if ($context['hook'] == 'nodeapi' && $context['op'] == 'insert' && context['node'] && context['node']->type == 'feed_item') {
     record->uid = $context['node']->uid;
  }
}
alex_b’s picture

Status: Needs review » Needs work

Looks easy enough is that is all. NW for a proper patch.

YourBoyRoy-1’s picture

I created a custom module using the code you supplied and it does appear to trigger Activity to record a message if there is only one feed item being inserted. However, if there are multiple items being inserted, only the the first feed item's insertion is triggering Activity to record a message. This happens both via the Import button on the Feed Parents node page and via cron (both auto and manual).

feedsactivity.module as follows

function feedsactivity_activity_record_alter(&$record, $context) {
  if ($context['hook'] == 'nodeapi' && $context['op'] == 'insert' && $context['node'] && $context['node']->type == 'feed_item') {
    $record->uid = $context['node']->uid;
  }
}

feedsactivity.info as follows
name = Feeds Activity
description = Custom module to fix activity with feeds as per http://drupal.org/node/894724
core = 6.x
package = "Feeds"

Thank you for your time

twistor’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)