Add update or create handle related cutomer rows in DB in contact page#560
Open
avishka-ra wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to keep WHMCS-side handle records (wHandles and wDomain_handle) in sync with OpenProvider contact handles when viewing the contact details page, and to refresh stored handle data even when no OpenProvider-side update is required—so lookups like findExisting() stay accurate.
Changes:
- Update
Handle::updateOrCreate()to refreshwHandles.datawhen OpenProvider data matches the form but the local serialized Customer differs. - Add
ContactController::syncHandlesWithWhmcs()and call it fromgetContactDetails()to create/link missingwHandles/wDomain_handlerows based on fetched OpenProvider contacts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| modules/registrars/openprovider/src/Handle.php | Refreshes wHandles.data when no OP-side change is needed, to prevent stale serialized Customer data. |
| modules/registrars/openprovider/Controllers/System/ContactController.php | Adds a sync routine to backfill/link handle rows in WHMCS when contact data is fetched from OpenProvider. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
prasad-fernando-74
approved these changes
Jun 26, 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.
Root cause
When getContactDetails fetches domain contacts from the OP API, the wHandles and wDomain_handle tables were never populated for that domain. As a result, when the user submitted the WHOIS edit form, updateOrCreate in Handle.php could not find an existing handle in wHandles and fell through to create a new one in OP — duplicating the owner handle instead of updating it.
Fix
Two files changed:
ContactController.php — added syncHandlesWithWhmcs (+ two helpers) called after fetching contacts from the API in getContactDetails:
Looks up the WHMCS domain and user from tbldomains
For each role that has both a handle ID and contact data, ensures a wHandles row exists via ensureWHandleRow and a wDomain_handle pivot row via syncDomainHandleLink
wHandles.type rules: Owner is always all; any OP handle shared by more than one role is also all; a handle serving exactly one non-Owner role gets that role's specific type (admin/tech/billing)
Existing wHandles.data is never overwritten — it may carry extensionAdditionalData set during registration
Type is upgrade-only (specific → all allowed; all → specific never)
Handle.php — in the updateOrCreate "no change" path (OP data matches the form, no API update needed): detects when wHandles.data is stale (e.g. written by the new sync with only basic contact fields) and refreshes it, keeping findExisting accurate on future calls.