[Rt-commit] [rtir] 01/01: Warn on old CF names in searches
Jim Brandt
jbrandt at bestpractical.com
Wed May 29 13:59:49 EDT 2013
This is an automated email from the git hooks/post-receive script.
jbrandt pushed a commit to branch 2.9/warn-on-old-search-formats
in repository rtir.
commit 6b48d7b9b05c5a4915256e12051dff9661025684
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed May 29 13:56:23 2013 -0400
Warn on old CF names in searches
Warn on startup and when searching if old CF names with
the _RTIR_ prefix or State are found in queries or formats.
---
html/RTIR/Search/Results.html | 5 +++++
lib/RT/IR/Config.pm | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/html/RTIR/Search/Results.html b/html/RTIR/Search/Results.html
index 22003a5..6ff105b 100644
--- a/html/RTIR/Search/Results.html
+++ b/html/RTIR/Search/Results.html
@@ -68,6 +68,11 @@ my $title = loc("Results");
my $Type = RT::IR::TicketType( Queue => $Queue ) || '';
$Format ||= RT->Config->Get('RTIRSearchResultFormats')->{ $Type . 'Default' };
+
+# Warn if old CFs are found
+RT::IR::Config::ValidateCFUpdates($Format);
+RT::IR::Config::ValidateCFUpdates($Query);
+
if ( $Type ) {
$BaseQuery ||= RT::IR->Query( Queue => $Queue );
$Query ||= RT::IR->ActiveQuery( Queue => $Queue );
diff --git a/lib/RT/IR/Config.pm b/lib/RT/IR/Config.pm
index f8be4d2..96b8578 100644
--- a/lib/RT/IR/Config.pm
+++ b/lib/RT/IR/Config.pm
@@ -18,6 +18,46 @@ sub Init {
},
);
%RT::Config::META = (%meta, %RT::Config::META);
+
+ my $format_ref = RT->Config->Get('RTIRSearchResultFormats');
+ foreach my $format ( keys %{$format_ref} ){
+ ValidateCFUpdates($format_ref->{$format});
+ }
+
+ return;
+}
+
+=head1 ValidateCFUpdates
+
+RTIR upgrades changed the naming of installed custom fields,
+removing the _RTIR_ prefix from the custom field names and removing
+State in favor of RT's default Status.
+
+This function checks queries and formats for references to the old
+CF names and warns that they need to be updated.
+
+=cut
+
+sub ValidateCFUpdates {
+ my $string = shift;
+ return unless $string;
+
+ if ( $string =~ /__CustomField\.\{State\}__/
+ or $string =~ /CF\.\{State\}/ ){
+
+ RT::Logger->warning('The custom field State has been replaced with the RT Status field.'
+ . ' You should update your custom searches and result formats accordingly.'
+ . ' See the UPGRADING file and the $RTIRSearchResultFormats option'
+ . ' in the default RTIR_Config.pm file. Found in: ' . $string);
+ }
+
+ if ( $string =~ /__CustomField\.\{_RTIR_(\w+)\}__/
+ or $string =~ /CF\.\{_RTIR_\w+\}/ ){
+
+ RT::Logger->warning('The _RTIR_ prefix has been removed from all RTIR custom fields.'
+ . ' You should update your custom searches and result formats accordingly.'
+ . ' See the UPGRADING file for details. Found in: ' . $string);
+ }
return;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Rt-commit
mailing list