[Rt-commit] rt branch, 4.2/warn-on-case-sensitive-searches, updated. rt-4.1.8-160-g687f2fd
Ruslan Zakirov
ruz at bestpractical.com
Mon Apr 22 10:55:05 EDT 2013
The branch, 4.2/warn-on-case-sensitive-searches has been updated
via 687f2fd171a5bdf6a0cd555383c688fdf05f0691 (commit)
via ab4cb6fa2f002eb5ed1aa33d3fd591d3dc121b53 (commit)
via 529de604d91f293d1dea95c592e9fc5b895db3d4 (commit)
from 53152fc887cef180c97908356930cf77ddb05c76 (commit)
Summary of changes:
lib/RT/Handle.pm | 7 +++++++
lib/RT/Principal.pm | 7 +++++--
lib/RT/Users.pm | 6 ++++--
t/web/owner_disabled_group_19221.t | 4 ++--
4 files changed, 18 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 529de604d91f293d1dea95c592e9fc5b895db3d4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Apr 22 18:20:11 2013 +0400
hopefuly last case of Groups.Domain case sensitive search
diff --git a/t/web/owner_disabled_group_19221.t b/t/web/owner_disabled_group_19221.t
index d41decf..a5866dd 100644
--- a/t/web/owner_disabled_group_19221.t
+++ b/t/web/owner_disabled_group_19221.t
@@ -122,7 +122,7 @@ diag "Check WithMember and WithoutMember recursively";
{
my $with = RT::Groups->new( RT->SystemUser );
$with->WithMember( PrincipalId => $user->PrincipalObj->Id, Recursively => 1 );
- $with->Limit( FIELD => 'domain', OPERATOR => '=', VALUE => 'UserDefined' );
+ $with->Limit( FIELD => 'domain', OPERATOR => '=', VALUE => 'UserDefined', CASESENSITIVE => 0 );
is_deeply(
[map {$_->Name} @{$with->ItemsArrayRef}],
['Disabled Group','Supergroup'],
@@ -131,7 +131,7 @@ diag "Check WithMember and WithoutMember recursively";
my $without = RT::Groups->new( RT->SystemUser );
$without->WithoutMember( PrincipalId => $user->PrincipalObj->Id, Recursively => 1 );
- $without->Limit( FIELD => 'domain', OPERATOR => '=', VALUE => 'UserDefined' );
+ $without->Limit( FIELD => 'domain', OPERATOR => '=', VALUE => 'UserDefined', CASESENSITIVE => 0 );
is_deeply(
[map {$_->Name} @{$without->ItemsArrayRef}],
[],
commit ab4cb6fa2f002eb5ed1aa33d3fd591d3dc121b53
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Apr 22 18:45:18 2013 +0400
a case of missing Groups.Type -> Groups.Name change
diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index cf27993..fc17854 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -440,7 +440,7 @@ sub WhoHaveRoleRight
VALUE => RT->SystemUser->id
);
- $self->_AddSubClause( "WhichRole", "(". join( ' OR ', map "$groups.Type = '$_'", @roles ) .")" );
+ $self->_AddSubClause( "WhichRole", "(". join( ' OR ', map "$groups.Name = '$_'", @roles ) .")" );
my @groups_clauses = $self->_RoleClauses( $groups, @objects );
$self->_AddSubClause( "WhichObject", "(". join( ' OR ', @groups_clauses ) .")" )
commit 687f2fd171a5bdf6a0cd555383c688fdf05f0691
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Apr 22 18:54:13 2013 +0400
handle case sensitivity in manually generated SQL
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 6f2272f..576fe32 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1228,6 +1228,13 @@ sub _LogSQLStatement {
push @{$self->{'StatementLog'}} , ([Time::HiRes::time(), $statement, [@bind], $duration, HTML::Mason::Exception->new->as_string]);
}
+# helper in a few cases where we do SQL by hand
+sub __MakeClauseCaseInsensitive {
+ my $self = shift;
+ return join ' ', @_ unless $self->CaseSensitive;
+ return join ' ', grep defined, $self->_MakeClauseCaseInsensitive(@_);
+}
+
__PACKAGE__->FinalizeDatabaseType;
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
index e87a3cb..14b0e74 100644
--- a/lib/RT/Principal.pm
+++ b/lib/RT/Principal.pm
@@ -576,14 +576,17 @@ sub _HasRoleRightQuery {
;
if ( $args{'Roles'} ) {
- $query .= "AND (" . join( ' OR ', map "Groups.Name = '$_'", @{ $args{'Roles'} } ) . ")";
+ $query .= "AND (" . join( ' OR ',
+ map $RT::Handle->__MakeClauseCaseInsensitive('Groups.Name', '=', "'$_'"),
+ @{ $args{'Roles'} }
+ ) . ")";
}
my (@object_clauses);
foreach my $obj ( @{ $args{'EquivObjects'} } ) {
my $type = ref($obj) ? ref($obj) : $obj;
- my $clause = "Groups.Domain = '$type-Role'";
+ my $clause = $RT::Handle->__MakeClauseCaseInsensitive('Groups.Domain', '=', "'$type-Role'");
if ( my $id = eval { $obj->id } ) {
$clause .= " AND Groups.Instance = $id";
diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index fc17854..5b3ae6c 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -440,7 +440,9 @@ sub WhoHaveRoleRight
VALUE => RT->SystemUser->id
);
- $self->_AddSubClause( "WhichRole", "(". join( ' OR ', map "$groups.Name = '$_'", @roles ) .")" );
+ $self->_AddSubClause( "WhichRole", "(". join( ' OR ',
+ map $RT::Handle->__MakeClauseCaseInsensitive("$groups.Name", '=', "'$_'"), @roles
+ ) .")" );
my @groups_clauses = $self->_RoleClauses( $groups, @objects );
$self->_AddSubClause( "WhichObject", "(". join( ' OR ', @groups_clauses ) .")" )
@@ -460,7 +462,7 @@ sub _RoleClauses {
my $id;
$id = $obj->id if ref($obj) && UNIVERSAL::can($obj, 'id') && $obj->id;
- my $role_clause = "$groups.Domain = '$type-Role'";
+ my $role_clause = $RT::Handle->__MakeClauseCaseInsensitive("$groups.Domain", '=', "'$type-Role'");
$role_clause .= " AND $groups.Instance = $id" if $id;
push @groups_clauses, "($role_clause)";
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list