[Rt-commit] rt branch, 4.2/warn-on-case-sensitive-searches, created. rt-4.1.8-486-gfcdbd5f
Alex Vandiver
alexmv at bestpractical.com
Fri May 24 16:07:16 EDT 2013
The branch, 4.2/warn-on-case-sensitive-searches has been created
at fcdbd5f52390bb7b9dd374c6ddb043a228db4ee9 (commit)
- Log -----------------------------------------------------------------
commit 7fac187fd63114fa60e2b20e1615c95badbe7083
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Apr 18 22:01:27 2013 +0400
warn on case sensitive searches
Because of historical reasons RT's searches
marked as case sensitive in RT::SearchBuilder::Limit, but we
expect them to be case insensitive.
Mixing case sensitive and case insensitive searches by the same
column causes problems for some columns on Pg and Oracle. Especially
those that should be indexed as indexes are different depending on
search kind.
This code catches such cases and throws a warning.
diff --git a/lib/RT/CustomFields.pm b/lib/RT/CustomFields.pm
index 3108b84..c337f99 100644
--- a/lib/RT/CustomFields.pm
+++ b/lib/RT/CustomFields.pm
@@ -129,7 +129,7 @@ sub LimitToGrouping {
return $self->Limit( FIELD => 'id', VALUE => 0, ENTRYAGGREGATOR => 'AND' );
}
foreach ( @$list ) {
- $self->Limit( FIELD => 'Name', VALUE => $_ );
+ $self->Limit( FIELD => 'Name', VALUE => $_, CASESENSITIVE => 0 );
}
} else {
my @list = map {@$_} grep defined && ref($_) eq 'ARRAY',
@@ -142,6 +142,7 @@ sub LimitToGrouping {
OPERATOR => '!=',
VALUE => $_,
ENTRYAGGREGATOR => 'AND',
+ CASESENSITIVE => 0,
);
}
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index e82d885..bdda8ff 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3564,7 +3564,7 @@ sub GetPrincipalsMap {
my $class = $object->RecordClassFromLookupType;
if ($class and $class->DOES("RT::Record::Role::Roles")) {
$roles->LimitToRolesForObject(RT->System);
- $roles->Limit( FIELD => "Name", VALUE => $_ )
+ $roles->Limit( FIELD => "Name", VALUE => $_, CASESENSITIVE => 0 )
for $class->Roles;
} else {
# No roles to show; so show nothing
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 6397055..efcb646 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -747,6 +747,13 @@ injection attacks when we pass through user specified values.
=cut
+my %check_case_sensitivity = (
+ groups => { 'name' => 1 },
+ queues => { 'name' => 1 },
+ users => { 'name' => 1, emailaddress => 1 },
+ customfields => { 'name' => 1 },
+);
+
my %deprecated = (
groups => {
type => 'Name',
@@ -757,7 +764,6 @@ my %deprecated = (
sub Limit {
my $self = shift;
my %ARGS = (
- CASESENSITIVE => 1,
OPERATOR => '=',
@_,
);
@@ -801,6 +807,16 @@ sub Limit {
);
}
+ unless ( exists $ARGS{CASESENSITIVE} ) {
+ if ( $table && $check_case_sensitivity{ lc $table }{ lc $ARGS{'FIELD'} } ) {
+ RT->Logger->warning(
+ "Case sensitive search by $table.$ARGS{'FIELD'}"
+ ." at ". (caller)[1] . " line ". (caller)[2]
+ );
+ }
+ $ARGS{'CASESENSITIVE'} = 1;
+ }
+
return $self->SUPER::Limit( %ARGS );
}
diff --git a/lib/RT/SearchBuilder/Role/Roles.pm b/lib/RT/SearchBuilder/Role/Roles.pm
index b1a3294..f2c85fb 100644
--- a/lib/RT/SearchBuilder/Role/Roles.pm
+++ b/lib/RT/SearchBuilder/Role/Roles.pm
@@ -137,6 +137,7 @@ sub _RoleGroupsJoin {
ALIAS => $groups,
FIELD => 'Name',
VALUE => $name,
+ CASESENSITIVE => 0,
) if $name;
$self->{'_sql_role_group_aliases'}{ $args{'Class'} .'-'. $name } = $groups
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index d23e8d3..b3078ba 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -1069,7 +1069,7 @@ sub _CustomFieldDecipher {
elsif ( $field =~ /\D/ ) {
$queue = '';
my $cfs = RT::CustomFields->new( $self->CurrentUser );
- $cfs->Limit( FIELD => 'Name', VALUE => $field );
+ $cfs->Limit( FIELD => 'Name', VALUE => $field, CASESENSITIVE => 0 );
$cfs->LimitToLookupType('RT::Queue-RT::Ticket');
# if there is more then one field the current user can
@@ -2459,7 +2459,7 @@ sub CurrentUserCanSee {
my $groups = RT::Groups->new( RT->SystemUser );
$groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
foreach ( @tmp ) {
- $groups->Limit( FIELD => 'Name', VALUE => $_ );
+ $groups->Limit( FIELD => 'Name', VALUE => $_, CASESENSITIVE => 0 );
}
my $principal_alias = $groups->Join(
ALIAS1 => 'main',
@@ -2565,6 +2565,7 @@ sub CurrentUserCanSee {
FIELD => 'Name',
VALUE => $role,
ENTRYAGGREGATOR => 'AND',
+ CASESENSITIVE => 0,
);
}
$limit_queues->( 'AND', @$queues ) if ref $queues;
diff --git a/share/html/Admin/Groups/Modify.html b/share/html/Admin/Groups/Modify.html
index 7cf046a..e9c404c 100644
--- a/share/html/Admin/Groups/Modify.html
+++ b/share/html/Admin/Groups/Modify.html
@@ -136,7 +136,7 @@ if ($Group->Id) {
# Warn about duplicate groups
my $dupcheck = RT::Groups->new(RT->SystemUser);
$dupcheck->LimitToUserDefinedGroups();
- $dupcheck->Limit( FIELD => 'Name', VALUE => $Group->Name );
+ $dupcheck->Limit( FIELD => 'Name', VALUE => $Group->Name, CASESENSITIVE => 0 );
if ($dupcheck->Count > 1) {
push @warnings, loc("There is more than one group with the name '[_1]'. This may cause inconsistency in parts of the admin interface, and therefore it's recommended you rename the conflicting groups.", $Group->Name);
}
commit 9406bce7bc0dba3f5acfb507a7b36cc2e582df19
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Apr 21 16:33:02 2013 +0400
catch and fix case sensitive searches by CF name
diff --git a/lib/RT/Articles.pm b/lib/RT/Articles.pm
index d69eabf..defed2a 100644
--- a/lib/RT/Articles.pm
+++ b/lib/RT/Articles.pm
@@ -314,7 +314,8 @@ sub LimitCustomField {
$self->Limit( ALIAS => $fields,
FIELD => 'Name',
VALUE => $args{'FIELD'},
- ENTRYAGGREGATOR => 'OR');
+ ENTRYAGGREGATOR => 'OR',
+ CASESENSITIVE => 0);
$self->Limit(
ALIAS => $fields,
FIELD => 'LookupType',
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index efcb646..4cd2168 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -808,7 +808,9 @@ sub Limit {
}
unless ( exists $ARGS{CASESENSITIVE} ) {
- if ( $table && $check_case_sensitivity{ lc $table }{ lc $ARGS{'FIELD'} } ) {
+ if ( $ARGS{'OPERATOR'} !~ /IS/i
+ && $table && $check_case_sensitivity{ lc $table }{ lc $ARGS{'FIELD'} }
+ ) {
RT->Logger->warning(
"Case sensitive search by $table.$ARGS{'FIELD'}"
." at ". (caller)[1] . " line ". (caller)[2]
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 1d2773e..e947a4b 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1406,7 +1406,7 @@ sub LoadCustomFieldByIdentifier {
my $CFs = RT::CustomFields->new( $self->CurrentUser );
$CFs->SetContextObject( $self->Object );
- $CFs->Limit( FIELD => 'Name', VALUE => $field );
+ $CFs->Limit( FIELD => 'Name', VALUE => $field, CASESENSITIVE => 0 );
$CFs->LimitToLookupType($self->CustomFieldLookupType);
$CFs->LimitToGlobalOrObjectId($self->Object->QueueObj->id);
return $CFs->First || RT::CustomField->new( $self->CurrentUser );
diff --git a/t/customfields/ip.t b/t/customfields/ip.t
index 60e68a4..2537b1e 100644
--- a/t/customfields/ip.t
+++ b/t/customfields/ip.t
@@ -26,7 +26,7 @@ my $cf;
diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
{
my $cfs = RT::CustomFields->new($RT::SystemUser);
- $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+ $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
is( $cfs->Count, 1, "found one CF with name 'IP'" );
$cf = $cfs->First;
diff --git a/t/customfields/iprange.t b/t/customfields/iprange.t
index 943e412..c99d1f1 100644
--- a/t/customfields/iprange.t
+++ b/t/customfields/iprange.t
@@ -21,7 +21,7 @@ my $cf;
diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
{
my $cfs = RT::CustomFields->new( $RT::SystemUser );
- $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+ $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
is( $cfs->Count, 1, "found one CF with name 'IP'" );
$cf = $cfs->First;
diff --git a/t/customfields/iprangev6.t b/t/customfields/iprangev6.t
index 3b8a4d6..3d73a23 100644
--- a/t/customfields/iprangev6.t
+++ b/t/customfields/iprangev6.t
@@ -21,7 +21,7 @@ my $cf;
diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
{
my $cfs = RT::CustomFields->new( $RT::SystemUser );
- $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+ $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
is( $cfs->Count, 1, "found one CF with name 'IP'" );
$cf = $cfs->First;
diff --git a/t/customfields/ipv6.t b/t/customfields/ipv6.t
index ad34f42..9c82d0d 100644
--- a/t/customfields/ipv6.t
+++ b/t/customfields/ipv6.t
@@ -26,7 +26,7 @@ my $cf;
diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
{
my $cfs = RT::CustomFields->new($RT::SystemUser);
- $cfs->Limit( FIELD => 'Name', VALUE => 'IP' );
+ $cfs->Limit( FIELD => 'Name', VALUE => 'IP', CASESENSITIVE => 0 );
is( $cfs->Count, 1, "found one CF with name 'IP'" );
$cf = $cfs->First;
commit f92208baa2a07099d71d6c2dd63d3aa9993dcbef
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Apr 22 16:43:34 2013 +0400
case insensitive search by Groups.Domain
diff --git a/lib/RT/Groups.pm b/lib/RT/Groups.pm
index 8d30dde..1cfad14 100644
--- a/lib/RT/Groups.pm
+++ b/lib/RT/Groups.pm
@@ -141,7 +141,7 @@ Return only SystemInternal Groups, such as "privileged" "unprivileged" and "ever
sub LimitToSystemInternalGroups {
my $self = shift;
- $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'SystemInternal');
+ $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'SystemInternal', CASESENSITIVE => 0 );
# All system internal groups have the same instance. No reason to limit down further
#$self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => '0');
}
@@ -158,7 +158,7 @@ Return only UserDefined Groups
sub LimitToUserDefinedGroups {
my $self = shift;
- $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined');
+ $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined', CASESENSITIVE => 0 );
# All user-defined groups have the same instance. No reason to limit down further
#$self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => '');
}
@@ -178,7 +178,7 @@ L</LimitToRolesForSystem>.
sub LimitToRolesForObject {
my $self = shift;
my $object = shift;
- $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => ref($object) . "-Role");
+ $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";
}
@@ -198,7 +198,7 @@ sub LimitToRolesForQueue {
Instead => "LimitToRolesForObject",
Remove => "4.4",
);
- $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Queue-Role');
+ $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
$self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => $queue);
}
@@ -219,7 +219,7 @@ sub LimitToRolesForTicket {
Instead => "LimitToRolesForObject",
Remove => "4.4",
);
- $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Ticket-Role');
+ $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::Ticket-Role', CASESENSITIVE => 0 );
$self->Limit(FIELD => 'Instance', OPERATOR => '=', VALUE => $Ticket);
}
@@ -239,7 +239,7 @@ sub LimitToRolesForSystem {
Instead => "LimitToRolesForObject",
Remove => "4.4",
);
- $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::System-Role');
+ $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'RT::System-Role', CASESENSITIVE => 0 );
}
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 4cd2168..edd6b39 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -748,7 +748,7 @@ injection attacks when we pass through user specified values.
=cut
my %check_case_sensitivity = (
- groups => { 'name' => 1 },
+ groups => { 'name' => 1, domain => 1 },
queues => { 'name' => 1 },
users => { 'name' => 1, emailaddress => 1 },
customfields => { 'name' => 1 },
diff --git a/lib/RT/SearchBuilder/Role/Roles.pm b/lib/RT/SearchBuilder/Role/Roles.pm
index f2c85fb..6bf239b 100644
--- a/lib/RT/SearchBuilder/Role/Roles.pm
+++ b/lib/RT/SearchBuilder/Role/Roles.pm
@@ -131,6 +131,7 @@ sub _RoleGroupsJoin {
ALIAS => $groups,
FIELD => 'Domain',
VALUE => $args{'Class'} .'-Role',
+ CASESENSITIVE => 0,
);
$self->Limit(
LEFTJOIN => $groups,
diff --git a/lib/RT/Shredder/Queue.pm b/lib/RT/Shredder/Queue.pm
index 80a1c84..46fea2f 100644
--- a/lib/RT/Shredder/Queue.pm
+++ b/lib/RT/Shredder/Queue.pm
@@ -76,7 +76,7 @@ sub __DependsOn
# Queue role groups( Cc, AdminCc )
$objs = RT::Groups->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
+ $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
$objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
push( @$list, $objs );
diff --git a/lib/RT/Shredder/Ticket.pm b/lib/RT/Shredder/Ticket.pm
index c532486..7c8da55 100644
--- a/lib/RT/Shredder/Ticket.pm
+++ b/lib/RT/Shredder/Ticket.pm
@@ -77,7 +77,7 @@ sub __DependsOn
# Ticket role groups( Owner, Requestors, Cc, AdminCc )
$objs = RT::Groups->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Ticket-Role' );
+ $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Ticket-Role', CASESENSITIVE => 0 );
$objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
push( @$list, $objs );
diff --git a/lib/RT/Shredder/User.pm b/lib/RT/Shredder/User.pm
index 67443e7..eb5b3d6 100644
--- a/lib/RT/Shredder/User.pm
+++ b/lib/RT/Shredder/User.pm
@@ -99,7 +99,7 @@ sub __DependsOn
# ACL equivalence group
# don't use LoadACLEquivalenceGroup cause it may not exists any more
my $objs = RT::Groups->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Domain', VALUE => 'ACLEquivalence' );
+ $objs->Limit( FIELD => 'Domain', VALUE => 'ACLEquivalence', CASESENSITIVE => 0 );
$objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
push( @$list, $objs );
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index afeb9db..f92e812 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -726,7 +726,10 @@ sub load_or_create_user {
my $groups_alias = $gms->Join(
FIELD1 => 'GroupId', TABLE2 => 'Groups', FIELD2 => 'id',
);
- $gms->Limit( ALIAS => $groups_alias, FIELD => 'Domain', VALUE => 'UserDefined' );
+ $gms->Limit(
+ ALIAS => $groups_alias, FIELD => 'Domain', VALUE => 'UserDefined',
+ CASESENSITIVE => 0,
+ );
$gms->Limit( FIELD => 'MemberId', VALUE => $obj->id );
while ( my $group_member_record = $gms->Next ) {
$group_member_record->Delete;
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index b3078ba..69af181 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -977,7 +977,8 @@ sub _WatcherMembershipLimit {
ALIAS => $groups,
FIELD => 'Domain',
VALUE => 'RT::Ticket-Role',
- ENTRYAGGREGATOR => 'AND'
+ ENTRYAGGREGATOR => 'AND',
+ CASESENSITIVE => 0,
);
$self->Join(
@@ -2457,7 +2458,7 @@ sub CurrentUserCanSee {
if ( my @tmp = grep $_ ne 'Owner' && !ref $roles{ $_ }, keys %roles ) {
my $groups = RT::Groups->new( RT->SystemUser );
- $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
+ $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
foreach ( @tmp ) {
$groups->Limit( FIELD => 'Name', VALUE => $_, CASESENSITIVE => 0 );
}
diff --git a/share/html/Elements/ShowMemberships b/share/html/Elements/ShowMemberships
index 1985302..8cc8b0a 100644
--- a/share/html/Elements/ShowMemberships
+++ b/share/html/Elements/ShowMemberships
@@ -71,12 +71,14 @@ $GroupMembers->Limit(
FIELD => 'Domain',
OPERATOR => '=',
VALUE => 'SystemInternal',
+ CASESENSITIVE => 0,
);
$GroupMembers->Limit(
ALIAS => $alias,
FIELD => 'Domain',
OPERATOR => '=',
VALUE => 'UserDefined',
+ CASESENSITIVE => 0,
);
$GroupMembers->OrderByCols(
{ ALIAS => $alias, FIELD => 'Domain' },
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 a96f8cb41dd2375efa2e0d778f9d04c00cd14c51
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Apr 22 17:17:33 2013 +0400
use LoadByCols instead of search
For backwards compatibility use LoadByCols
instead of Load.
diff --git a/share/html/REST/1.0/Forms/queue/ns b/share/html/REST/1.0/Forms/queue/ns
index 3ea6bf2..c0f6b1e 100644
--- a/share/html/REST/1.0/Forms/queue/ns
+++ b/share/html/REST/1.0/Forms/queue/ns
@@ -53,10 +53,10 @@ $id
<%perl>
use RT::Queues;
-my $queues = RT::Queues->new($session{CurrentUser});
-$queues->Limit(FIELD => 'Name', OPERATOR => '=', VALUE => $id);
-if ($queues->Count == 0) {
+my $queue = RT::Queue->new($session{CurrentUser});
+$queue->LoadByCols( Name => $id );
+unless ($queue->id) {
return (0, "No queue named $id exists.");
}
-return $queues->Next->Id;
+return $queue->id;
</%perl>
commit fcdbd5f52390bb7b9dd374c6ddb043a228db4ee9
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 aceb23a..7911f83 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1234,6 +1234,14 @@ 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;
+ my ($field, $op, $value) = $self->_MakeClauseCaseInsensitive(@_);
+ return "$field $op $value";
+}
+
__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