mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
API call filtering contacts by email1 returns contacts with deleted mail addresses #4779
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#4779
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DaRealWorm on GitHub (Jun 2, 2022).
Issue
When making an API call to the V8 Json API for contacts filtering by
email1field eg[...]/V8/module/Contacts?filter[email1][eq]=test@example.comcontacts are returned that do no currently have this address but had it in the past and is now deleted.The resulting query is
SELECT contacts.id FROM email_addresses JOIN email_addr_bean_rel ON email_addresses.id = email_addr_bean_rel.email_address_id JOIN contacts ON contacts.id = email_addr_bean_rel.bean_id where ((email_addresses.email_address = 'test@example.com') AND contacts.deleted = '0') AND contacts .deleted=0 LIMIT 0,20.This will return all contacts that currently have or ever had a relationship to this e-mail address. Only deleted contacts are excluded but no deleted
email_addr_bean_rels.Expected Behavior
Only contacts currently having an active (
deleted = 0) relationship to the e-mail address should be returned.Actual Behavior
Contacts whose relationship to this address has been deleted will still be found and returned.
Possible Fix
Including
and email_addr_bean_rel.deleted = 0in the query.Can be included in
Api/V8/Service/ModuleService.phpwhere the Email where clause is being constructed.Steps to Reproduce
[...]/V8/module/Contacts?filter[email1][eq]=test@example.comContext
I was trying to find a contact by e-mail address and got one that obviously did not contain the searched address. After checking the query I found that the contact previously had the address but was removed later.
Your Environment
@samus-aran commented on GitHub (Jul 6, 2022):
Seems fairly logical the fix. I dunno if this has any play in the relationship between this bug and theirs https://github.com/salesagility/SuiteCRM/issues/9147
@krzaychoos commented on GitHub (Jul 1, 2024):
Unfortunately, their bug #9147 does not resolve Contacts issue. Contacts with deleted email addresses are still found via API V8 queries. Has anyone found a solution to this problem?
@SuiteBot commented on GitHub (Jul 2, 2024):
This issue has been mentioned on SuiteCRM. There might be relevant details there:
https://community.suitecrm.com/t/api-returning-duplicate-records-on-email1-filter/88399/8
@krzaychoos commented on GitHub (Jul 2, 2024):
Exactly! THX!
@chris001 commented on GitHub (Jul 4, 2024):
Would someone like to make a PR to fix this issue, from the fixed SQL provided in this reply to the forum post?:
https://community.suitecrm.com/t/api-returning-duplicate-records-on-email1-filter/88399/4