[Rt-devel] dumpfile-to-rt3.0 crashdump - Could not create a new user

John Tobin tobinjt at cs.tcd.ie
Fri Aug 4 07:34:29 EDT 2006


On Thu, Jul 27, 2006 at 12:25:52PM +0100, Andrew Nicols wrote:
> upgrade at rt-upgrade-2:~/rt2-to-rt3-1.23$ sudo ./dumpfile-to-rt-3.0 ../dbdump
> Importing users
> uCreating user Unnamed user 45
> .[Thu Jul 27 12:15:42 2006] [error]: Could not create a new user
> (/usr/local/rt3/lib/RT/User_Overlay.pm:217)
> Failed to create user for$VAR1 = {
>          'CryptedPassword' => undef,
>          'Name' => 'Unnamed user 45'
>        };
> uCreating user Unnamed user 40
> .[Thu Jul 27 12:15:42 2006] [crit]: RT::User::crit Unimplemented in
> RT::User. (/usr/local/rt3/lib/RT/User_Overlay.pm line 206)
> (/usr/local/rt3/lib/RT.pm:228)

Hi Andrew,

I the same problem upgrading from 2.0.15 to 3.2.3.  As far as I can tell
changes in some of the modules RT uses have broken rt-2.0-to-dumpfile.
I spent quite some time fixing it up, and I've got a dirty patch I can
share with you (see below).  I've been intending to clean it up (after
reading the RT book I think I could use ReadableAttributes() and
WritableAttributes()), but I haven't had the time.

This patch made rt-2.0-to-dumpfile work for me; if you have a
difficulties get back to me.

diff -aur rt2-to-rt3-1.23.orig/rt-2.0-to-dumpfile rt2-to-rt3-1.23/rt-2.0-to-dumpfile
--- rt2-to-rt3-1.23.orig/rt-2.0-to-dumpfile	2004-02-13 16:03:35.000000000 +0000
+++ rt2-to-rt3-1.23/rt-2.0-to-dumpfile	2006-03-28 15:05:49.096465200 +0100
@@ -79,6 +79,11 @@
     my $blank_Group = RT::Group->new($RT::SystemUser);
     $blank_Group->_Accessible( 'Foo', 'read' );
     my $acc = $blank_Group->{_AccessibleCache};
+    my %Cols = (
+        Name => 'read/write',
+        Description => 'read/write',
+        Pseudo => 'read'
+    );
 
     my $Groups = RT::Groups->new($RT::SystemUser);
     $Groups->LimitToReal();
@@ -87,7 +92,7 @@
 
         my $group;
 
