[otrs-cvs] otrs/Kernel/System Ticket.pm,1.549.2.13,1.549.2.14
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/otrs/Kernel/System
In directory lancelot:/tmp/cvs-serv23466/Kernel/System
Modified Files:
Tag: rel-3_1
Ticket.pm
Log Message:
- 2013-01-14 Fixed bug#9047 - HistoryTicketGet caches info on disk directly.
Author: mg
Index: Ticket.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/Ticket.pm,v
retrieving revision 1.549.2.13
retrieving revision 1.549.2.14
diff -2 -u -d -r1.549.2.13 -r1.549.2.14
--- Ticket.pm 25 Nov 2012 19:49:48 -0000 1.549.2.13
+++ Ticket.pm 14 Jan 2013 12:18:43 -0000 1.549.2.14
@@ -1,5 +1,5 @@
# --
# Kernel/System/Ticket.pm - all ticket functions
-# Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
+# Copyright (C) 2001-2013 OTRS AG, http://otrs.org/
# --
# $Id$
@@ -4859,5 +4859,6 @@
=item HistoryTicketGet()
-returns a hash of the ticket history info at this time.
+returns a hash of some of the ticket data
+calculated based on ticket history info at the given date.
my %HistoryData = $TicketObject->HistoryTicketGet(
@@ -4866,5 +4867,5 @@
StopDay => 24,
TicketID => 123,
- Force => 0,
+ Force => 0, # 1: don't use cache
);
@@ -4915,42 +4916,29 @@
}
- # check cache
- my $Path = $Self->{ConfigObject}->Get('Home')
- . "/var/tmp/TicketHistoryCache/$Param{StopYear}/$Param{StopMonth}/";
- my $File = $Self->{MainObject}->FilenameCleanUp(
- Filename =>
- "TicketHistoryCache-$Param{TicketID}-$Param{StopYear}-$Param{StopMonth}-$Param{StopDay}.cache",
- Type => 'local',
- );
+ my $CacheKey = 'Cache::HistoryTicketGet';
+ for my $ParamName ( sort keys %Param ) {
+ $CacheKey .= '::' . $Param{$ParamName};
+ }
- # write cache
- my %Ticket;
- if ( !$Param{Force} && -f "$Path/$File" ) {
- my $ContentARRAYRef = $Self->{MainObject}->FileRead(
- Directory => $Path,
- Filename => $File,
- Result => 'ARRAY', # optional - SCALAR|ARRAY
- );
- if ($ContentARRAYRef) {
- for my $Line ( @{$ContentARRAYRef} ) {
- if ( $Line =~ /^(.+?):(.+?)$/ ) {
- $Ticket{$1} = $2;
- }
- }
- return %Ticket;
- }
+ my $Cached = $Self->{CacheInternalObject}->Get( Key => $CacheKey );
+ if ( ref $Cached eq 'HASH' && !$Param{Force} ) {
+ return %{$Cached};
}
- # db access
my $Time = "$Param{StopYear}-$Param{StopMonth}-$Param{StopDay} 23:59:59";
return if !$Self->{DBObject}->Prepare(
- SQL => 'SELECT th.name, tht.name, th.create_time, th.create_by, th.ticket_id, '
- . 'th.article_id, th.queue_id, th.state_id, th.priority_id, th.owner_id, th.type_id '
- . ' FROM ticket_history th, ticket_history_type tht WHERE '
- . 'th.history_type_id = tht.id AND th.ticket_id = ? AND th.create_time <= ? '
- . 'ORDER BY th.create_time, th.id ASC',
+ SQL => '
+ SELECT th.name, tht.name, th.create_time, th.create_by, th.ticket_id,
+ th.article_id, th.queue_id, th.state_id, th.priority_id, th.owner_id, th.type_id
+ FROM ticket_history th, ticket_history_type tht
+ WHERE th.history_type_id = tht.id
+ AND th.ticket_id = ?
+ AND th.create_time <= ?
+ ORDER BY th.create_time, th.id ASC',
Bind => [ \$Param{TicketID}, \$Time ],
Limit => 3000,
);
+
+ my %Ticket;
while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
@@ -5039,5 +5027,5 @@
if ( $FieldName =~ /^Ticket(Free(?:Text|Key)(?:[?:1[0-6]|[1-9]))$/ ) {
- # Remove the leading Tiket on field name
+ # Remove the leading Ticket on field name
my $FreeFieldName = $1;
$Ticket{$FreeFieldName} = $Value;
@@ -5104,25 +5092,8 @@
# if the request is for the last month or older, cache it
- if ( $Year <= $Param{StopYear} && $Month > $Param{StopMonth} ) {
-
- # create sub directory if needed
- if ( !-e $Path && !File::Path::mkpath( [$Path], 0, 0775 ) ) {
- $Self->{LogObject}->Log(
- Priority => 'error',
- Message => "Can't create directory: $Path: $!",
- );
- }
-
- # write cache file
- my $Content = '';
- for my $Key ( keys %Ticket ) {
- $Content .= "$Key:$Ticket{$Key}\n";
- }
- $Self->{MainObject}->FileWrite(
- Directory => $Path,
- Filename => $File,
- Content => \$Content,
- );
+ if ( "$Year-$Month" gt "$Param{StopYear}-$Param{StopMonth}" ) {
+ $Self->{CacheInternalObject}->Set( Key => $CacheKey, Value => \%Ticket );
}
+
return %Ticket;
}
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log