Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
087f05e2
Unverified
Commit
087f05e2
authored
7 months ago
by
JonGold
Browse files
Options
Downloads
Patches
Plain Diff
fix using REGEXP with contact ID
parent
99d3046f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Civi/Api4/Utils/FormattingUtil.php
+2
-1
2 additions, 1 deletion
Civi/Api4/Utils/FormattingUtil.php
tests/phpunit/api/v4/Action/ContactGetTest.php
+7
-0
7 additions, 0 deletions
tests/phpunit/api/v4/Action/ContactGetTest.php
with
9 additions
and
1 deletion
Civi/Api4/Utils/FormattingUtil.php
+
2
−
1
View file @
087f05e2
...
...
@@ -126,7 +126,8 @@ class FormattingUtil {
}
// Special handling for 'current_user' and user lookups
if
(
$fk
===
'Contact'
&&
isset
(
$value
)
&&
!
is_numeric
(
$value
))
{
$exactMatch
=
[
NULL
,
'='
,
'!='
,
'<>'
,
'IN'
,
'NOT IN'
];
if
(
$fk
===
'Contact'
&&
isset
(
$value
)
&&
!
is_numeric
(
$value
)
&&
in_array
(
$operator
,
$exactMatch
,
TRUE
))
{
$value
=
\_civicrm_api3_resolve_contactID
(
$value
);
if
(
'unknown-user'
===
$value
)
{
throw
new
\CRM_Core_Exception
(
"
\"
{
$fieldSpec
[
'name'
]
}
\"
\"
{
$value
}
\"
cannot be resolved to a contact ID"
,
2002
,
[
'error_field'
=>
$fieldSpec
[
'name'
],
"type"
=>
"integer"
]);
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/api/v4/Action/ContactGetTest.php
+
7
−
0
View file @
087f05e2
...
...
@@ -318,6 +318,13 @@ class ContactGetTest extends Api4TestBase implements TransactionalInterface {
$this
->
assertArrayHasKey
(
$meg
[
'id'
],
(
array
)
$result
);
$this
->
assertArrayHasKey
(
$jess
[
'id'
],
(
array
)
$result
);
$this
->
assertArrayHasKey
(
$amy
[
'id'
],
(
array
)
$result
);
// Check that punctuation in REGEXP isn't munged away.
$findByIDs
=
'^('
.
$jane
[
'id'
]
.
'|'
.
$meg
[
'id'
]
.
'|'
.
$jess
[
'id'
]
.
'|'
.
$amy
[
'id'
]
.
')$'
;
$result
=
Contact
::
get
(
FALSE
)
->
addWhere
(
'id'
,
'REGEXP'
,
$findByIDs
)
->
execute
();
$this
->
assertCount
(
4
,
$result
);
}
public
function
testGetRelatedWithSubType
():
void
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment