I've been trying to get mailcomment working on Drupal 7.9. I get an email notification formatted by mailcomment when a comment is left for a particular node, but when I reply to an email and it is processed by mailcomment, I get a php error:

Recoverable fatal error: Argument 1 passed to mailcomment_source_get_source() must be an instance of FeedsImportBatch, instance of FeedsSource given, called in /drupal-7/sites/default/modules/feeds/plugins/FeedsProcessor.inc on line 386 and defined in mailcomment_source_get_source() (line 451 of /drupal-7/sites/default/modules/mailcomment/mailcomment.module).

Location http://drupal-7/batch?id=479&op=do
Referrer http://drupal-7/batch?op=start&id=479

I tracked down that mailcomment_source_get_source is expecting a FeedsImportBatch, and according to http://drupal.org/node/1180174

In Feeds 7.x-2.0, the FeedsBatch/FeedsImportBatch class is gone and is replaced with different "result" classes that are returned by Fetchers and Parsers. Instead of returning an object of class FeedsImportBatch, therefore, the Fetcher returns an object of type FeedsFetcherResult.

Here's the function declaration for mailcomment_source_get_source (which is set as a callback from mailcomment_feeds_parser_sources_alter):
function mailcomment_source_get_source(FeedsImportBatch $batch, $key) {

And here's taxonomy_feeds_get_source, (which is set as a callback from taxonomy_feeds_parser_sources_alter in modules/feeds/mappers/taxonomy.inc):
function taxonomy_feeds_get_source(FeedsSource $source, FeedsParserResult $result, $key) {

I changed mailcomment_source_get_source as follows, which fixed the error, but the comment reply email still isn't being processed.
function mailcomment_source_get_source(FeedsSource $batch, FeedsParserResult $result, $key) {

Still kind of stuck here, but I'm going to keep on it till I figure it out. If anyone can offer any help or advice it would be great. Maybe I'm doing something really wrong here!

CommentFileSizeAuthor
#2 mailcomment-1350072-3.patch958 bytespereljon

Comments

pereljon’s picture

Issue summary: View changes

Clarification in summary

pereljon’s picture

Ok... Looks like I was mapping the result to the wrong argument. Here's the fixes I'm proposing.
1. Change the mailcomment_source_get_source function comment to reflect the new hook_feeds_parser_sources_alter.
2. Change the mailcomment_source_get_source function arguments to ($source, FeedsParserResult $result, $key).
2a. Change the name of the "batch" argument variable to "result" to match hook_feeds_parser_sources_alter.

I'm going to package this into a patch and post it.

Cheers,
JP

/**
 * Callback specified in hook_feeds_parser_sources_alter().
 *
 * To be invoked on mapping time.
 *
 * @param $source
 *   The FeedsSource object being imported.
 * @param $result
 *   The FeedsParserResult object being mapped from.
 * @param $key
 *   The key specified in the $sources array in
 *   hook_feeds_parser_sources_alter().
 *
 * @return
 *   The value to be extracted from the source.
 *
 * @see hook_feeds_parser_sources_alter()
 * @see locale_feeds_get_source()
 */
function mailcomment_source_get_source($source, FeedsParserResult $result, $key) {
  $item = $result->currentItem();
pereljon’s picture

StatusFileSize
new958 bytes

Here's the patch.

pereljon’s picture

Mis-numbered the patch for comment 3. This comment's just filler.

danepowell’s picture

Title: Recoverable fatal error: Argument 1 passed to mailcomment_source_get_source() must be an instance of FeedsImportBatch » Recoverable fatal error on comment import
Priority: Normal » Critical
Status: Active » Fixed

Right you are! Don't know how that slipped through testing. Thanks for the patch!
http://drupalcode.org/project/mailcomment.git/commit/d69a41a

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added tags