[Jifty-commit] r5486 - in Jifty-DBI/trunk: lib/Jifty/DBI/Filter

Jifty commits jifty-commit at lists.jifty.org
Tue May 27 13:20:35 EDT 2008

Author: trs
Date: Tue May 27 13:20:34 2008
New Revision: 5486

   Jifty-DBI/trunk/   (props changed)

 r35216 at zot:  tom | 2008-05-27 13:19:57 -0400
 _formatter is *inheritable* class data.  If it happens to get set by the DateTime filter before getting set by one of its subclasses (the Date and Time filters), than it is stuck on the DateTime _formatter setting because the subclasses don't override it.  There are a couple solutions, the simplest being to check the value of _strptime and update/override _formatter if it is different, which is what I've done here.  (This may not be the most optimized solution.)

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm
--- Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Filter/DateTime.pm	Tue May 27 13:20:34 2008
@@ -41,7 +41,9 @@
 sub formatter {
     my $self = shift;
-    unless ($self->_formatter) {
+    if ( not $self->_formatter
+          or $self->_formatter->pattern ne $self->_strptime )
+    {
          $self->_formatter(DateTime::Format::Strptime->new(pattern => $self->_strptime));
     return $self->_formatter;

More information about the Jifty-commit mailing list