V8 API - Bug in WHERE clause, when filtering email1 field #9147
Labels
Area: API
Issues & PRs related to all things regarding the API
Area: Emails
Issues & PRs related to all things regarding emails & email module
Priority:Important
Issues & PRs that are important; broken functions, errors - there are workarounds
Type: Bug
Bugs within the core SuiteCRM codebase
Hey,
there seems to be a bug in the V8 API in version 7.11.19, (I am not sure if these affects older versions as well, I just have tested it for that version), where the filter function for the
email1
field doesn't work.This applies to the comment I posted here: #8617 (comment)
Issue
By trying:
https://<suitecrm_url>/Api/V8/module/Accounts?filter[email1][eq]=<some_email>
Please note, that <suitecrm_url> and <some_email> are just placeholder!
I always get as response, and it doesn't matter if the email address exists or not:
After digging in the code a bit and debugging the query I found some interesting SQL query statement:
Which is a bit odd, if you look closely at the
WHERE
clause, which says:(email_addresses.email_address='<some_email>' AND accounts.deleted='0') AND accounts.deleted=1
From then on, it made sense why the query always fails.
After further debugging I found this interesting line:
SuiteCRM/Api/V8/Service/ModuleService.php
Lines 154 to 158 in 9cb957e
And the variable
$deleted
is defined as:SuiteCRM/Api/V8/Service/ModuleService.php
Line 123 in 9cb957e
The issue now is, that the value of
$deleted
isfalse
and due value and type check$deleted === 0
it obviously fails, due0 === false
isfalse
.So changing this line to:
solves this issue.
The text was updated successfully, but these errors were encountered: