Getting a fatal error while doing the password reset function in user.module. Fatal error: Cannot redeclare _mimemail_replace_files() (previously declared in profiles/petfasion/modules/contrib/messaging/messaging_htmlmail/messaging_htmlmail.inc:422) in sites/all/modules/mimemail/mimemail.inc on line 104

This is on 7.8 on -dev modules.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sgabe’s picture

Project: Mime Mail » Messaging

It seems the maintainer of the Messaging module has copied some functions from Mime Mail. I am moving the issue to the right place.

sgabe’s picture

likewhoa’s picture

Priority: Normal » Major

why is this not getting any attention? I don't see this fixed in -dev yet. Pushing to major since it fubars the sites that users try to recover passwords from.

pereljon’s picture

Status: Active » Needs review
FileSize
9 KB

Patch included. Renamed all functions which could overlap with mimemail module.

jlea9378’s picture

Thanks, that solved it!

Dane Powell’s picture

Status: Needs review » Needs work

Definitely a problem but I don't think #4 is the best way to solve it. First of all, member functions of classes should be safe and don't need to be renamed. Second, simply copying functions from another module doesn't seem like The Drupal Way. What this probably means is that that module should be included as a dependency.

joelpittet’s picture

@Dane Powell, _mimemail_replace_files is not in the class it's in the global namespace, that is why it's causing the cannot redeclare message. The patch may have a been overzelous with find and replace but the problem is still very real.

The patch is good even if a little verbose.

joelpittet’s picture

FileSize
5.74 KB

Here is another patch with the method names left in tact, only modifying the function names.

The following renamed methods are lifts from mimemail and should be considered for sacking because they aren't referenced anywhere in the module.
messaging_htmlmail_parse_boundary
messaging_htmlmail_parse_headers
messaging_htmlmail_parse_content
messaging_htmlmail_parse_attachment
_messaging_htmlmail_expand_links

jackfoust’s picture

#8 seemed to work as a fix for me.

dimitriseng’s picture

Status: Needs work » Needs review
FileSize
5.74 KB

I encountered this issue when trying to send an email using the Contact Form and also when testing in the messaging settings. I can confirm that #8 has resolved the issue and unless there are any objections regarding the refactoring of the method names I think that it would be great to get this change commited as this is quite major IMO, thank you.

sgabe’s picture

I wonder why Messaging duplicates Mime Mail functions in the first place...?

sgabe’s picture

#1489018: Fatal Error when requesting new password is marked as a duplicate of this.

spgd01’s picture

#8 Works for me

jlea9378’s picture

Ran into this error again. I guess I must have updated the module. Applying the patch in #8 solved the problem once again. Can this get committed to dev?

acrazyanimal’s picture

Status: Needs review » Reviewed & tested by the community

Still an issue huh? Looks like they're looking for a new maintainer. Would be nice to get this at least committed since it is fairly critical. I can verify that #10 and #8 work.

Dane Powell’s picture

Status: Reviewed & tested by the community » Needs work

I recommend that people apply the patches in #8 or #10 as a temporary workaround, but those hacks are the wrong way to solve this issue in the long run. If Messaging needs these functions, it should simply declare a dependency on MIME Mail rather than blatantly (and poorly) copying its code.

Dane Powell’s picture

(FYI I am not an official maintainer by I do have Git access - I will gladly commit a less hackish patch if someone can come up with one)

spgd01’s picture

Is this ever going to be fixed? I cannot save new content.

I still get the following even with the new patch:

Fatal error: Cannot redeclare _mimemail_replace_files() (previously declared in /home/hiddenvi/public_html/sites/all/modules/messaging/messaging_htmlmail/messaging_htmlmail.inc:422) in /home/hiddenvi/public_html/sites/all/modules/mimemail_alpha/mimemail.inc on line 117

broncomania’s picture

Same here

aDarkling’s picture

The patch in #8 Worked fine for me.

While I agree with Dane that the messaging_htmlmail submodule should've required Mime Mail, we also have to consider that:

  1. the damage has been done & the code's already there. We're just fixing it;
  2. requiring Mime Mail also forces Mail System to be used, and at that point may just be overkill for some (minimalized) installations; and
  3. if we do spend time coding some cool plugin adapter to bypass the inefficiencies of point 2, will the occasion come up later for reuse with some other kind of email? I'm pretty sure not.

