Newsletters sended to all subscriptions not only language preffered.

For example I create new newsletter with language russian. Then I request to send this newsletter and run cron.
Why do newsletter receive english subscriptions? Or maybe I'm doing something wrong?

Issue fork simplenews-1551752

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

marislazda’s picture

Priority: Normal » Critical

someone?

berdir’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Category: support » feature
Priority: Critical » Normal

This is currently not supported. Changing to a feature request.

alberto56’s picture

Title: Newsletters sended to all subscriptions not only language preffered » Multilingual improvements & make it possible to send nodes of a specific language only to subscribers of a specific langage
Status: Active » Needs review
StatusFileSize
new5.23 KB

In the current behaviour, nodes which are in a given language but not part of a translation set are considered just like a node with no language: they are sent to everyone.

This might not be ideal because you might have a situation where:

(1) A first node is created in French, and not part of a translation set
(2) The first node is queued for sending
(3) Cron runs, the node is sent to English and French subscribers
(4) A translated node is created in English and queued for sending
(5) Cron runs, and now the English node is sent to English subscribers, and the French node to French subscribers (even though they already got it).

This patch allows administrators to bypass the translation set logic entirely if required. (See image.)

This patch also provides another feature requested by marislazda, above, which requires nodes to be LANGUAGE_NONE or in a subscriber's preferred language before being sent. This will prevent nodes from being sent out to users who can't understand them, regardless of translation sets (in fact the translation module is not required for this at all).

See enclosed patch and screenshot

New simpletests are not included, though.

alberto56’s picture

StatusFileSize
new134.81 KB

Oops here is the screenshot.

alberto56’s picture

I am periodically getting a "status cannot be null" integrity constraint violation, in this call in simplenews.mail.inc:

function simplenews_update_spool($msids, $data) {
    db_update('simplenews_mail_spool')
      ->condition('msid', $msids)
      ->fields(array(
        'status' => $data['status'],
        'error' => isset($result['error']) ? (int)$data['error'] : 0,
        'timestamp' => REQUEST_TIME,
      ))
      ->execute();
}

Not sure if it is related to this patch though. Documenting it here in case some else gets it as well.

nikita.izotov’s picture

Issue summary: View changes

After patching i have this error after sending the newsletter out:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'status' cannot be null: UPDATE {simplenews_mail_spool} SET status=:db_update_placeholder_0, error=:db_update_placeholder_1, timestamp=:db_update_placeholder_2 WHERE (msid IN (:db_condition_placeholder_0)) ; Array ( [:db_update_placeholder_0] => [:db_update_placeholder_1] => 0 [:db_update_placeholder_2] => 1485254479 [:db_condition_placeholder_0] => 61 ) funktsioonis simplenews_update_spool() (rida 476 / /home/www/prod/sites/default/modules/contrib/simplenews/includes/simplenews.mail.inc).

nikita.izotov’s picture

SQL problem solved, this wasn't caused by this patch, but I found that simplenews will send newsletter nodes if they are not published.

How to do:
1. Create newsletter node, save and publish it.
2. Translate newsletter node, save without publishing,

What will happen:
Drupal will send original node what is published and not published translation.

To fix that i've created a small patch that is attached.

luksak’s picture

Probably this is not going to make it into 7.x anymore and AFAIK this is not implemented in 3.x. Therefore moving this to 3.x.

luksak’s picture

Version: 7.x-1.x-dev » 3.x-dev
Status: Needs review » Needs work
luksak’s picture

I am gong to try to implement this. How should we approach this? RecipientHandlerSelectBase builds the query, should it handle this logic as well or should we create a new RecipientHandler for this?

https://git.drupalcode.org/project/simplenews/-/blob/3.x/src/Plugin/simp...

luksak’s picture

Status: Needs work » Needs review

The merge request introduces a new RecipientHandler called RecipientHandlerTranslationRestricted that supports sending newsletter issues only to subscribers with the preferred language matching an existing translation of the issue.

I have no idea why there would be a merge conflict since the branch has the latest commits from 3.x. Could someone else have a look at this?

adamps’s picture

Title: Multilingual improvements & make it possible to send nodes of a specific language only to subscribers of a specific langage » Make it possible to send nodes of a specific language only to subscribers of a specific langage
Component: Documentation » Code
Status: Needs review » Needs work
Issue tags: +Needs reroll

omarlopesino made their first commit to this issue’s fork.

omarlopesino’s picture

The MR works fine into my site (Drupal 11). I've updated the MR thinking that the MR needs reroll, but i guess it is for the D7 patch, not the MR.

I've noticed that for example, when I create a newsletter issue, and I send it, if I create a translation, I can't send the translation of that content. This implies that if I want to send a newsletter in multiple languages, I need to create every translation before sending it.

Could it be good idea to re-queue the newsletter when a translation is created?

adamps’s picture

Version: 3.x-dev » 4.x-dev

Thanks. Fixes now need to be on 4.x.

I've noticed that for example, when I create a newsletter issue, and I send it, if I create a translation, I can't send the translation of that content. This implies that if I want to send a newsletter in multiple languages, I need to create every translation before sending it.

This is "works as designed". Each newsletter can only be sent once - otherwise it causes many problems for this module.

immaculatexavier made their first commit to this issue’s fork.