Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#54 | messaging-n1307166-54.patch | 6.91 KB | DamienMcKenna |
Comments
Comment #1
sgabe CreditAttribution: sgabe commentedIt seems the maintainer of the Messaging module has copied some functions from Mime Mail. I am moving the issue to the right place.
Comment #2
sgabe CreditAttribution: sgabe commented#1403316: Cannot redeclare _mimemail_replace_files() is marked as a duplicate of this.
Comment #3
likewhoa CreditAttribution: likewhoa commentedwhy 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.
Comment #4
pereljon CreditAttribution: pereljon commentedPatch included. Renamed all functions which could overlap with mimemail module.
Comment #5
jlea9378 CreditAttribution: jlea9378 commentedThanks, that solved it!
Comment #6
Dane Powell CreditAttribution: Dane Powell commentedDefinitely 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.
Comment #7
joelpittet@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.
Comment #8
joelpittetHere 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
Comment #9
jackfoust CreditAttribution: jackfoust commented#8 seemed to work as a fix for me.
Comment #10
dimitriseng CreditAttribution: dimitriseng commentedI 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.
Comment #11
sgabe CreditAttribution: sgabe commentedI wonder why Messaging duplicates Mime Mail functions in the first place...?
Comment #12
sgabe CreditAttribution: sgabe commented#1489018: Fatal Error when requesting new password is marked as a duplicate of this.
Comment #13
spgd01 CreditAttribution: spgd01 commented#8 Works for me
Comment #14
jlea9378 CreditAttribution: jlea9378 commentedRan 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?
Comment #15
acrazyanimal CreditAttribution: acrazyanimal commentedStill 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.
Comment #16
Dane Powell CreditAttribution: Dane Powell commentedI 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.
Comment #17
Dane Powell CreditAttribution: Dane Powell commented(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)
Comment #18
spgd01 CreditAttribution: spgd01 commentedIs 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
Comment #19
broncomania CreditAttribution: broncomania commentedSame here
Comment #20
aDarkling CreditAttribution: aDarkling commentedThe 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:
So, I think we should just commit it & move on.
Comment #21
dimitriseng CreditAttribution: dimitriseng commentedDoes 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.
Comment #22
bluecobalt CreditAttribution: bluecobalt commentedWhy is this issue still open and unaddressed?
I agree with Dane that messaging_htmlmail submodule should simply require Mime Mail.
Comment #23
joelpittetPlease commit #8 and move on ;)
Comment #24
alibama CreditAttribution: alibama commentedwtf = 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...
Comment #25
justadropofwater CreditAttribution: justadropofwater commentedPretty please, will someone commit this?
Comment #26
fonant CreditAttribution: fonant commented#8 fixes the problem for me.
Comment #27
joelpittetJust 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:
Comment #28
likewhoa CreditAttribution: likewhoa commented@joelpittet all new patches need a review no matter how nice they are ;)
Comment #29
joelpittetFair enough...
Comment #30
eric_sea CreditAttribution: eric_sea commented#27 worked for me.
Comment #31
lunazoid CreditAttribution: lunazoid commented#27 did the job. Hoping this gets committed to dev to save headaches on future updates.
Comment #32
joelpittet@lunazoid maybe you can mark it as RTBC? Though I don't think anybody is actively maintaining this module...
Comment #33
developerweeks CreditAttribution: developerweeks commentedJoelpittet 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.
Comment #34
lunazoid CreditAttribution: lunazoid commentedThe patch in #27 fixes the error.
Comment #35
gdhp CreditAttribution: gdhp commentedAny 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.
Comment #36
likewhoa CreditAttribution: likewhoa commentedI guess this issue is not Critical enough for maintainers to have ignored since February :D
Comment #37
lokapujyaThe global functions taken from mimemail should be removed.
Comment #38
joelpittet@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.
Comment #39
lokapujyaPatch #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?
Comment #40
joelpittetFor 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...
Comment #41
gdhp CreditAttribution: gdhp commentedIn 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:
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.
Comment #42
lokapujyaRemoves the duplicated functions and makes mimemail a dependency.
Comment #43
joelpittet@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...
Comment #44
sgabe CreditAttribution: sgabe commented#2285901: Fatal Error on instal - config page is marked as a duplicate of this.
Comment #45
kevinsiji CreditAttribution: kevinsiji commentedApplying patch #42 with
git apply
did not worked. No output.Manually applied the patch and it fixes the error.
Comment #46
lokapujyaDid you try applying it from the /messaging folder? you need to be in the 7.x-1.x branch of the messaging project.
Comment #47
kevinsiji CreditAttribution: kevinsiji commentedFolder 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.
Comment #48
joelpittet@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
Comment #49
HakimR CreditAttribution: HakimR commented#8 worked for me !
Comment #50
kevinsiji CreditAttribution: kevinsiji commentedThanks @joelpittet for explaining #48
So it should be RTBC now.
Comment #51
GreenSkunkThanks for the patch and explanation! Patch#42 !
Comment #52
rwilson0429 CreditAttribution: rwilson0429 commentedApplied 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.
Comment #53
lokapujyarwilson0429: 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.
Comment #54
DamienMcKennaThe last patch added the dependency to the wrong module - it belongs in messaging_htmlmail.info, not messaging.info.
Comment #55
DamienMcKennaComment #56
lokapujyaComment #58
Nafes CreditAttribution: Nafes as a volunteer commentedAgree 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!