Hi there I have been at this module for 2 days now : ( - I get the following error when importing "Unable to create comment with empty NID."

Config is
Mail Comment 7.x-2.2
Mailhandler 7.x-2.2
Notif/Messaging 7.x-1.0-alpha2
I have used both PHPMailer & SMTP

Under mailhandler = domain is "website.com"
Server string for Message Id = "website.com"
The ((( Reply ABOVE this LINE to POST a COMMENT ))) doesnt appear but i guess that can be added manually.

I do not know - what is wrong or how to fix the problem ( ive look at other similar post - but no avail) any guidance at this point would be greatly appreciated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sylense’s picture

Priority: Normal » Major

I have the same problem but it only happens when I use one of the filter modes (basic or aggressive). If I have no filtering selected then the comments import successfully but then I have a bunch of email gunk (signature, original message, etc) that I do not want imported. I think this is a major bug possibly with the regex somehow removing the NID before the import takes place resulting in a failed import.

Do you have a filter mode selected?

Sylense’s picture

Assigned: danshadow » Unassigned
danshadow’s picture

Thanks for your response, but unfortunately there is no filter : its set to ( No import filter. Leave messages as-is. )

Sylense’s picture

Hmm...I'm using IMAP and my setup works fine with no filtering however, I do get this same error message when attempting to import comments with filtering turned on. I'm not sure how related the two issues are.

Cosades85’s picture

I am faced with the same issue. My config is identical:

Mail Comment 7.x-2.2
Mailhandler 7.x-2.2
Notif/Messaging 7.x-1.0-alpha2
I have used both PHPMailer & SMTP

I'll add that the INSTALL.txt in /modules/mailcomment says the dependenciy on NOtif/Messaging is the 4-x branch:

- Notifications and Messaging (7.x-4.x branch)

Sylense, can you add any more details to your setup, or is it identical?

Thanks

malancheril’s picture

I have the same setup and the same issue as Sylense. I get the same message but only when basic or aggressive filtering is set. Has anyone found a solution or a workaround?

malancheril’s picture

This might be an issue. In mail comment.module I noticed this comment:
* The message id should have this form:
* uid.nid.cid.time.signature@server string

When I turn off filters and create a new piece of content, my gmail account gets an email as expected. When I view "Original message" in gmail, I can see a line that says:
Message-ID: <1.20.0.1362587781.a503fbf34290d692a1704bcf63348c8a@myserver.com>

But when I turned on the filters, the message ID was different:
Message-ID: <51376eff.c79f320a.432b.1db3SMTPIN_ADDED_BROKEN@mx.google.com>

...which would cause the NID mismatch. Does this shed any light? Has anyone had a similar experience?

amourow’s picture

the same problem as @malancheril (#7) described.
Now the reply text cannot be stripped.

kristat’s picture

Subscribe. Same problem

rob.barnett’s picture

I also had the same problem. mailcomment inserts a url at the end of the email comment like so:
View original post: http://example.com/mailcomment/redirect/%3C2506.38126.56232.1370016261.8....
But this url gets stripped by the filters.

By including the following function and adding the appropriate url back into the filter (mailcomment.module) the comment posts correctly for me.

/**
 * retrieve urls from text.
 */
function getUrls($string) {
        $regex = '/https?\:\/\/[^\" ]+/i';
        preg_match_all($regex, $string, $matches);

        return ($matches[0]);
}

Aggressive filter:

$urls = getUrls($text);
$text = trim(drupal_substr($text, 0, $matches[0][1])) . '<br><span style="display:none;">' . $urls[6] . '</span>';

You also would need to concatenate the $urls array to the basic filter as well.

mudsurfer’s picture

Hey Hurley - Thanks!
I'm an utter coding noob. I have now got mail comment working except for this filter problem, and it looks like your solution should be what I try next. Can you give a quick clue as to where in the mailcomment.module I put these changes? ie: does it matter where in the module that the additional function goes? I think I found the section that is the aggressive filter (under function_mailcomment_filter_aggressive($text)?) - but not sure where to paste these extra lines?

If easy for you to spit this out as a patch, I know how to deal with that (because it shows me the line numbers I need to play with :)

randallknutson’s picture

Category: support » bug
Status: Active » Needs review
FileSize
721 bytes

Just ran into this. Attached is a patch that cleans up the code from #10 a bit and makes it more robust. I only fixed aggressive for now.

Dane Powell’s picture

Triggering automated testing.

Status: Needs review » Needs work

The last submitted patch, mailcomment-empty-nid-1889550-12.patch, failed testing.

Dane Powell’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, mailcomment-empty-nid-1889550-12.patch, failed testing.

Dane Powell’s picture

Version: 7.x-2.2 » 7.x-2.x-dev
Status: Needs work » Needs review

Trying to get tests running properly.

Dane Powell’s picture

Status: Needs review » Needs work

The last submitted patch, mailcomment-empty-nid-1889550-12.patch, failed testing.

Dane Powell’s picture

Looks like #12 throws notices, and needs work.

Dane Powell’s picture

Title: Unable to create comment with empty NID » Broken imports when aggressive filter is used
Status: Needs work » Fixed
Dane Powell’s picture

Status: Fixed » Closed (fixed)

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