So, I think we should just commit it & move on.

dimitriseng’s picture

Does anybody have any thoughts on how we could move on with this? The patch in #8 is fixing the issue, so we need to consider the questions in #20 and try to progress this, thanks.

bluecobalt’s picture

Why is this issue still open and unaddressed?

I agree with Dane that messaging_htmlmail submodule should simply require Mime Mail.

joelpittet’s picture

Priority: Major » Critical
Status: Needs work » Needs review

Please commit #8 and move on ;)

alibama’s picture

wtf = thank you! this really should be committed = took me ages to debug as I was processing emails through a rule using rules views integration.... it was, of course, the last place I thought to look while debugging the process...

justadropofwater’s picture

Pretty please, will someone commit this?

fonant’s picture

#8 fixes the problem for me.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +namespaces
FileSize
11.35 KB

Just re-rolling #8 and setting to RTBC because quite a few people have commented on this. Hopefully someone will commit.

Whitespace has been trimmed(editor does that by default now to keep up with coding drupal code standards).

EDIT: To review patch:

curl https://drupal.org/files/1307166-27-redeclare-_mimemail.patch | git apply
git diff --color-words
likewhoa’s picture

Status: Reviewed & tested by the community » Needs review

@joelpittet all new patches need a review no matter how nice they are ;)

joelpittet’s picture

Fair enough...

eric_sea’s picture

#27 worked for me.

lunazoid’s picture

Issue summary: View changes

#27 did the job. Hoping this gets committed to dev to save headaches on future updates.

joelpittet’s picture

@lunazoid maybe you can mark it as RTBC? Though I don't think anybody is actively maintaining this module...

developerweeks’s picture

Joelpittet commented today already, but I just wanted to point out:
I downloaded the recommended versions of mailsystem and mimemail yesterday and this issue was in them. Just wanted to point out that this is not limited to the dev versions.

lunazoid’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #27 fixes the error.

gdhp’s picture

Any sign of this heading to a Dev release? Has been labelled as 'Reviewed and tested' since February. Would be good to see a dev release for those of us who don't like installing patches.

likewhoa’s picture

I guess this issue is not Critical enough for maintainers to have ignored since February :D

lokapujya’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.36 KB

The global functions taken from mimemail should be removed.

joelpittet’s picture

Status: Needs review » Needs work

@lokapujya look at the RTBC patch I did closer... Those private functions are being called in a few places. That's why I renamed them. You'd likely need to declare mimemail module a dependency for your patch to work. The #27 was already RTBC. Also, this project is likely abandoned by the maintainers because the last commit was on June 11, 2012 9:32.

lokapujya’s picture

Patch #27 is a good "patch," but does not eliminate the code duplication. Messaging will not reap the benefits of improvement to mimemail. Dane Powell suggested in #16 that a better long term solution is to make mimemail a dependency. I did not go that far because of aDarkling's concern in #20.2. I figured that if someone wants to install messaging without mimemail that it should be allowed (or that we would come up with an idea for that in another issue.) Possibly mimemail can be broken up in some way that makes it more pluggable?

The proposed patch in #37 will mean that you also need mimemail, but it's not an enforced requirement. I was thinking it could just be a documented dependency. Let me know what you think. If we were to do #27, would it make sense to namespace the functions (maybe just move the functions into the class) so that when we want to pull in the updates from mimemail, we can just copy them in?

What are our options for getting a maintainer? or if this module is actually abandoned, is there a preferred replacement module?

joelpittet’s picture

For dealing with an abandoned project @see https://drupal.org/node/251466

I don't know if there is a preferred replacement module.

The rename was the easiest solution that's why I did that, it doesn't break any existing code and esentially forks mimemail modules private functions.

You could namespace them inside a class as methods so they are easier to update, or just leave them forked and renamed as #27. #37 will lead to a bunch of errors if the module doesn't exist so at the very least you'd need to wrap each call in a module_exists() call. @see https://api.drupal.org/api/drupal/includes!module.inc/function/module_ex...

