[Rt-commit] rt branch, 4.2/upgrading-indexes-and-review, updated. rt-4.1.8-577-ga5a50b1

Alex Vandiver alexmv at bestpractical.com
Thu Jul 11 01:25:11 EDT 2013


The branch, 4.2/upgrading-indexes-and-review has been updated
       via  a5a50b1262069f3863eb18602e09a6a7b14d08b1 (commit)
       via  f015ee7f39a3979da0507f69ccf4cb5cb1dd887e (commit)
       via  f6dd51a29b862fa0290a181ba945135079b3e6aa (commit)
      from  fa917d0369c415f647bae91d9d3ff06ed90f6557 (commit)

Summary of changes:
 lib/RT/Group.pm     |  5 +++--
 lib/RT/Groups.pm    |  4 ++--
 lib/RT/Principal.pm | 12 +-----------
 lib/RT/Users.pm     |  7 ++++---
 4 files changed, 10 insertions(+), 18 deletions(-)

- Log -----------------------------------------------------------------
commit f6dd51a29b862fa0290a181ba945135079b3e6aa
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Jul 2 16:42:33 2013 -0400

    Specify Instance even for RT::System groups
    
    This allows more specific indexes to be used.

diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index d202d79..0778600 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -330,8 +330,9 @@ sub LoadSystemRoleGroup {
         Remove => "4.4",
     );
     $self->LoadByCols(
-        Domain => 'RT::System-Role',
-        Name => $type
+        Domain   => 'RT::System-Role',
+        Instance => RT::System->Id,
+        Name     => $type
     );
 }
 
diff --git a/lib/RT/Groups.pm b/lib/RT/Groups.pm
index 7d5671e..77f702a 100644
--- a/lib/RT/Groups.pm
+++ b/lib/RT/Groups.pm
@@ -179,8 +179,7 @@ sub LimitToRolesForObject {
     my $self   = shift;
     my $object = shift;
     $self->Limit(FIELD => 'Domain',   OPERATOR => '=', VALUE => ref($object) . "-Role", CASESENSITIVE => 0 );
-    $self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => $object->id)
-        if $object->id and not ref($object) eq "RT::System";
+    $self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => $object->id);
 }
 
 =head2 LimitToRolesForQueue QUEUE_ID
@@ -240,6 +239,7 @@ sub LimitToRolesForSystem {
         Remove => "4.4",
     );
     $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::System-Role', CASESENSITIVE => 0 );
+    $self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => RT::System->Id );
 }
 
 

commit f015ee7f39a3979da0507f69ccf4cb5cb1dd887e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Jul 2 16:46:42 2013 -0400

    ->id can be called as a class method on RT::System; use eval rather than ref() and can()
    
    This mirrors the code in RT::Principal::_HasRoleRightQuery.

diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index d7c2b81..6b9ad20 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -458,11 +458,12 @@ sub _RoleClauses {
     my @groups_clauses;
     foreach my $obj ( @objects ) {
         my $type = ref($obj)? ref($obj): $obj;
-        my $id;
-        $id = $obj->id if ref($obj) && UNIVERSAL::can($obj, 'id') && $obj->id;
 
         my $role_clause = $RT::Handle->__MakeClauseCaseInsensitive("$groups.Domain", '=', "'$type-Role'");
-        $role_clause   .= " AND $groups.Instance = $id" if $id;
+
+        if ( my $id = eval { $obj->id } ) {
+            $role_clause .= " AND $groups.Instance = $id";
+        }
         push @groups_clauses, "($role_clause)";
     }
     return @groups_clauses;

commit a5a50b1262069f3863eb18602e09a6a7b14d08b1
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Jul 2 16:47:12 2013 -0400

    Refactor duplicated role group code

diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
index 14b0e74..7dff9da 100644
--- a/lib/RT/Principal.pm
+++ b/lib/RT/Principal.pm
@@ -582,17 +582,7 @@ sub _HasRoleRightQuery {
         ) . ")";
     }
 
-    my (@object_clauses);
-    foreach my $obj ( @{ $args{'EquivObjects'} } ) {
-        my $type = ref($obj) ? ref($obj) : $obj;
-
-        my $clause = $RT::Handle->__MakeClauseCaseInsensitive('Groups.Domain', '=', "'$type-Role'");
-
-        if ( my $id = eval { $obj->id } ) {
-            $clause .= " AND Groups.Instance = $id";
-        }
-        push @object_clauses, "($clause)";
-    }
+    my @object_clauses = RT::Users->_RoleClauses( Groups => @{ $args{'EquivObjects'} } );
     $query .= " AND (" . join( ' OR ', @object_clauses ) . ")";
     return $query;
 }

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


More information about the Rt-commit mailing list