Repository navigation
Save company custom fields and sources on limited field updates - #100
Merged
Merged
Conversation
addUpdateCompany() saves custom fields and external sources after the columns, but only on the full update path. A limited field update skipped both without a word. An update becomes a limited field update when "Overwrite Option" (fieldoverride) is on and it comes from an external source: the CSV importer, forms, the API and the sync extensions. So on those sites a CSV import mapping a company custom field left the old value in place, and the source was never recorded against an existing company. A caller passing limitedFields directly fared no better: the custom field keys it named were moved out of the column update "for separate update", which then never ran. Contacts have saved custom fields on either path since 2.98.1, skipping blanks under do_not_update_blanks, and #34 moved their external sources out of the same check. Companies now do the same, from the same shapes. Also fix getCompany() and getCompanies() with withExternalSources: both passed their args as getExternalSources()'s $id, so they always returned false. The grouped variant and every other caller pass -1 first. Found while testing JETCRM-1465 (Automattic/jetpack-crm-extensions#908). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From a /simplify review: the three near-identical addUpdateCustomField() blocks (custom fields, addr_ and secaddr_ address fields) become one list of keys and one loop, with the blank rule stated once. Same behaviour. The test no longer resets the CRM tables twice per test (the base integration test case already does), and fetches through get_company(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tellyworth
force-pushed
the
fix/company-limited-update-custom-fields
branch
from
November 10, 2026 04:04
03b2ca5 to
fbcea70
Compare
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
addUpdateCompany()only saved custom fields and external sources on its full update path, so a limited field update silently dropped both. An update becomes a limited field update when "Overwrite Option" (fieldoverride) is on and it comes from an external source: CSV Importer, forms, the API and the sync extensions. Callers that passlimitedFieldsdirectly hit it too.What users see, with Overwrite Option on:
Contacts don't have this problem. They have saved custom fields on both paths since 2.98.1 (skipping blanks under
do_not_update_blanks), and #34 moved their external sources out of the same check. This PR gives companies the same handling, following the contacts code.Also fixed
getCompany()/getCompanies()withwithExternalSourcespassed their args array asgetExternalSources()'s$id, so they always returnedfalse. The grouped variant and every other caller pass-1first. I found it because the new test needed to read the source back.Not changed
dataare still applied only on full updates. Contacts behave the same way, and changing that for both is a broader decision.limitedFieldsguard (Events ~1471, Quotes ~1639, Transactions ~1814, Invoices ~1883). The general fix is a sharedObjectLayerhelper called by all six DALs, but that touches four more large DALs with their own semantics, so it's left for a follow-up: JETCRM-1466.Testing
tests/php/entities/Company_Limited_Update_Test.php. All 4 tests fail on trunk and pass here:limitedFieldsupdate saves a custom field it names, and leaves the others aloneOK (188 tests, 605 assertions), including on a freshly reset tests DB.phpcs-changedclean. The moved block keeps its legacy camelCase names under a scopedphpcs:disable, as in Stop forms clearing contact details, and updates clearing the owner #34.Not scheduled for a release yet.
🤖 Generated with Claude Code