Bug workaround: use strftime instead of date('r') calls

Warwick Smith warwick@imvs.sa.gov.au
Fri, 8 Feb 2002 10:36:29 +1030


Around a week ago (4/2) I posted a note about a workaround for a PHP bug
(#15362) in the "date" function with some timezones, when using the 'r'
parameter by using the "strftime" function in it's place.

As this bug seems to exist in PHP versions 4.05 -> 4.1.1 (at least), I would
like to make a bold suggestion to the developers to replace the use of the
date('r') calls with strftime('%a, %e %b %Y %T %z').  This provides the same
RFC style date output, but doesn't encounter the PHP bug (ie it will work
properly!)

When I patched my own copy (Horde 2.0, Imp 3.0) I updated the 5 files
(horde:problem.php, imp:compose.php, imp:mailbox.php, imp:message.php,
imp:lib/Maintenance/Task/purge_trash.php)

Whether you add and use a new function in the Horde class (Horde::rfcDate)
or just add the strftime directly in the code like I have is up to you.

The diffs are below:

--------------------------------------------------
horde: problem.php
42c42
<          $headers['Received'] .= "\n\t" . strftime("%a, %e %b %Y %T %z");
---
>          $headers['Received'] .= "\n\t" . date('r');
45c45
<          $headers['Date'] = strftime("%a, %e %b %Y %T %z");
---
>          $headers['Date'] = date('r');

--------------------------------------------------
imp: compose.php
619c619
<          $headers['Resent-Date'] = strftime("%a, %e %b %Y %T %z");
---
>          $headers['Resent-Date'] = date('r');
694c694
<          $headers['Received'] .= "\n\t" . strftime("%a, %e %b %Y %T %z");
---
>          $headers['Received'] .= "\n\t" . date('r');
697c697
<          $headers['Date'] = strftime("%a, %e %b %Y %T %z");
---
>          $headers['Date'] = date('r');

338c338
<      $headers['Date'] = strftime("%a, %e %b %Y %T %z");
---
>      $headers['Date'] = date('r');
310c310
<          $query .= ' ON "' . strftime("%a, %e %b %Y %T %z", mktime(0, 0,
0, $HTTP_POST_VARS['search_on_month'], $HTTP_POST_VARS['search_on_day'],
$HTTP_POST_VARS['search_on_year'])) . '"';
---
>          $query .= ' ON "' . date('r', mktime(0, 0, 0,
$HTTP_POST_VARS['search_on_month'], $HTTP_POST_VARS['search_on_day'],
$HTTP_POST_VARS['search_on_year'])) . '"';
317c317
<          $query .= ' BEFORE "' . strftime("%a, %e %b %Y %T %z", mktime(0,
0, 0, $HTTP_POST_VARS['search_before_month'],
$HTTP_POST_VARS['search_before_day'],
$HTTP_POST_VARS['search_before_year'])) . '"';
---
>          $query .= ' BEFORE "' . date('r', mktime(0, 0, 0,
$HTTP_POST_VARS['search_before_month'],
$HTTP_POST_VARS['search_before_day'],
$HTTP_POST_VARS['search_before_year'])) . '"';
324c324
<          $query .= ' SINCE "' . strftime("%a, %e %b %Y %T %z", mktime(0,
0, 0, $HTTP_POST_VARS['search_since_month'],
$HTTP_POST_VARS['search_since_day'], $HTTP_POST_VARS['search_since_year']))
. '"';
---
>          $query .= ' SINCE "' . date('r', mktime(0, 0, 0,
$HTTP_POST_VARS['search_since_month'], $HTTP_POST_VARS['search_since_day'],
$HTTP_POST_VARS['search_since_year'])) . '"';

--------------------------------------------------
imp: message.php

338c338
<      $headers['Date'] = strftime("%a, %e %b %Y %T %z");
---
>      $headers['Date'] = date('r');

--------------------------------------------------
imp: lib/Maintenance/Task/purge_trash.php

40c40
<                 $del_time = strftime("%a, %e %b %Y %T %z", time() -
($prefs->getValue('purge_trash_keep') * 86400));
---
>                 $del_time = date("r", time() -
($prefs->getValue('purge_trash_keep') * 86400));



Regards,

Warwick Smith
Electronic Services Officer / Webmaster
Email: warwick@imvs.sa.gov.au
Web:   http://www.imvs.sa.gov.au
Tel:   +61 8 82223832
Fax:   +61 8 82223147

* If it's never finished, you can't prove it doesn't work. *




