[otrs-cvs] otrs/Kernel/System XML.pm,1.51,1.52
cvs-log at otrs.org
cvs-log at otrs.org
Fri Apr 13 07:05:39 GMT 2007
Comments:
Update of /home/cvs/otrs/Kernel/System
In directory lancelot:/tmp/cvs-serv25410/Kernel/System
Modified Files:
XML.pm
Log Message:
Removed the cache file writing from XMLHashAdd and XMLHashUpdate
Author: tr
Index: XML.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/XML.pm,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** XML.pm 7 Apr 2007 09:24:58 -0000 1.51
--- XML.pm 13 Apr 2007 07:05:34 -0000 1.52
***************
*** 132,148 ****
}
}
! # write cache file
! my $FileCache = quotemeta("$Param{Type}-$Param{Key}");
! $FileCache = $Self->{CacheDirectory}."xml-storage-$FileCache.cache";
! my $Dump = Data::Dumper::Dumper($Param{XMLHash});
! $Dump =~ s/\$VAR1/\$XMLHashRef/;
! if (open (OUT, "> $FileCache")) {
! binmode(OUT);
! print OUT $Dump."\n1;";
! close (OUT);
! }
! else {
! $Self->{LogObject}->Log(Priority => 'error', Message => "Can't write cache file $FileCache: $!");
! }
# db quote
my $Key = $Param{Key};
--- 132,140 ----
}
}
!
! # delete cache file
! my $FileCache = $Self->_CacheFileLocation("$Param{Type}-$Param{Key}");
! $Self->_CacheFileDelete($FileCache);
!
# db quote
my $Key = $Param{Key};
***************
*** 234,250 ****
my %ValueHASH = $Self->XMLHash2D(XMLHash => $Param{XMLHash});
if (%ValueHASH) {
! # write cache file
! my $FileCache = quotemeta("$Param{Type}-$Param{Key}");
! $FileCache = $Self->{CacheDirectory}."xml-storage-$FileCache.cache";
! my $Dump = Data::Dumper::Dumper($Param{XMLHash});
! $Dump =~ s/\$VAR1/\$XMLHashRef/;
! if (open (OUT, "> $FileCache")) {
! binmode(OUT);
! print OUT $Dump."\n1;";
! close (OUT);
! }
! else {
! $Self->{LogObject}->Log(Priority => 'error', Message => "Can't write cache file $FileCache: $!");
! }
# db quote
foreach (keys %Param) {
--- 226,231 ----
my %ValueHASH = $Self->XMLHash2D(XMLHash => $Param{XMLHash});
if (%ValueHASH) {
! my $FileCache = $Self->_CacheFileLocation("$Param{Type}-$Param{Key}");
! $Self->_CacheFileDelete($FileCache);
# db quote
foreach (keys %Param) {
***************
*** 302,325 ****
}
# read cache file
! my $FileCache = quotemeta("$Param{Type}-$Param{Key}");
! $FileCache = $Self->{CacheDirectory}."xml-storage-$FileCache.cache";
if (-e $FileCache && $Param{Cache}) {
! if (open (IN, "< $FileCache")) {
! my $XMLHashRef;
! my $Content = '';
! while (<IN>) {
! $Content .= $_;
! }
! close (IN);
! if ($Content && !eval $Content) {
! print STDERR "ERROR: $FileCache: $@\n";
! }
! @XMLHash = @{$XMLHashRef};
return @XMLHash;
}
- else {
- $Self->{LogObject}->Log(Priority => 'error', Message => "Can't read cache file $FileCache: $!");
- return;
- }
}
# db quote
--- 283,292 ----
}
# read cache file
! my $FileCache = $Self->_CacheFileLocation("$Param{Type}-$Param{Key}");
if (-e $FileCache && $Param{Cache}) {
! @XMLHash = @{$Self->_CacheFileRead($FileCache)};
! if (@XMLHash) {
return @XMLHash;
}
}
# db quote
***************
*** 351,364 ****
# write cache file
if (!-e $FileCache && $Param{Cache} && $Content) {
! my $Dump = Data::Dumper::Dumper(\@XMLHash);
! $Dump =~ s/\$VAR1/\$XMLHashRef/;
! if (open (OUT, "> $FileCache")) {
! binmode(OUT);
! print OUT $Dump."\n1;";
! close (OUT);
! }
! else {
! $Self->{LogObject}->Log(Priority => 'error', Message => "Can't write cache file $FileCache: $!");
! }
}
return @XMLHash;
--- 318,322 ----
# write cache file
if (!-e $FileCache && $Param{Cache} && $Content) {
! $Self->_CacheFileAdd($FileCache, \@XMLHash);
}
return @XMLHash;
***************
*** 387,397 ****
}
# remove cache file
! my $FileCache = quotemeta("$Param{Type}-$Param{Key}");
! $FileCache = $Self->{CacheDirectory}."xml-storage-$FileCache.cache";
! if (-e $FileCache) {
! if (!unlink $FileCache) {
! $Self->{LogObject}->Log(Priority => 'error', Message => "Can't remove $FileCache: $!");
! }
! }
# db quote
foreach (keys %Param) {
--- 345,351 ----
}
# remove cache file
! my $FileCache = $Self->_CacheFileLocation("$Param{Type}-$Param{Key}");
! $Self->_CacheFileDelete($FileCache);
!
# db quote
foreach (keys %Param) {
***************
*** 427,434 ****
}
# rename cache file
! my $FileCacheOld = quotemeta("$Param{OldType}-$Param{OldKey}");
! my $FileCacheNew = quotemeta("$Param{NewType}-$Param{NewKey}");
! $FileCacheOld = $Self->{CacheDirectory}."xml-storage-$FileCacheOld.cache";
! $FileCacheNew = $Self->{CacheDirectory}."xml-storage-$FileCacheNew.cache";
if (-e $FileCacheOld) {
if (!rename($FileCacheOld, $FileCacheNew)) {
--- 381,387 ----
}
# rename cache file
! my $FileCacheOld = $Self->_CacheFileLocation("$Param{OldType}-$Param{OldKey}");
! my $FileCacheNew = $Self->_CacheFileLocation("$Param{NewType}-$Param{NewKey}");
!
if (-e $FileCacheOld) {
if (!rename($FileCacheOld, $FileCacheNew)) {
***************
*** 1198,1201 ****
--- 1151,1214 ----
}
+ sub _CacheFileDelete {
+ my $Self = shift;
+ my $FileCache = shift;
+
+ if (-e $FileCache) {
+ if (!unlink $FileCache) {
+ $Self->{LogObject}->Log(Priority => 'error', Message => "Can't remove $FileCache: $!");
+ }
+ }
+ return 1;
+ }
+
+ sub _CacheFileAdd {
+ my $Self = shift;
+ my $FileCache = shift;
+ my $XMLHash = shift;
+
+ # write cache file
+ my $Dump = Data::Dumper::Dumper($XMLHash);
+ $Dump =~ s/\$VAR1/\$XMLHashRef/;
+ if (open (OUT, "> $FileCache")) {
+ binmode(OUT);
+ print OUT $Dump."\n1;";
+ close (OUT);
+ }
+ else {
+ $Self->{LogObject}->Log(Priority => 'error', Message => "Can't write cache file $FileCache: $!");
+ }
+ }
+
+ sub _CacheFileRead {
+ my $Self = shift;
+ my $FileCache = shift;
+ if (open (IN, "< $FileCache")) {
+ my $XMLHashRef;
+ my $Content = '';
+ while (<IN>) {
+ $Content .= $_;
+ }
+ close (IN);
+ if ($Content && !eval $Content) {
+ print STDERR "ERROR: $FileCache: $@\n";
+ }
+
+ return $XMLHashRef;
+ }
+ else {
+ $Self->{LogObject}->Log(Priority => 'error', Message => "Can't read cache file $FileCache: $!");
+ return;
+ }
+ }
+
+ sub _CacheFileLocation {
+ my $Self = shift;
+ my $FileCache = shift;
+ $FileCache = quotemeta($FileCache);
+ $FileCache = $Self->{CacheDirectory}."xml-storage-$FileCache.cache";
+ return $FileCache;
+ }
+
1;
More information about the cvs-log
mailing list