X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fsbin%2Frt-dump-database;h=ce023adabcd1ebd19ab0dea1d528051a43be2444;hb=6662dd7c5260d74d92df0437d1eeebcb2baa6fe4;hp=647781d8d9cbea27df0bfba4c9c79545f938bc58;hpb=40a7b3dc653e099f7bd0bd762b649b04c4432db2;p=freeside.git diff --git a/rt/sbin/rt-dump-database b/rt/sbin/rt-dump-database index 647781d8d..ce023adab 100755 --- a/rt/sbin/rt-dump-database +++ b/rt/sbin/rt-dump-database @@ -2,8 +2,8 @@ # BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: -# -# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +# +# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -48,8 +48,34 @@ # END BPS TAGGED BLOCK }}} use strict; -use lib "/opt/rt3/local/lib"; -use lib "/opt/rt3/lib"; +# As we specify that XML is UTF-8 and we output it to STDOUT, we must be sure +# it is UTF-8 so further XMLin will not break +binmode(STDOUT, ":utf8"); + +# fix lib paths, some may be relative +BEGIN { + require File::Spec; + my @libs = ("lib", "local/lib"); + my $bin_path; + + for my $lib (@libs) { + unless ( File::Spec->file_name_is_absolute($lib) ) { + unless ($bin_path) { + if ( File::Spec->file_name_is_absolute(__FILE__) ) { + $bin_path = ( File::Spec->splitpath(__FILE__) )[1]; + } + else { + require FindBin; + no warnings "once"; + $bin_path = $FindBin::Bin; + } + } + $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib ); + } + unshift @INC, $lib; + } + +} use RT; use XML::Simple; @@ -117,7 +143,7 @@ foreach my $class (@classes) { # next if $obj-> # skip default names foreach my $field (sort keys %fields) { my $value = $obj->__Value($field); - $rv->{$field} = $value if length($value); + $rv->{$field} = $value if ( defined ($value) && length($value) ); } delete $rv->{Disabled} unless $rv->{Disabled};