Problem/Motivation

(Why the issue was filed, steps to reproduce the problem, etc.)
Mailhandler is not correctly setting the status of comments (published / unpublished) when creating comments from parsed emails. Emails received from authenticated users are set to unpublished, meaning they are not visible to regular users of the space. I assume they should be published.

So far I have only found this with Discussion comments, but from what I have found I think it will effect all comment imports.

Looking at the address www.example.com/import/comment_reply_email_importer I notice default commands are being applied to set the published status for authenticated users. This in turn led me to the following file: profiles/openatrium/modules/contrib/mailhandler/plugins/mailhandler/commands/MailhandlerCommandsDefault.class.php

It appears to me that there is an issue in the regex pattern on line 117 in method getCommands(). The hyphen character in the first matching group after the underscore and before the whitespace, is meant to match a literal hyphen, and hence needs escaping with a backslash. As a result the preg_match() function doesn't return *any* matches and the published flag doesn't get correctly set on the newly created comment.

Proposed resolution

I shall be attaching a patch to the issue shortly, once I have the issue's number for the patch file.

Remaining tasks

The patch will require review.

CommentFileSizeAuthor
#3 openatrium-regexfix-2651534-1.patch982 bytesbombjack

Comments

bombjack created an issue. See original summary.

bombjack’s picture

bombjack’s picture

StatusFileSize
new982 bytes

Patch file attached

bombjack’s picture

Status: Active » Needs review
kevster111’s picture

I haven't had this issue. I have a smaller issue with mailhandler not sending replies to replies if sent from email but only with some content types.

So far comments are all published correctly. I am using this heavily now and will try some things to recreate your issues.

bombjack’s picture

Intresting, replies to replies were being sent fine for me in my evaluation environment which is a couple of steps behind dev (openatrium-7.x-2.50) running on php 5.5.30. Haven't actually updated my codebase as yet, still evaluating on a private server. I shall update to 7.x-2.52 soon and establish whether the replies to replies still work, and post back with any results.

For me it was just that the inbound email imports where showing up as unpublished, so as user 1 I can see them, but none of the regular site users could until some user with the correct privileges published the comments. Adjusting the regex fixed my problem.

My patch was created against the dev version, as I checked the regex prior to creating the issue, to see if it had been already been changed. It was still the same as what i have in 7.x-2.50 version, so I went ahead and created the issue / patch against the dev version.

bombjack’s picture

@kevster111 I can confirm that I still have replies sent to people requesting notifications as a result of email replies received after upgrading the codebase to 7.x-2.52, again running on php 5.5.30

Best of luck tracking down your issue.

mpotter’s picture

Using an online prg_match tester, I don't find any difference between the using the original pattern and using your patch. While escaping the hyphen is probably a good idea, I don't think it is the cause of your problem.

bombjack’s picture

Hi Mike,

I used regex101.com: https://regex101.com/r/yP4vU6/1

It showed the error, changing it fixed the problem for me.

Perhaps it is somewhat dependent on the PHP configuration settings, and hence might work for others where it didn't for me?

mpotter’s picture

Status: Needs review » Active

It's potentially dependent on PHP version or settings. This patch is for the mailhandler module so you probably want to post it over in that project queue.

bombjack’s picture

Hi Mike,

Yeah sorry I wasn't sure whether plugins in the mailhandler module might have been OA specific.

Looking in to, someone else has had a similar issue and opened an issue in the mailhandler issue queue. https://www.drupal.org/node/2333087

Looks like it's been sitting there for a while sadly :-( I added a comment to try and bump it along rather than duplicating it, but looking at the project's commit history nothings been committed for nearly a year now. Not sure what else to do.

I couldn't find anything in the PHP documentation (albeit after only a quick look). Given its a bit random I wonder if it has anything to do with the underlying libraries using when compiling PHP?

sunfinger’s picture

Hi,

I've got exactly the same issue. The status command is not processed.
I have removed the NID from the mapping to induce an "Unable to create comment with empty NID" error and visualizing parsing in the feed log:

Original item:
array(
  'imap_uid' => 26,
  'body_text' => "status: 1\n<!DOCTYPE html>\r\n<html><head>\r\n    <meta charset=\"UTF-8\">\r\n</head><body><p>23h08<br></p...",
  'body_html' => "<!DOCTYPE html>\r\n<html><head>\r\n    <meta charset=\"UTF-8\">\r\n</head><body><p>23h08<br></p><blockquo...",
  'authenticated_uid' => '3',
  'date' => 'Mon, 14 Mar 2016 23:08:36 +0100 (CET)',
  'Date' => 'Mon, 14 Mar 2016 23:08:36 +0100 (CET)',
  'subject' => 'Re: [Graphisme] Banniere 3 #7: offending "submit" link',
  'Subject' => 'Re: [Graphisme] Banniere 3 #7: offending "submit" link',
...
Entity :
(object) array(
  'cid' => 0,
  'pid' => 0,
  'nid' => 0,
  'uid' => 3,
  'node_type' => 'comment_node_image_contest',
  'hostname' => '127.0.0.1',
  'created' => 1457993072,
  'changed' => 1457993072,
  'language' => 'und',
  'name' => '',
  'mail' => '',
  'subject' => 'Re: [Graphisme] Banniere 3 #7: offending "submit" link',
  'feeds_is_new' => TRUE,
  'status' => '',
)

The patch is working for me too. Hope that this tiny modification will be done in the 2.60 version.

Thanks a lot

mpotter’s picture

Assigned: bombjack » Unassigned
Status: Active » Closed (won't fix)

Only Assign an issue to somebody if that person is specifically working on a patch.

I'm closing this issue because further discussion of this needs to take place over in the Mailhandler project as mentioned in #11. Nothing I can fix directly in Atrium.

neurojavi’s picture

I've had the same problem with comments posted as unpublished. Applying the patch in #2333087: Regex issue in MailhandlerCommandsDefault.class.php after php upgrade solved the problem. I know this is not OA related but maybe you could consider to include this patch for Mailhandler in OA...

Thanks.-