Closed (fixed)
Project:
Simplenews
Version:
6.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Oct 2008 at 13:48 UTC
Updated:
7 May 2009 at 18:39 UTC
Jump to comment: Most recent file
Comments
Comment #1
thepanz commentedI can confirm this behavior: if I switch the two test eMail addresses only the first one will get the entire body message, the other one receives only ---- TITLE ---- and default footer message with unsubscribe link, no body message.
Regards
Comment #2
thepanz commentedHi, I couldn't help to don't look for a solution for my issue :)
I found that if a newsletter issue isn't translated (I'm using Locale, but no translations for content is setted) Simplenews, while sending mails, try to cache all contents with user-preferred language. This results in a double node_build for the same node. First time everything is ok, then re-building the same node results in a missing content (node fields are precedent setted to #display = TRUE, so no rendering will be done).
I added a simple statement for let simplenews know to re-use the same rendered node even if there isn't any available translation.
Hope my patch will be usefull...
Regards
Comment #3
sutharsan commentedI can not reproduce your error. Please provide more details of your configuration. Which relevant modules are enabled, what languages are used, what is the default, what is the language of the newsletter, with which subscriber preferred language does the error occur, etc.
Please explain: 'node fields are precedent setted to #display = TRUE, so no rendering will be done'.
The provided patch seems a hacky solution to me, therefore it needs work.
Comment #4
thepanz commentedHi Sutharsan, thank you for your attention! I'll try to explain my Drupal configuration:
- Latest Drupal 6.x version
- Latest Simplenews 6.x-1.x version (retrieved by CVS)
- Locale module enabled
- English and Italian translations enabled
- Italian as site-default language
- Preserve_Language module enabled (http://drupal.org/project/preserve_language)
- Multilingual support for Simplenews-content is: Disabled (that, in conjunction with preserve_language, gives to newly created issue default language "Neutral" and not the site-default one)
Sending an issue test eMail i get that only first eMail address receives the full eMail (with title, body and footer), the others receives a mail without the body part (only --TITLE-- and the appended footer message).
After some debug I noticed that when retrieving the simplenews-node content for sending, Simplenews caches the email body on a $messages[NID][LANG] array. If the receiver user setted a preference for any language in the $account object, Simplenews uses tha right cached message. My issue is related to simplenews-nodes that haven't any language setting (remember the "Neutral" setting as default).
take an example where node N1 (Neutral language) and two users U1 (english) and U2 (other language). In that case Simplenews retrieve and render N1; caches N1 in $messages[1][en] and sends it to U1, for U2 simplenews retrieves and render (*again*) N1 and caches it under $messages[1][otherlanguage].
The second rendering results in a missing content because Drupal already cached N1 after it have been rendered. You can view that printing $node after each render: first time you'll see the right node object with each field, the second time you'll notice that $node fields will have a $field[#display] = TRUE. This is because Drupal have already processed and rendered that field so it won't be displayed again.
Comment #5
sutharsan commentedPlease try again with the latest 6.x-1.x-dev (use CVS). The attached patch has been committed.
The attached partly reverses #321750 and makes sure that node_load returns the same array as node insert/update. With the attached patch and preserve_language my test-site works fine.
Feel free to re-open the issue if the problem persists.
Comment #6
thepanz commentedHi, I updated Simplenews to latest 6.x-1.x-DEV version. My issue is still there. To reproduce you need at least 2 users: one with EN language setting, and the second with XX (use a random language code).
If your newsletter issue haven't any translation available Simplenews will:
1. Retrieve node/issue
2. fetch user lang-code (as an example EN)
3. render node/issue
4. store rendered node/issue with *user* lang-code (remember: always as EN)
5. send Email to address
when the second user is taken from the list simplenews will do the same as above, BUT the node in step 1 is the same retrieved before (and Cached by Drupall). So in step 3: Drupal will provide the cached rendered node with all fields previously displayed as empty. That node will be stored and sent. This is the cause of empty mail body if test-address are owned by different language users.
My "hacky " solution simply check if the node have a translation, if NOT re-use it for ALL email addresses: there is also no need to store translated versions of body if it's always the same..
Let me know if you need more info
Regards
Comment #7
sutharsan commentedThanks for your detailed explanation. The problem comes from drupal_render() modifying the node object. This will cause the node body to be empty the next time it is rendered. The attached patch should fix this.
Comment #8
thepanz commentedThank you Sutharsan for your attention and patch. I'll try it ASAP and I'll post my review.
Regards
Comment #9
thepanz commentedYour patch is already in latest 6.x CVS branch :)
I tested it with some test-email sending and It's working without any problem for now.
Comment #10
sutharsan commentedYes, I was inpatient ;) Thanks for testing.
Comment #12
Tmanagement commentedThis issue looks quit similar to my problem which I submitted...http://drupal.org/node/453334
Since it seems that the issue from this post has been solved I was wondering if it is indeed the same issue as the one I posted and if so do I need to pick the dev version from march to solve this?
Comment #13
Tmanagement commentedSomebody?