-        foreach my $param ( sort keys %$acc, 'id' ) {
+        foreach my $param ( sort keys %$acc, keys %Cols, 'id' ) {
             $group->{$param} = $Group->_Value($param)
               if ( $Group->_Value($param) );
         }
@@ -106,12 +111,24 @@
     my $blank_KeywordSelect = RT::KeywordSelect->new($RT::SystemUser);
     $blank_KeywordSelect->_Accessible( 'Foo', 'read' );
     my $global_ksacc = $blank_KeywordSelect->{_AccessibleCache};
+    my %KeywordCols = (
+        Name => 'read/write',
+        Keyword => 'read/write', # link to Keywords.  Can be specified by id
+        Single => 'read/write', # bool (described below)
+
+        Depth => 'read/write', #- If non-zero, limits the descendents to this number of levels deep.
+        ObjectType  => 'read/write', # currently only C<Ticket>
+        ObjectField => 'read/write', #optional, currently only C<Queue>
+        ObjectValue => 'read/write', #constrains KeywordSelect function to when B<ObjectType>.I<ObjectField> equals I<ObjectValue>
+        Disabled => 'read/write'
+    );
     my $global_ks    = RT::KeywordSelects->new($RT::SystemUser);
     $global_ks->LimitToQueue(0);
     $global_ks->{'find_disabled_rows'} = 1;
     foreach my $keysel ( @{ $global_ks->ItemsArrayRef } ) {
 
-        foreach my $param ( sort keys %$global_ksacc, 'id' ) {
+        foreach my $param ( sort keys %$global_ksacc,
+                keys %KeywordCols, 'id' ) {
             $ds->{Global}->{'CustomField'}->{ $keysel->id }->{$param} = $keysel->_Value($param)
               if ( $keysel->_Value($param) );
         }
@@ -151,11 +168,24 @@
     my $blank_Link = RT::Link->new($RT::SystemUser);
     $blank_Link->_Accessible( 'Foo', 'read' );
     $acc = $blank_Link->{_AccessibleCache};
+
+    my %LinksCols = (
+        LocalBase => 'read',
+        LocalTarget => 'read',
+        Base => 'read',
+        Target => 'read',
+        Type => 'read',
+        Creator => 'read/auto',
+        Created => 'read/auto',
+        LastUpdatedBy => 'read/auto',
+        LastUpdated => 'read/auto'
+    );
+
     my $links = RT::Links->new($RT::SystemUser);
     $links->UnLimit();
     while ( my $l = $links->Next ) {
         my $link_ds;
-        foreach my $param ( sort keys %$acc ) {
+        foreach my $param ( sort keys %$acc, keys %LinksCols ) {
             $link_ds->{$param} = $l->_Value($param)
               if ( $l->_Value($param) );
         }
@@ -201,6 +231,32 @@
     ## but then we'd not be able to say /why/ we're not exporting the
     ## ticket...
 
+
+    my $Cols = {
+        EffectiveId => { 'read' => 1, 'write' => 1, 'public' => 1 },
+        Queue => { 'read' => 1, 'write' => 1 },
+        Requestors => { 'read' => 1, 'write' => 1 },
+        Owner => { 'read' => 1, 'write' => 1 },
+        Subject => { 'read' => 1, 'write' => 1 },
+        InitialPriority => { 'read' => 1, 'write' => 1 },
+        FinalPriority => { 'read' => 1, 'write' => 1 },
+        Priority => { 'read' => 1, 'write' => 1 },
+        Status => { 'read' => 1, 'write' => 1 },
+        TimeWorked => { 'read' => 1, 'write' => 1 },
+        TimeLeft => { 'read' => 1, 'write' => 1 },
+        Created => { 'read' => 1, 'auto' => 1 },
+        Creator => { 'read' => 1,  'auto' => 1 },
+        Told => { 'read' => 1, 'write' => 1 },
+        Resolved => {'read' => 1},
+        Starts => { 'read' => 1, 'write' => 1 },
+        Started => { 'read' => 1, 'write' => 1 },
+        Due => { 'read' => 1, 'write' => 1 },
+        Creator => { 'read' => 1, 'auto' => 1 },
+        Created => { 'read' => 1, 'auto' => 1 },
+        LastUpdatedBy => { 'read' => 1, 'auto' => 1 },
+        LastUpdated => { 'read' => 1, 'auto' => 1 }
+    };
+
     while ( my $t = $tix->Next ) {
         my $tick_ds;
         if (!$export_dead && ($t->Status eq 'dead')) {
@@ -216,7 +272,8 @@
 
         }
 
-        foreach my $param ( sort keys %{ $t->{_AccessibleCache} }, 'id' ) {
+        foreach my $param ( sort keys %{ $t->{_AccessibleCache} },
+                keys %$Cols, 'id' ) {
             $tick_ds->{$param} = $t->_Value($param)
               if ( $t->_Value($param) );
         }
@@ -244,14 +301,40 @@
             }
         }
 
+        my $AttachmentCols = 
+            {
+            TransactionId   => { 'read'=>1, 'public'=>1, },
+            MessageId       => { 'read'=>1, },
+            Parent          => { 'read'=>1, },
+            ContentType     => { 'read'=>1, },
+            Subject         => { 'read'=>1, },
+            Content         => { 'read'=>1, },
+            ContentEncoding => { 'read'=>1, },
+            Headers         => { 'read'=>1, },
+            Filename        => { 'read'=>1, },
+            Creator         => { 'read'=>1, 'auto'=>1, },
+            Created         => { 'read'=>1, 'auto'=>1, },
+        };
         my $blank_Transaction = RT::Transaction->new($RT::SystemUser);
         $blank_Transaction->_Accessible( 'Foo', 'read' );
         my $tracc = $blank_Transaction->{_AccessibleCache};
+        my %TransactionCols = (
+            TimeTaken => 'read',
+            Ticket => 'read/public',
+            Type=> 'read',
+            Field => 'read',
+            Data => 'read',
+            NewValue => 'read',
+            OldValue => 'read',
+            Creator => 'read/auto',
+            Created => 'read/auto',
+        );
         my $tr    = $t->Transactions;
         while ( my $trans = $tr->Next ) {
             my $trans_ds;
             print STDERR ".";
-            foreach my $tr_param ( sort keys %$tracc, 'id' ) {
+            foreach my $tr_param ( sort keys %$tracc, keys %TransactionCols,
+                    'id' ) {
                 $trans_ds->{$tr_param} = $trans->_Value($tr_param)
                   if ( $trans->_Value($tr_param) );
             }
@@ -264,7 +347,8 @@
                 my $att_ds;
                 print STDERR ".";
                 foreach
-                  my $att_param ( sort keys %{ $att->{_AccessibleCache} } ) {
+                  my $att_param ( sort keys %{ $att->{_AccessibleCache} },
+                            keys %$AttachmentCols) {
                         if ($att_param eq 'Content') {
                                 $att_ds->{$att_param} = $att->Content();
 
@@ -294,6 +378,73 @@
     $blank_User->_Accessible( 'Foo', 'read' );
     my $acc = $blank_User->{_AccessibleCache};
 
+    my %Cols = (
+        # {{{ Core RT info
+        Name => 'public/read/write/admin',
+        Password => 'write',
+        Comments => 'read/write/admin',
+        Signature => 'read/write',
+        EmailAddress => 'public/read/write',
+        PagerEmailAddress => 'read/write',
+        FreeformContactInfo => 'read/write',
+        Organization => 'public/read/write/admin',
+        Disabled => 'public/read/write/admin', #To modify this attribute, we have helper
+        #methods
+        Privileged => 'read/write/admin', # 0=no 1=user 2=system
+
+        # }}}
+
+        # {{{ Names
+
+        RealName => 'public/read/write',
+        NickName => 'public/read/write',
+        # }}}
+                
+        # {{{ Localization and Internationalization
+        Lang => 'public/read/write',
+        EmailEncoding => 'public/read/write',
+        WebEncoding => 'public/read/write',
+        # }}}
+
+        # {{{ External ContactInfo Linkage
+        ExternalContactInfoId => 'public/read/write/admin',
+        ContactInfoSystem => 'public/read/write/admin',
+        # }}}
+
+        # {{{ User Authentication identifier
+        ExternalAuthId => 'public/read/write/admin',
+        #Authentication system used for user 
+        AuthSystem => 'public/read/write/admin',
+        Gecos => 'public/read/write/admin', #Gecos is the name of the fields in a 
+        # unix passwd file. In this case, it refers to "Unix Username"
+        # }}}
+
+        # {{{ Telephone numbers
+        HomePhone =>  'read/write',
+        WorkPhone => 'read/write',
+        MobilePhone => 'read/write',
+        PagerPhone => 'read/write',
+
+        # }}}
+
+        # {{{ Paper Address
+        Address1 => 'read/write',
+        Address2 => 'read/write',
+        City => 'read/write',
+        State => 'read/write',
+        Zip => 'read/write',
+        Country => 'read/write',
+        # }}}
+
+        # {{{ Core DBIx::Record Attributes
+        Creator => 'read/auto',
+        Created => 'read/auto',
+        LastUpdatedBy => 'read/auto',
+        LastUpdated => 'read/auto'
+
+        # }}}
+    );
+
     my $users = RT::Users->new($RT::SystemUser);
     if ($since) {
         $users->Limit( FIELD    => 'LastUpdated', OPERATOR => ">=", VALUE    => $since );
@@ -306,7 +457,7 @@
     my @users;
     foreach my $user ( @{ $users->ItemsArrayRef } ) {
         my $user_ds;
-        foreach my $param ( sort keys %$acc, 'id' ) {
+        foreach my $param ( sort keys %Cols, keys %$acc, 'id' ) {
             $user_ds->{$param} = $user->_Value($param)
               if ( $user->_Value($param) );
         }
@@ -322,13 +473,28 @@
     $blank_Queue->_Accessible( 'Foo', 'read' );
     my $acc = $blank_Queue->{_AccessibleCache};
 
+    my %Cols = (
+        Name => 'read/write',
+        CorrespondAddress => 'read/write',
+        Description => 'read/write',
+        CommentAddress =>  'read/write',
+        InitialPriority =>  'read/write',
+        FinalPriority =>  'read/write',
+        DefaultDueIn =>  'read/write',
+        Creator => 'read/auto',
+        Created => 'read/auto',
+        LastUpdatedBy => 'read/auto',
+        LastUpdated => 'read/auto',
+        Disabled => 'read/write',
+    );
+
     my $Queues = RT::Queues->new($RT::SystemUser);
     $Queues->UnLimit();
     $Queues->{'find_disabled_rows'} = 1;
 
     foreach my $Queue ( @{ $Queues->ItemsArrayRef } ) {
         my $queue_ds;
-        foreach my $param ( sort keys %$acc, 'id' ) {
+        foreach my $param ( sort keys %$acc, keys %Cols, 'id' ) {
             $queue_ds->{$param} = $Queue->_Value($param)
               if ( $Queue->_Value($param) );
         }

-- 
John Tobin
"Linux is used for 100 percent of the work involved in the development
of new processors at Intel."
      -- Doug Fisher, general manager of Intel's Core Software Division
 http://os.newsforge.com/os/05/07/21/0730239.shtml?tid=152&tid=2&tid=18


More information about the Rt-devel mailing list