[Rt-commit] r11773 - rtir/branches/2.3-EXPERIMENTAL/lib/RT
ruz at bestpractical.com
ruz at bestpractical.com
Thu Apr 17 20:04:35 EDT 2008
Author: ruz
Date: Thu Apr 17 20:04:29 2008
New Revision: 11773
Modified:
rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
Log:
* add HasNoQueueCache as we don't cache attempts to load record
that doesn't exist
Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm (original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm Thu Apr 17 20:04:29 2008
@@ -367,6 +367,7 @@
# flush constituency cache on each request
wrap 'RT::Interface::Web::Handler::CleanupRequest', pre => sub {
%RT::IR::ConstituencyCache = ();
+ %RT::IR::HasNoQueueCache = ();
};
require RT::Record;
@@ -390,21 +391,26 @@
return;
}
if ( UNIVERSAL::isa( $self, 'RT::Ticket' ) ) {
- if (not defined $RT::IR::ConstituencyCache{ $self->id }) {
+ my $const = $RT::IR::ConstituencyCache{ $self->id };
+ unless ( $const ) {
my $systicket = RT::Ticket->new($RT::SystemUser);
$systicket->Load( $self->id );
- $RT::IR::ConstituencyCache{ $self->id } =
+ $const = $RT::IR::ConstituencyCache{ $self->id } =
$systicket->FirstCustomFieldValue('_RTIR_Constituency')
|| '_none';
}
- return if ( $RT::IR::ConstituencyCache{ $self->id } eq '_none' );
- if ( not $self->{_constituency_queue} ) {
- my $new_queue = RT::Queue->new( $RT::SystemUser);
- $new_queue->LoadByCols( Name => $queue->Name . " - " . $RT::IR::ConstituencyCache{ $self->id } );
- return unless ( $new_queue->id );
- $self->{_constituency_queue} = $new_queue;
+ return if $const eq '_none';
+ return if $RT::IR::HasNoQueueCache{ $const };
+
+ my $new_queue = RT::Queue->new($RT::SystemUser);
+ $new_queue->LoadByCols(
+ Name => $queue->Name . " - " . $const
+ );
+ unless ( $new_queue->id ) {
+ $RT::IR::HasNoQueueCache{$const} = 1;
+ return;
}
- $_[-1] = [$queue, $self->{_constituency_queue}];
+ $_[-1] = [$queue, $new_queue];
} else {
use YAML;
$RT::Logger->crit( "$self is not a ticket object like I expected"
@@ -465,9 +471,10 @@
unless ($const) {
my $ticket = RT::Ticket->new($RT::SystemUser);
$ticket->Load($id);
- $const = $RT::IR::ConstituencyCache{$ticket->id} = $ticket->FirstCustomFieldValue('_RTIR_Constituency') || '_none';
+ $const = $RT::IR::ConstituencyCache{$ticket->id}
+ = $ticket->FirstCustomFieldValue('_RTIR_Constituency') || '_none';
}
- if ($const) {
+ if ($const ne '_none' && !$RT::IR::HasNoQueueCache{$const} ) {
my $new_queue = RT::Queue->new($RT::SystemUser);
$new_queue->LoadByCols(
Name => $queue->Name . " - " . $const );
@@ -475,6 +482,8 @@
my $val = $new_queue->_Value($attr) || $queue->_Value($attr);
$RT::Logger->debug("Overriden $attr is $val for ticket #$id according to constituency $const");
return $val;
+ } else {
+ $RT::IR::HasNoQueueCache{$const} = 1;
}
}
}
More information about the Rt-commit
mailing list