>From chuck@horde.org Date: Thu,  7 Feb 2002 22:27:43 -0500
Return-Path: <chuck@horde.org>
Mailing-List: contact imp-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list imp@lists.horde.org
Received: (qmail 87878 invoked from network); 8 Feb 2002 03:28:20 -0000
Received: from h00104bc60b3c.ne.mediaone.net (HELO marina.horde.org) (24.91.196.127)
  by clark.horde.org with SMTP; 8 Feb 2002 03:28:20 -0000
Received: by marina.horde.org (Postfix, from userid 33)
	id 33A3939FF; Thu,  7 Feb 2002 22:27:43 -0500 (EST)
Received: from 192.168.0.130 ( [192.168.0.130])
	as user chuck@localhost by marina.horde.org with HTTP;
	Thu,  7 Feb 2002 22:27:43 -0500
Message-ID: <1013138863.3c6345af09633@marina.horde.org>
Date: Thu,  7 Feb 2002 22:27:43 -0500
From: Chuck Hagenbuch <chuck@horde.org>
To: imp@lists.horde.org
References: <018201c1afcb$358dec80$e200a8c0@ibmhule> <1013082281.3c6268a95f52f@jan.dip.ammma.net> <3C62A9F0.7060808@sunnmore.net> <1013116354.3c62edc2f183a@linux.wg.de> <3C63144C.4090005@sunnmore.net>
In-Reply-To: <3C63144C.4090005@sunnmore.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 4.0-cvs
Subject: Re: SV: [imp] norwegian doesn't work from login or prefs, only options. Other languages work...

Quoting Roy-Magne Mo <rmo@sunnmore.net>:

> I'm sure, no_NO has been used, and is what you'll find on your system if 
> is glibc 2.2.4 and older. But for IMP, that has no connection to the 
> locales on the system, it should honour the standard.

Hmm. Gettext can get cranky when the locale doesn't actually exist, though I 
think that depends on the gettext implementation.

-chuck

--
Charles Hagenbuch, <chuck@horde.org>
"What was and what may be, lie, like children whose faces we cannot see, in the
arms of silence. All we ever have is here, now." - Ursula K. Le Guin


>From liamr@umich.edu Date: Thu,  7 Feb 2002 22:29:40 -0500
Return-Path: <liamr@umich.edu>
Mailing-List: contact imp-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list imp@lists.horde.org
Received: (qmail 88800 invoked from network); 8 Feb 2002 03:29:42 -0000
Received: from harumscarum.mr.itd.umich.edu (141.211.125.17)
  by clark.horde.org with SMTP; 8 Feb 2002 03:29:42 -0000
Received: from manx.web.itd.umich.edu (manx.web.itd.umich.edu [141.213.234.63])
	by harumscarum.mr.itd.umich.edu (8.9.3/3.3s) with ESMTP id WAA08442
	for <imp@lists.horde.org>; Thu, 7 Feb 2002 22:29:40 -0500 (EST)
From: liamr@umich.edu
Received: (from www@localhost)
	by manx.web.itd.umich.edu (8.10.2+Sun/8.10.2) id g183TeA26681
	for imp@lists.horde.org; Thu, 7 Feb 2002 22:29:40 -0500 (EST)
X-Authentication-Warning: manx.web.itd.umich.edu: www set sender to liamr@umich.edu using -f
Received: from 68.40.66.44 ( [68.40.66.44])
	as user liamr@l.imap.itd.umich.edu by manx.web.itd.umich.edu with HTTP;
	Thu,  7 Feb 2002 22:29:40 -0500
Message-ID: <1013138980.3c63462414b65@manx.web.itd.umich.edu>
Date: Thu,  7 Feb 2002 22:29:40 -0500
To: imp@lists.horde.org
References: <1013123952.3c630b709a70a@pneumatictube.mail.umich.edu> <1013125192.3c63104883a6b@linux.wg.de>
In-Reply-To: <1013125192.3c63104883a6b@linux.wg.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 3.0
X-Originating-IP: 68.40.66.44
Subject: Re: [imp] Re: unqualified addresses get sent to localhost w/ Redirect

> > ok.. further poking around, and i've got a partial fix..
> 
> Try what I just commited.

I don't currently have a CVS install of Horde/IMP sitting around.  I tried 
making the change...

    $recipients = $f_to = format_addresses($f_to); 

in the version of compose.php from the release (2.369.2.11), but it didn't 
work... probably due to the vastly different version number (CVS currently 
being at 2.407) and all things that have changed since the release.

I'll set up a new CVS install tomorrow and see if your change works.

Any word on when 3.1 might be released?

Liam