The checkbox 'Enable scheduled newsletter' doesn't work when you try to disble newsletter scheduling

Created on 18 October 2023, 9 months ago
Updated 12 June 2024, 21 days ago
πŸ› Bug report
Status

RTBC

Version

4.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain einarulfhednar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @einarulfhednar
  • @einarulfhednar opened merge request.
  • πŸ‡ͺπŸ‡ΈSpain einarulfhednar

    Problem/Motivation

    When we have the scheduled newsletter enabled and we want to disable it by unchecking the 'Enable scheduled newsletter' option, visually the option remains checked and in the 'simplenews_scheduler' table of the database the status of the 'activated' column never changes to 0.

    This is because, when the data is collected from the database (line 39 of the simplenws_scheduler.module file) a condition is not set to select those rows that have the status of the 'activated' column to 1 and, therefore, it never goes through the else on line 50 of the same file.

    Steps to reproduce

    1. Check Activate scheduled newsletter option.
    2. Click Save scheduler settings button.
    3. Uncheck Activate scheduled newsletter option.
    4. Click Save scheduler settings button.

    Proposed resolution

    In the data fetching (line 39 of the simplenews_scheduler.module file) add the condition to select the rows of the 'activated' column to 1.

    With this we get that, if there are no elements, it passes by else of the condition of line 46 and the variable $checked is set to FALSE.

  • Status changed to Needs review 8 months ago
  • πŸ‡©πŸ‡ͺGermany JoCowood Kamp-Lintfort

    Hi einarulfhednar,

    thank you for your merge request.

    I think the solution is good but not perfect. If you add the condition, you cannot access the remaining config of the inactive schedule. If a user wants to disable the scheduling but keeping the interval, date values and so on, this is not possible. The user will loose the rest of the config.

    What about setting the following patch? It sets checked based on the record and repairs the conditional invisible state of all following form fields, which was part of the code but broken.

  • πŸ‡©πŸ‡ͺGermany JoCowood Kamp-Lintfort

    My colleague goldfit found a bug in my patch. The submit button gets invisible, too. You cannot save a disabled scheduler. This is not part of my changes but the original code. I fixed that in the new patch.

  • πŸ‡©πŸ‡ͺGermany JoCowood Kamp-Lintfort

    Hey einarulfhednar,

    I would be more then happy to fix this bug in 4.0.0-alpha3 but I need a review. Do you mind reviewing my latest patch from #5?

  • Status changed to RTBC 21 days ago
  • πŸ‡ΊπŸ‡¦Ukraine Andriy Khomych

    I can confirm this issue, it even happens when you enable scheduling.
    The #5 patch works, thanks.
    I am moving it to RTBC.

Production build 0.69.0 2024