[Rt-commit] rt branch 5.0/articles-limit-custom-field-object-type created. rt-5.0.2-57-gfadcd86daf
BPS Git Server
git at git.bestpractical.com
Fri Jan 7 19:05:23 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/articles-limit-custom-field-object-type has been created
at fadcd86dafd1adfeaaacfe36d0e3175445653651 (commit)
- Log -----------------------------------------------------------------
commit fadcd86dafd1adfeaaacfe36d0e3175445653651
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Jan 8 02:44:58 2022 +0800
Test articles custom field searches without specifying a custom field
diff --git a/t/articles/cfsearch.t b/t/articles/cfsearch.t
index 3bfa667eea..1c2858f991 100644
--- a/t/articles/cfsearch.t
+++ b/t/articles/cfsearch.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use RT::Test tests => 11;
+use RT::Test tests => undef;
my $suffix = '-'. $$;
@@ -91,3 +91,38 @@ $article2->AddCustomFieldValue(Field => $cf->Id, Value => 'Value2');
is $articles->Count, 1, 'found correct number of articles';
}
+diag "Search any custom field";
+
+# Makes sure to not search non-article custom fields
+my $class_cf = RT::CustomField->new( RT->SystemUser );
+my ( $ret, $msg ) = $class_cf->Create(
+ Name => 'Class CF',
+ LookupType => 'RT::Class',
+ Type => 'Freeform',
+ MaxValues => 1,
+);
+ok $ret, $msg;
+
+( $ret, $msg ) = $class_cf->AddToObject($class);
+ok $ret, $msg;
+
+( $ret, $msg ) = $class->AddCustomFieldValue( Field => $class_cf, Value => 'Class Foo' );
+ok $ret, $msg;
+
+{
+ my $articles = RT::Articles->new($RT::SystemUser);
+ $articles->UnLimit();
+ $articles->Limit( FIELD => "Class", SUBCLAUSE => 'ClassMatch', VALUE => $class->Id );
+ $articles->LimitCustomField( VALUE => 'Value1' );
+ is $articles->Count, 1, 'found correct number of articles';
+}
+
+{
+ my $articles = RT::Articles->new($RT::SystemUser);
+ $articles->UnLimit();
+ $articles->Limit( FIELD => "Class", SUBCLAUSE => 'ClassMatch', VALUE => $class->Id );
+ $articles->LimitCustomField( VALUE => 'Class Foo' );
+ is $articles->Count, 0, 'found correct number of articles';
+}
+
+done_testing;
commit 9bc84cc90eb1b77d402b6d45426caf822aa05b36
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Jan 8 02:24:14 2022 +0800
Limit ObjectType in articles custom field searches
RT::Articles::LimitCustomField supports to search any custom field(i.e.
no custom fields are specified), which could cause RT to wrongly search
non-article custom fields.
diff --git a/lib/RT/Articles.pm b/lib/RT/Articles.pm
index 0e569d201e..0167938b93 100644
--- a/lib/RT/Articles.pm
+++ b/lib/RT/Articles.pm
@@ -266,6 +266,11 @@ sub LimitCustomField {
EXPRESSION => 'main.id'
);
+ $self->Limit(
+ LEFTJOIN => $ObjectValuesAlias,
+ FIELD => 'ObjectType',
+ VALUE => 'RT::Article',
+ );
$self->Limit(
LEFTJOIN => $ObjectValuesAlias,
FIELD => 'Disabled',
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list