CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Problems with scheduled reminders in 4.1.3
Pages: [1]

Author Topic: Problems with scheduled reminders in 4.1.3  (Read 1534 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Problems with scheduled reminders in 4.1.3
June 15, 2012, 01:21:35 am
Hi,

I'm testing 4.1.3 on a test server, and in particular the fix for CRM-9805 (reminders sent for ancient events). I've found 3 problems.

The code shipped with 4.1.3 will only work for absolute dates

To use relative dates, the patch at https://fisheye2.atlassian.com/browse/CiviCRM/branches/v4.1/CRM/Core/BAO/ActionSchedule.php?r2=41029&r1=40475 is required.

The fix is part of CRM-10384, courtesy of Yashodha Chaku.

But even with that fix applied, there are two other problems...

I can still generate reminders for ancient events

As you can see from the redacted reminder email, below, reminders were sent for events as far back as November 2008.

The reminders were set to go to ANY participant status at an event of type "Training", 1 day AFTER the Event Start Date, with no particular recipient roles selected.

I don't get this when the reminder is sent 1 day BEFORE the Event Start Date.

Token replacement doesn't work in the HTML part of the message

When I set the HTML format to be ...

{event.title}

{event.start_date}

The title and start date appear in the Text part but not the HTML part. The tokens are replaced with empty text in the HTML.

Quote
To: "Xxxx Xxxx" <xxxx.xxxx@example.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="=_ee0063c724591dd1e88f8f6e07f241f2"
From: Xxxx Xxxx <xxxx.xxxx@example.org>
Subject: cya6
To: "Xxxx Xxxx" <xxxx.xxxx@example.com>

--=_ee0063c724591dd1e88f8f6e07f241f2
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=utf-8



    Event title here

    2008-11-25 13:00:00
--=_ee0063c724591dd1e88f8f6e07f241f2
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset=utf-8

<p>
   </p>
<p>
   </p>
--=_ee0063c724591dd1e88f8f6e07f241f2--

Ken
« Last Edit: June 15, 2012, 01:54:26 am by ken »

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Problems with scheduled reminders in 4.1.3
June 20, 2012, 07:52:50 pm
Analysis of why reminder emails are still being sent for ancient events

Looking at the code in CRM/Core/BAO/ActionSchedule.php, if the reminder is set to be sent before the Event Start/End Date, the logic only permits reminders to be sent if ...

        event-date - offset <= now <= event-date + 1 day

... and if the reminder if to be sent after the event, the logic permits reminders if ...

        now <= event-date + offset

... which permits reminders for ancient events. (There is another condition, but this doesn't stop old reminders being sent. It is: now <= event-date - 1 day)

Looking at the logic Lobo proposed in http://forum.civicrm.org/index.php/topic,23423.0.html I think the logic ought to be ...

        event-date + offset <= now <= event-date + offset + 1 day

... where the offset is positive or negative depending on before/after

In order to create a patch that minimises the code changes, observe that this condition can be rewritten ...

        now - 1 day <= event-date + offset <= now

The following patch will implement this logic ...

Code: [Select]
--- branches/v4.1/CRM/Core/BAO/ActionSchedule.php (.../ActionSchedule.php)
+++ branches/v4.1/CRM/Core/BAO/ActionSchedule.php (.../ActionSchedule.php)
@@ -841,11 +841,10 @@
       if ($actionSchedule->start_action_date) {
         $startDateClause   = array(); 
         $operator          = ($actionSchedule->start_action_condition == 'before' ? "DATE_SUB" : "DATE_ADD");
-        $op                = ($actionSchedule->start_action_condition == 'before' ? "<=" : ">=");
         $date              = $operator . "({$dateField}, INTERVAL {$actionSchedule->start_action_offset} {$actionSchedule->start_action_unit})";
         $startDateClause[] = "'{$now}' >= {$date}";
 
-        $startDateClause[] = $operator . "({$now}, INTERVAL 1 DAY ) {$op} {$dateField}";
+        $startDateClause[] = "DATE_SUB({$now}, INTERVAL 1 DAY ) <= {$date}";
         $startDate = implode(' AND ', $startDateClause);
       }
       elseif ($actionSchedule->absolute_date) {

I'll attach that patch to http://issues.civicrm.org/jira/browse/CRM-10384

Ken

ZenLax

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • Not an engineer, but I play one on TV.
  • CiviCRM version: 4.8
  • CMS version: Drupal 6.x/7.x
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Problems with scheduled reminders in 4.1.3
March 10, 2013, 10:54:47 pm
Can anyone tell me if this patch has been applied in production yet? I am running 4.2.8 but still having problems with scheduled reminders for relative dates.

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Problems with scheduled reminders in 4.1.3
March 18, 2013, 04:07:05 am
It appears this was fixed in 4.1.4. It could be your problem is due to a regression of this issue. What are your symptoms, and are they reproducible?

ZenLax

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • Not an engineer, but I play one on TV.
  • CiviCRM version: 4.8
  • CMS version: Drupal 6.x/7.x
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Problems with scheduled reminders in 4.1.3
March 18, 2013, 05:34:30 am
Hi Ken, thank you for posting a reply. It is indeed mysterious. I posted the symptoms here http://forum.civicrm.org/index.php?topic=27985

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Problems with scheduled reminders in 4.1.3
March 21, 2013, 01:24:51 pm
@zenlax,

your issue is different to this one.

Ken

ZenLax

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • Not an engineer, but I play one on TV.
  • CiviCRM version: 4.8
  • CMS version: Drupal 6.x/7.x
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Problems with scheduled reminders in 4.1.3
March 22, 2013, 01:06:09 am
OK thanks much :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Problems with scheduled reminders in 4.1.3

This forum was archived on 2017-11-26.