RT 4.2.11, ticket#13852
[freeside.git] / rt / etc / upgrade / 4.1.6 / content
diff --git a/rt/etc/upgrade/4.1.6/content b/rt/etc/upgrade/4.1.6/content
new file mode 100644 (file)
index 0000000..d27014c
--- /dev/null
@@ -0,0 +1,43 @@
+use strict;
+use warnings;
+
+our @Initial = (sub {
+    my $users = RT::Users->new(RT->SystemUser);
+    $users->FindAllRows;
+
+    my $attributes = $users->Join(
+        ALIAS1  => "main",
+        FIELD1  => "id",
+        TABLE2  => RT::Attributes->Table,
+        FIELD2  => "ObjectId",
+    );
+    $users->Limit(
+        ALIAS   => $attributes,
+        FIELD   => "ObjectType",
+        VALUE   => "RT::User",
+    );
+    $users->Limit(
+        ALIAS   => $attributes,
+        FIELD   => "Name",
+        VALUE   => RT::User::_PrefName( RT->System ),
+    );
+
+    # Iterate all users (including disabled), with config preferences set.
+    # Avoids running a query for every user in the system by only selecting
+    # those known to have preferences.
+    while (my $user = $users->Next) {
+        RT->Logger->debug(sprintf "User #%d has config preferences", $user->id);
+
+        my $config = $user->Preferences( RT->System )
+            or next;
+        next unless exists $config->{DeferTransactionLoading};
+
+        $config->{ShowHistory} = delete $config->{DeferTransactionLoading}
+            ? "click" : "delay";
+
+        $user->SetPreferences( RT->System, $config );
+        RT->Logger->debug(sprintf "Updated config Preferences for user %s (#%d)", $user->Name, $user->id);
+    }
+});
+
+1;