gdhp’s picture

In terms of a replacement for the Notifications/Messaging combo, the best option seems to be the subscriptions module. That has a lot of similar features, and from a UI perspective I actually prefer it.

The main drawbacks from what I can see are:

  • No ability to subscribe to a user
  • Only sends messages as an email

The latter is the only real reason I would rather use messaging module. Although given the limitations I'm finding on how it displays its on site messages even that seems less than worthwhile.

I don't know about for people who use the messaging module for anything other than the classic Messaging/Notifications combo. The two seem rather closely tied like that.

I'd rather see someone at least get this patch worked into the module for a dev release though, even if it's the only update we see in forever.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
6.7 KB

Removes the duplicated functions and makes mimemail a dependency.

joelpittet’s picture

@gdhp I'm sure nobody would blame you if you just took it over, did this patch and abandoned it again to someone else leaving it at "Seeking new maintainer".

I would if I ever used this module still, I only happened upon it with either a requirement for another module or just "installing shiny things syndrome" I seem to have...

sgabe’s picture

#2285901: Fatal Error on instal - config page is marked as a duplicate of this.

kevinsiji’s picture

Status: Needs review » Needs work

Applying patch #42 with git apply did not worked. No output.

Manually applied the patch and it fixes the error.

lokapujya’s picture

Status: Needs work » Needs review

Did you try applying it from the /messaging folder? you need to be in the 7.x-1.x branch of the messaging project.

kevinsiji’s picture

Folder is messaging and version is current dev version 7.x-1.x-dev (2013-Oct-01). I tried again today on a fresh copy of the module downloaded.

joelpittet’s picture

@kevinsiji I just applied #42 with no issues.

Commands to reproduce:

Download the latest dev version with drush

drush dl messaging --dev

Change directory into the messaging directory

cd sites/all/modules/messaging

Use curl to download the patch and patch using -p1 option

curl https://www.drupal.org/files/issues/1307166-42.patch | patch -p1

git apply will only work if downloaded messaging git repo as a submodule or it's own repo.
If you want to use git apply from your repo you'll likely need something to tell where this patch is to apply from you're git repo's root.
curl https://www.drupal.org/files/issues/1307166-42.patch | git apply --directory="html/sites/all/modules/contrib/messaging/"
From the above you can see where my git repo root is all the way to the messaging directory.

Hope that helps

HakimR’s picture

#8 worked for me !

kevinsiji’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @joelpittet for explaining #48
So it should be RTBC now.

GreenSkunk’s picture

Thanks for the patch and explanation! Patch#42 !

rwilson0429’s picture

Applied patch #42 and got this error:
Warning: preg_replace_callback(): Requires argument 2, '_mimemail_replace_files', to be a valid callback in /home1/xxxxxx/public_dev_html/sites/all/modules/messaging/messaging_htmlmail/messaging_htmlmail.inc on line 369

Fatal error: Call to undefined function _mimemail_file() in /home1/xxxxxx/public_dev_html/sites/all/modules/messaging/messaging_htmlmail/messaging_htmlmail.inc on line 377

Re-downloaded latest dev version and applied patch#8. Patch in #8 fixed the problem for me.

lokapujya’s picture

rwilson0429: Well the patch probably needs to be applied before installing the module, so that the dependent module gets loaded. Since you installed messaging first, you could just install mimemail to do what the patch is would have required.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.91 KB

The last patch added the dependency to the wrong module - it belongs in messaging_htmlmail.info, not messaging.info.

DamienMcKenna’s picture

lokapujya’s picture

Status: Needs review » Reviewed & tested by the community

  • Nafes committed a4f8808 on 7.x-1.x authored by joelpittet
    Issue #1307166 by joelpittet, lokapujya, DamienMcKenna, dimitriseng,...
Nafes’s picture

Status: Reviewed & tested by the community » Fixed

Agree with #20. Committed #27.

Agree, that code duplication is not very good, so opened new issue #2552085: Remove code duplication.

DamienMcKenna and lokapujya, thank you for your efforts!

Status: Fixed » Closed (fixed)

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