On PHP 5.2 or 5.3, without the PHP4 date module loaded, date_modify doesn't work with stanzas like "+1 Sunday".

That means that the following piece of code:

if (date_format($current_day, 'l') != $day) {
date_modify($current_day, '+1 '. $day);
$moved = TRUE;
}

in date_repeat_calc.inc causes infinite loops when trying to compute by day rules.

It appears that just commenting out those 4 lines makes things work again, though as I don't know other ramifications of this, I'm not including the patch.

Comments

sdague’s picture

Status: Active » Needs review
StatusFileSize
new1.35 KB

The following patch seems to be a safe fix for this. It basically just checks to see if the date actually changed at all before it sets $moved so that we don't loop forever without moving forward. After doing this imports of all manner of odd recurrance events work, and don't put us into an infinite loop. This works with either the Date PHP4 module loaded, or with it not loaded on PHP5.2 or 5.3.

sdague’s picture

Bump. It would be nice if someone looked at this.

karens’s picture

The project page says PHP 4 issues are receiving little or no support. We are now supporting PHP 5.2 and PHP 5.3 across two versions of Drupal, which is already more than I can reasonably accomplish. PHP 4 is ridiculously old at this point and there are tons of other problems with it when it comes to using dates.

sdague’s picture

Title: by day recurrance rules cause infinite loop if PHP4 compat code is not loaded » by day recurrance rules cause infinite loop if PHP4 compat code is *not* loaded

The issue *isn't* using PHP4.

The issue is that when you disable the Date PHP4 compat library on a PHP 5.2 / 5.3 installation things go wrong. The Date PHP4 compat library has more features than the actual date implementation in PHP 5.2 / 5.3. The Date library depends on these features when parsing recurring dates, and thus *breaks* on PHP 5.2 / 5.3.

I'm all for dumping PHP4 support, but this is an issue where things break unless you load PHP4 compatibility code on new PHP, which seems pretty broken.

tomdisher’s picture

This patch seems to be working for me - brilliant. Thank you!

jspayne’s picture

Subscribing - this patch needs to be integrated. Solved my problem as well.

karens’s picture

Status: Needs review » Postponed (maintainer needs more info)

The '+1 Sunday' code works fine in D7 where we don't even have a PHP4 module. I can't see any reason why this wouldn't work fine as-is. The code in date_repeat_calc.inc is the same in D6 and D7 and I've received no reports of problems in D7.

I need steps to reproduce a problem in D6.

sdague’s picture

Status: Postponed (maintainer needs more info) » Needs review

The situation that creates this issue:

Using feeds + ical_parser to load ical feeds and create nodes out of them. ical_parser calls down into date_repeat_calc.inc to do it's ical manipulation. If it runs into an event with an RRULE (especially those with EXCEPT or ADD in the mix), without this patch it goes into an infinite loop, eventually crashing with a PHP timeout.

All this patch makes sure is that the date_modify actually moved forward before setting $moved. It's a safety check.

Status: Needs review » Needs work

The last submitted patch, 0001-Issue-1105858-by-sdague-check-to-make-sure-we-actual.patch, failed testing.

sdague’s picture

Upload rebased patch

damienmckenna’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

Unfortunately the D6 version of this module is no longer supported, but we appreciate the time you put into this.