[Rt-commit] rt branch, 4.2/deprecated-config-options, created. rt-4.1.6-379-g0218e17

Alex Vandiver alexmv at bestpractical.com
Wed Mar 20 14:31:28 EDT 2013


The branch, 4.2/deprecated-config-options has been created
        at  0218e1794d33e70bb3e56fe7069df904a27183fd (commit)

- Log -----------------------------------------------------------------
commit 1d6cd46e6042e0129053883078a9089e9d4aab4a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 18 22:12:53 2013 -0400

    Make stack traces optional in RT->Deprecated

diff --git a/lib/RT.pm b/lib/RT.pm
index d31e4fa..d079708 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -852,6 +852,7 @@ sub Deprecated {
         Remove => undef,
         Instead => undef,
         Message => undef,
+        Stack   => 1,
         @_,
     );
 
@@ -884,7 +885,7 @@ sub Deprecated {
     $msg .= "  You should use $args{Instead} instead."
         if $args{Instead};
 
-    $msg .= "  Call stack:\n$stack";
+    $msg .= "  Call stack:\n$stack" if $args{Stack};
     RT->Logger->warn($msg);
 }
 

commit 0218e1794d33e70bb3e56fe7069df904a27183fd
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 18 22:13:15 2013 -0400

    Provide a simple way to note that a config option has been deprecated

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 10fff8e..1ecd6e1 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -764,39 +764,15 @@ our %META = (
         },
     },
     LogToScreen => {
-        PostSet => sub {
-            my $self  = shift;
-            my $value = shift;
-            $self->SetFromConfig(
-                Option => \'LogToSTDERR',
-                Value  => [$value],
-                %{$self->Meta('LogToScreen')->{'Source'}}
-            );
-        },
-        PostLoadCheck => sub {
-            my $self = shift;
-            # XXX: deprecated, remove in 4.4
-            $RT::Logger->info("You set \$LogToScreen in your config, but it's been renamed to \$LogToSTDERR.  Please update your config.")
-                if $self->Meta('LogToScreen')->{'Source'}{'Package'};
+        Deprecated => {
+            Instead => 'LogToSTDERR',
+            Remove  => '4.4',
         },
     },
     UserAutocompleteFields => {
-        PostSet => sub {
-            my $self  = shift;
-            my $value = shift;
-            $self->SetFromConfig(
-                Option => \'UserSearchFields',
-                Value  => [$value],
-                %{$self->Meta('UserAutocompleteFields')->{'Source'}}
-            );
-        },
-        PostLoadCheck => sub {
-            my $self = shift;
-            RT->Deprecated(
-                Message => '$UserAutocompleteFields is deprecated',
-                Instead => '$UserSearchFields',
-                Remove => "4.4"
-            ) if $self->Meta('UserAutocompleteFields')->{'Source'}{'Package'};
+        Deprecated => {
+            Instead => 'UserSearchFields',
+            Remove  => '4.4',
         },
     },
     CustomFieldGroupings => {
@@ -1168,6 +1144,22 @@ sub Set {
     $META{$name}->{'Type'} = $type;
     $META{$name}->{'PostSet'}->($self, $OPTIONS{$name}, $old)
         if $META{$name}->{'PostSet'};
+    if ($META{$name}->{'Deprecated'}) {
+        my %deprecated = %{$META{$name}->{'Deprecated'}};
+        my $new_var = $deprecated{Instead} || '';
+        $self->SetFromConfig(
+            Option => \$new_var,
+            Value  => [$OPTIONS{$name}],
+            %{$self->Meta($name)->{'Source'}}
+        ) if $new_var;
+        $META{$name}->{'PostLoadCheck'} ||= sub {
+            RT->Deprecated(
+                Message => "Configuration option $name is deprecated",
+                Stack   => 0,
+                %deprecated,
+            );
+        };
+    }
     return $self->_ReturnValue( $old, $type );
 }
 

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


More information about the Rt-commit mailing list