[Rt-commit] rt branch, 4.0/skip-system-user-in-txns-right-check, created. rt-4.0.23-12-ga09e210

? sunnavy sunnavy at bestpractical.com
Sun Mar 15 08:08:57 EDT 2015


The branch, 4.0/skip-system-user-in-txns-right-check has been created
        at  a09e210eddaf9975855a48caa6d7e732313ad836 (commit)

- Log -----------------------------------------------------------------
commit a09e210eddaf9975855a48caa6d7e732313ad836
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 5 00:36:46 2015 +0800

    pass directly for system user in RT::Transaction->CurrentUserCanSee check
    
    this is because outdated ObjectType field could cause the following ->Object to
    die. since the _outdated_ issue usually happens when upgrading RT, we need to
    short-circuit it for system user to make upgrade code happy.
    
    one fail case is in etc/upgrade/upgrade-articles, where we iterate transactions
    to update ObjectType from "RT::FM::Article" to "RT::Article". the error is:
    Can't locate object method "new" via package "RT::FM::Article"

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 8590dbd..f2a88f1 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1152,11 +1152,15 @@ This fact depends on type of the transaction, type of an object the transaction
 is attached to and may be other conditions, so this method is prefered over
 custom implementations.
 
+It always returns true if current user is system user.
+
 =cut
 
 sub CurrentUserCanSee {
     my $self = shift;
 
+    return 1 if $self->CurrentUser->PrincipalObj->Id == RT->SystemUser->Id;
+
     # If it's a comment, we need to be extra special careful
     my $type = $self->__Value('Type');
     if ( $type eq 'Comment' ) {

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


More information about the rt-commit mailing list