docs: update Status.md with Zoho user sync production fixes
Some checks failed
HVAC Plugin CI/CD Pipeline / Security Analysis (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Code Quality & Standards (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Unit Tests (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Integration Tests (push) Has been cancelled
Security Monitoring & Compliance / Dependency Vulnerability Scan (push) Has been cancelled
Security Monitoring & Compliance / Secrets & Credential Scan (push) Has been cancelled
Security Monitoring & Compliance / WordPress Security Analysis (push) Has been cancelled
Security Monitoring & Compliance / Static Code Security Analysis (push) Has been cancelled
Security Monitoring & Compliance / Security Compliance Validation (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Deploy to Production (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Notification (push) Has been cancelled
Security Monitoring & Compliance / Security Summary Report (push) Has been cancelled
Security Monitoring & Compliance / Security Team Notification (push) Has been cancelled

Documents the iterative debugging of user sync on production:
version constant mismatch, GET search criteria fix, error reporting
priority, phone/name validation, and spam account cleanup.
Final result: 64/64 active trainers syncing to Zoho CRM.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ben 2026-02-06 12:58:24 -04:00
parent 4c22b9db8e
commit 7b895ad785

View file

@ -1,8 +1,8 @@
# HVAC Community Events - Project Status # HVAC Community Events - Project Status
**Last Updated:** February 6, 2026 **Last Updated:** February 6, 2026
**Current Session:** Zoho CRM Sync Fix **Current Session:** Zoho CRM Sync Production Fix
**Version:** 2.2.6 (Deployed to Production) **Version:** 2.2.11 (Deployed to Production)
--- ---
@ -18,12 +18,69 @@
- Contact forms (trainer, venue) - Contact forms (trainer, venue)
- Any other public-facing forms - Any other public-facing forms
### Post-Deploy Action Required ---
On production, go to **wp-admin > HVAC Community Events > Zoho CRM Sync**, click **"Force Full Re-sync (Reset Hashes)"**, then click each sync button or wait for the hourly scheduled sync. This clears poisoned hashes from prior failed syncs so all records re-sync with the new validated code.
## 🎯 CURRENT SESSION - ZOHO CRM SYNC PRODUCTION FIX (Feb 6, 2026)
### Status: ✅ **COMPLETE - 64/64 Trainers Syncing to Zoho CRM**
**Objective:** Fix Zoho CRM user sync that was silently failing on production - 0/65 users syncing despite "connection successful" status.
### Issues Found & Fixed (iterative production debugging)
1. **Version Constant Mismatch** (`includes/class-hvac-plugin.php`)
- `HVAC_PLUGIN_VERSION` stuck at `'2.0.0'` while `HVAC_VERSION` was `'2.2.10'`
- Admin JS used `HVAC_PLUGIN_VERSION` for cache busting, so browser served old JS without reset handler
- Fix: Bumped both constants to `'2.2.11'`
2. **GET Request Search Criteria Ignored** (`includes/zoho/class-zoho-sync.php`)
- `sync_users()` passed search criteria as `$data` parameter to `make_api_request()`
- But `make_api_request()` ignores `$data` for GET requests (line 345 only includes body for POST/PUT/PATCH)
- Every Zoho contact search returned unfiltered results, causing all syncs to fail
- Fix: Moved criteria into URL query string: `/Contacts/search?criteria=(Email:equals:...)`
3. **Error Reporting Priority** (`includes/zoho/class-zoho-sync.php`)
- `validate_api_response()` checked generic `error` key before Zoho-specific `data[0]` errors
- Users saw "API error with status code 400" instead of actionable field-level errors
- Fix: Reordered to check Zoho `data[0]` errors first, added field-level detail (api_name, expected_data_type, info)
4. **Phone Field Validation** (`includes/zoho/class-zoho-sync.php`)
- Zoho rejects invalid phone formats with HTTP 400
- Fix: Strip non-digit chars, require 10+ digits, only include Phone field when valid
5. **Last_Name Required Field** (`includes/zoho/class-zoho-sync.php`)
- Zoho Contacts module requires Last_Name but some WP users had empty last names
- Fix: Fallback chain: `last_name` meta → `display_name``user_login`
6. **Spam Account Cleanup** (production WP-CLI)
- User 14 (`rigobertohugo19`, `info103@noreply0.com`) was a spam/bot registration with no name
- Demoted from `hvac_trainer` to `subscriber`
### Production Sync Results (iterative)
| Attempt | Synced | Failed | Issue |
|---------|--------|--------|-------|
| 1st (pre-fix) | 0 | 65 | Search criteria not sent to Zoho API |
| 2nd (search fix) | 63 | 2 | Generic "status code 400" errors |
| 3rd (error detail) | 0 | 2 | User 57: invalid Phone, User 14: missing Last_Name |
| 4th (data validation) | 31 | 1 | User 57 phone still failing (7-digit threshold too low) |
| 5th (10-digit threshold) | 26 | 0 | **All 65 trainers synced** |
| Final (User 14 demoted) | **64/64** | **0** | All active trainers syncing |
### Files Modified
| File | Change |
|------|--------|
| `includes/class-hvac-plugin.php` | Synced `HVAC_PLUGIN_VERSION` to `'2.2.11'` (was stuck at `'2.0.0'`) |
| `includes/zoho/class-zoho-sync.php` | Search criteria in URL, error priority fix, phone sanitization, Last_Name fallback |
### Git Commits
- `03b9bce5` - fix(zoho): Fix silent sync failures with API response validation and hash reset
- `4c22b9db` - fix(zoho): Fix user sync search criteria and improve data validation
--- ---
## 🎯 CURRENT SESSION - ZOHO CRM SYNC FIX (Feb 6, 2026) ## 📋 PREVIOUS SESSION - ZOHO CRM SYNC ARCHITECTURE FIX (Feb 6, 2026)
### Status: ✅ **COMPLETE - Deployed to Production** ### Status: ✅ **COMPLETE - Deployed to Production**
@ -77,22 +134,6 @@ The sync pipeline had a "silent failure" architecture:
| `includes/admin/class-zoho-admin.php` | Added `reset_sync_hashes()` handler, reset button HTML, staging warning in connection test | | `includes/admin/class-zoho-admin.php` | Added `reset_sync_hashes()` handler, reset button HTML, staging warning in connection test |
| `assets/js/zoho-admin.js` | Added reset hashes button handler, staging warning display in connection test | | `assets/js/zoho-admin.js` | Added reset hashes button handler, staging warning display in connection test |
### Staging Verification
| Test | Result |
|------|--------|
| Pre-deployment checks | All passed |
| Connection Test button | "Connection successful!" |
| Staging mode detection | Correctly reports hostname-based staging |
| Force Full Re-sync button | Cleared 3 post hashes + 66 user hashes |
| Events Sync | 41/41 synced, 0 failed |
| Staging write-block (after wp-config fix) | GET: PASS (95 modules), POST: PASS (blocked) |
### Production Deployment
- Deployed successfully to https://upskillhvac.com/
- All fix code verified present on production server
- Production correctly detected as non-staging (`upskillhvac.com` hostname match)
--- ---
## 📋 PREVIOUS SESSION - NEAR ME BUTTON MOBILE FIX (Feb 6, 2026) ## 📋 PREVIOUS SESSION - NEAR ME BUTTON MOBILE FIX (Feb 6, 2026)
@ -1006,7 +1047,7 @@ DISPLAY=:1 HEADLESS=false node test-comprehensive-validation.js
### Production Environment ### Production Environment
**URL:** https://upskillhvac.com **URL:** https://upskillhvac.com
**Version:** 2.1.8 (latest) **Version:** 2.2.11 (latest)
**Server:** Cloudways Shared VPS **Server:** Cloudways Shared VPS
--- ---