[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-547-ge4d6fd5

Jesse Vincent jesse at bestpractical.com
Tue Aug 24 19:39:12 EDT 2010


The branch, 3.9-trunk has been updated
       via  e4d6fd51d73a1a403bafc419a721895e03863813 (commit)
       via  aaf6fcdd70d3a26ccdd5576f6d06a648c12e97ef (commit)
       via  0eb7cc2310c96b7356db131cc9b0118a724cdd88 (commit)
       via  e4578d7f45611bcc40571bc55a591f2f859b9851 (commit)
      from  20fc3eb766d6fc162b97ac0a8f9da41c023930e8 (commit)

Summary of changes:
 lib/RT/CustomField_Overlay.pm |   49 ++++++++++-------
 lib/RT/Tickets_Overlay.pm     |  122 +++++++++--------------------------------
 2 files changed, 56 insertions(+), 115 deletions(-)

- Log -----------------------------------------------------------------
commit e4578d7f45611bcc40571bc55a591f2f859b9851
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Aug 24 19:33:52 2010 -0400

    Extract type-specific canonicalizers  in CustomField.pm so they're more
    extensible.

diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index e87512a..2f8bce7 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -1281,28 +1281,13 @@ sub AddValueForObject {
             $extra_values--;
         }
     }
-    # For date, we need to store Content as ISO date
-    if ( $self->Type eq 'DateTime' ) {
-        my $DateObj = RT::Date->new( $self->CurrentUser );
-        $DateObj->Set(
-            Format => 'unknown',
-            Value  => $args{'Content'},
-        );
-        $args{'Content'} = $DateObj->ISO;
-    }
-    elsif ( $self->Type eq 'Date' ) {
 
-        # in case user input date with time, let's omit it by setting timezone
-        # to utc so "hour" won't affect "day"
-        my $DateObj = RT::Date->new( $self->CurrentUser );
-        $DateObj->Set(
-            Format   => 'unknown',
-            Value    => $args{'Content'},
-            Timezone => 'UTC',
-        );
-        $args{'Content'} = $DateObj->Date( Timezone => 'UTC' );
+    if (my $canonicalizer = $self->can('_CanonicalizeValue'.$self->Type)) {
+         $canonicalizer->($self, \%args);
     }
 
+
+
     my $newval = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
     my $val    = $newval->Create(
         ObjectType   => ref($obj),
@@ -1325,6 +1310,30 @@ sub AddValueForObject {
 
 # }}}
 
+
+sub _CanonicalizeValueDateTime {
+    my $self    = shift;
+    my $args    = shift;
+    my $DateObj = RT::Date->new( $self->CurrentUser );
+    $DateObj->Set( Format => 'unknown',
+                   Value  => $args->{'Content'} );
+    $args->{'Content'} = $DateObj->ISO;
+}
+
+# For date, we need to store Content as ISO date
+sub _CanonicalizeValueDate {
+    my $self = shift;
+    my $args = shift;
+
+    # in case user input date with time, let's omit it by setting timezone
+    # to utc so "hour" won't affect "day"
+    my $DateObj = RT::Date->new( $self->CurrentUser );
+    $DateObj->Set( Format   => 'unknown',
+                   Value    => $args->{'Content'},
+                   Timezone => 'UTC',
+                 );
+    $args->{'Content'} = $DateObj->Date( Timezone => 'UTC' );
+}
 # {{{ MatchPattern
 
 =head2 MatchPattern STRING

commit 0eb7cc2310c96b7356db131cc9b0118a724cdd88
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Aug 24 19:34:44 2010 -0400

    replace an unless with an if for readability

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index d40579b..0a5fc4d 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -1475,7 +1475,7 @@ sub _CustomFieldLimit {
                 }
             }
             elsif ( $op eq '=' || $op eq '!=' || $op eq '<>' ) {
-                unless ( length( Encode::encode_utf8($value) ) > 255 ) {
+                if ( length( Encode::encode_utf8($value) ) < 256 ) {
                     $self->_SQLLimit(
                         ALIAS    => $TicketCFs,
                         FIELD    => 'Content',

commit aaf6fcdd70d3a26ccdd5576f6d06a648c12e97ef
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Aug 24 19:38:49 2010 -0400

    FreezeLimits and ThawLimits were something that we haven't used since RT
    3.0 or so. They're now gone.

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index 0a5fc4d..6f211a9 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -1849,60 +1849,6 @@ sub Limit {
 
 # }}}
 
-=head2 FreezeLimits
-
-Returns a frozen string suitable for handing back to ThawLimits.
-
-=cut
-
-sub _FreezeThawKeys {
-    'TicketRestrictions', 'restriction_index', 'looking_at_effective_id',
-        'looking_at_type';
-}
-
-# {{{ sub FreezeLimits
-
-sub FreezeLimits {
-    my $self = shift;
-    require Storable;
-    require MIME::Base64;
-    MIME::Base64::base64_encode(
-        Storable::freeze( \@{$self}{ $self->_FreezeThawKeys } ) );
-}
-
-# }}}
-
-=head2 ThawLimits
-
-Take a frozen Limits string generated by FreezeLimits and make this tickets
-object have that set of limits.
-
-=cut
-
-# {{{ sub ThawLimits
-
-sub ThawLimits {
-    my $self = shift;
-    my $in   = shift;
-
-    #if we don't have $in, get outta here.
-    return undef unless ($in);
-
-    $self->{'RecalcTicketLimits'} = 1;
-
-    require Storable;
-    require MIME::Base64;
-
-    #We don't need to die if the thaw fails.
-    @{$self}{ $self->_FreezeThawKeys }
-        = eval { @{ Storable::thaw( MIME::Base64::base64_decode($in) ) }; };
-
-    $RT::Logger->error($@) if $@;
-
-}
-
-# }}}
-
 # {{{ Limit by enum or foreign key
 
 # {{{ sub LimitQueue

commit e4d6fd51d73a1a403bafc419a721895e03863813
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Aug 24 19:40:25 2010 -0400

    slightly untangle the date restriction code in custom field search

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index 6f211a9..c0abf44 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -1428,51 +1428,37 @@ sub _CustomFieldLimit {
             $cf->Load($field);
 
             # need special treatment for Date
-            if ( $cf->Type =~ /^Date(Time)?$/ ) {
-                my $is_datetime = $1 ? 1 : 0;
-                if ( $is_datetime && $op eq '=' ) {
+            if ( $cf->Type eq 'DateTime' && $op eq '=' ) {
 
-               # if we're specifying =, that means we want everything on a
-               # particular single day.  in the database, we need to check for >
-               # and < the edges of that day.
+                # if we're specifying =, that means we want everything on a
+                # particular day.  in the database, we need to check for >
+                # and < the edges of that day.
 
-                    my $date = RT::Date->new( $self->CurrentUser );
-                    $date->Set( Format => 'unknown', Value => $value );
-                    $date->SetToMidnight( Timezone => 'server' );
-                    my $daystart = $date->ISO;
-                    $date->AddDay;
-                    my $dayend = $date->ISO;
+                my $date = RT::Date->new( $self->CurrentUser );
+                $date->Set( Format => 'unknown', Value => $value );
+                $date->SetToMidnight( Timezone => 'server' );
+                my $daystart = $date->ISO;
+                $date->AddDay;
+                my $dayend = $date->ISO;
 
-                    $self->_OpenParen;
-
-                    $self->_SQLLimit(
-                        ALIAS    => $TicketCFs,
-                        FIELD    => 'Content',
-                        OPERATOR => ">=",
-                        VALUE    => $daystart,
-                        %rest,
-                    );
+                $self->_OpenParen;
 
-                    $self->_SQLLimit(
-                        ALIAS    => $TicketCFs,
-                        FIELD    => 'Content',
-                        OPERATOR => "<=",
-                        VALUE    => $dayend,
-                        %rest,
-                        ENTRYAGGREGATOR => 'AND',
-                    );
+                $self->_SQLLimit( ALIAS    => $TicketCFs,
+                                  FIELD    => 'Content',
+                                  OPERATOR => ">=",
+                                  VALUE    => $daystart,
+                                  %rest,
+                                );
+
+                $self->_SQLLimit( ALIAS    => $TicketCFs,
+                                  FIELD    => 'Content',
+                                  OPERATOR => "<=",
+                                  VALUE    => $dayend,
+                                  %rest,
+                                  ENTRYAGGREGATOR => 'AND',
+                                );
 
-                    $self->_CloseParen;
-                }
-                else {
-                    $self->_SQLLimit(
-                        ALIAS    => $TicketCFs,
-                        FIELD    => 'Content',
-                        OPERATOR => $op,
-                        VALUE    => $value,
-                        %rest,
-                    );
-                }
+                $self->_CloseParen;
             }
             elsif ( $op eq '=' || $op eq '!=' || $op eq '<>' ) {
                 if ( length( Encode::encode_utf8($value) ) < 256 ) {

-----------------------------------------------------------------------


More information about the Rt-commit mailing list