[Rt-commit] rt branch, 4.4/saved-search-upgrade-warning, updated. rt-4.4.1-111-g0f747bc

Shawn Moore shawn at bestpractical.com
Fri Jan 13 13:50:00 EST 2017


The branch, 4.4/saved-search-upgrade-warning has been updated
       via  0f747bc324d1ab1125148a1ada1aaea2330a4450 (commit)
      from  e35ad873cd0a7670e5f114dfe1fa9fb876c57c03 (commit)

Summary of changes:
 etc/upgrade/4.4.2/content | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 etc/upgrade/4.4.2/content

- Log -----------------------------------------------------------------
commit 0f747bc324d1ab1125148a1ada1aaea2330a4450
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Jan 13 18:45:45 2017 +0000

    Upgrade step to fix saved searches with no SearchType
    
    As e35ad873cd0a7670e5f114dfe1fa9fb876c57c03 mentions, old saved searches
    may lack a SearchType attribute.
    
    With this, we should be able to eliminate the
        ($search->{SearchType} || 'Ticket')
    defensive checks we needed to do.
    
    Fixes: I#16856

diff --git a/etc/upgrade/4.4.2/content b/etc/upgrade/4.4.2/content
new file mode 100644
index 0000000..360f134
--- /dev/null
+++ b/etc/upgrade/4.4.2/content
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+
+our @Initial = (
+    # fix searches without SearchType
+    sub {
+        my $attrs = RT::Attributes->new(RT->SystemUser);
+        $attrs->Limit( FIELD => 'Name', VALUE => 'SavedSearch' );
+        while ( my $attr = $attrs->Next ) {
+            my $content = $attr->Content;
+
+            next if $content->{SearchType};
+
+            $content->{SearchType} = 'Ticket';
+
+            my ($ret, $msg) = $attr->SetContent($content);
+            unless ( $ret ) {
+                RT->Logger->error("Failed to update content for SavedSearch #" . $attr->id . ": $msg");
+            }
+        }
+    },
+);
+

-----------------------------------------------------------------------


More information about the rt-commit mailing list