Memory Wiki

Untitled Session

2026-06-03 23:40 UTC · 43 messages · cli

You2026-06-03 23:42 UTC
Final read-only review of profe-sync.php on test.thelinguagroup.com after bug fixes. Verify all orphaned COMMITs are removed, test data is clean, and the full architecture is sound for production deploy.
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "<?php\n/**\n * Plugin Name: Profe Sync\n * Description: Synchronizes WordPress/PMP user data with profe_main database.\n * Version: 2.0.0\n * Author: Nous Research\n * Network: true\n *\n * Must-use plugin. Place in wp-content/mu-plugins/.\n */\n\ndefined('ABSPATH') || exit;...
Tool2026-06-03 23:42 UTC
{"output": "ERROR 2026 (HY000): TLS/SSL error: self-signed certificate in certificate chain", "exit_code": 1, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "ERROR 1045 (28000): Access denied for user 'wordpress'@'172.18.0.3' (using password: YES)", "exit_code": 1, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') );\ndefine( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );\ndefine( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );\ndefine( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST',...
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "DB_USER=wordpress\nDB_PASSWORD=***\nDB_HOST=db:3306", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "\"WORDPRESS_DB_PASSWORD=***\n \"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\",\n \"PHPIZE_DEPS=autoconf \\t\\tdpkg-dev \\t\\tfile \\t\\tg++ \\t\\tgcc \\t\\tlibc-dev \\t\\tmake \\t\\tpkg-config \\t\\tre2c\",\n \"PHP_INI_DI...
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "Tables_in_profe_main\nprofe_crm\nprofe_mem_levels\nprofe_users", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "cnt\n0", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "cnt\n3", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "Error: Query failed: WARNING: option --ssl-verify-server-cert is disabled, because of an insecure passwordless login.\n--------------\nSELECT id, uuid, wp_user_id, user_login, user_email, membership_level FROM profe_main.profe_users\n--------------\n\nERROR 1054 (42S22) at line 1: Unknow...
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "Field\tType\tNull\tKey\tDefault\tExtra\nuuid\tvarchar(36)\tNO\tPRI\tNULL\t\nwp_user_id\tbigint unsigned\tNO\tUNI\tNULL\t\nuser_login\tvarchar(60)\tNO\t\tNULL\t\nuser_email\tvarchar(100)\tNO\tMUL\tNULL\t\ndisplay_name\tvarchar(250)\tNO\t\t\t\nmembership_level\tvarchar(50)\tYES\tMUL\tNULL\...
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "uuid\twp_user_id\tuser_login\tuser_email\tmembership_level\n60a46608-b0c7-4677-8709-5a3723002cf1\t2\ttestsync\ttester@test.com\tNULL\n95c26620-78c8-49d0-a785-7849282f2715\t3\tdonna\tjaimi.saunders6+donna@gmail.com\tAdmin\nc64e5051-23ac-4931-96f6-5b2305e25801\t1\tprofe\tjaimi.saunders6@gm...
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "Field\tType\tNull\tKey\tDefault\tExtra\nid\tbigint\tNO\tPRI\tNULL\tauto_increment\nuser_id\tbigint\tNO\tMUL\tNULL\t\ntag\tvarchar(100)\tNO\t\tNULL\t\ncreated_at\tdatetime\tNO\t\tCURRENT_TIMESTAMP\tDEFAULT_GENERATED\nprocessed\ttinyint(1)\tNO\tMUL\t0", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "ID\tuser_login\tuser_email\n1\tprofe\tjaimi.saunders6@gmail.com\n2\ttestsync\ttester@test.com\n3\tdonna\tjaimi.saunders6+donna@gmail.com", "exit_code": 0, "error": null}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "id\tname\tslug\tpmpro_level_id\tprice_amount\tcurrency\tbilling_interval\tsort_order\tis_active\tcreated_at\tupdated_at\n1\tAdmin\tadmin\t1\t0.00\tUSD\tone_time\t1\t1\t2026-06-02 14:16:41\t2026-06-02 14:16:41\n2\tFree\tfree\t2\t0.00\tUSD\tone_time\t2\t1\t2026-06-02 14:16:41\t2026-06-02 1...
Donna2026-06-03 23:42 UTC
Now let me do a targeted search for any remaining COMMITs in the file and verify the full function structure of `profe_crm_process_tags`:
Tool2026-06-03 23:42 UTC
{"total_count": 50, "matches": [{"path": "/root/profe-archived-reports/pre-profe-sync-backup.sql", "line": 59, "content": "SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, @@AUTOCOMMIT=0;"}, {"path": "/root/profe-archived-reports/pre-profe-sync-backup.sql", "line": 79, "content": "COMMIT;"}, {"path": "/root/profe-...
Tool2026-06-03 23:42 UTC
{"total_count": 0}
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "Table\tNon_unique\tKey_name\tSeq_in_index\tColumn_name\tCollation\tCardinality\tSub_part\tPacked\tNull\tIndex_type\tComment\tIndex_comment\tVisible\tExpression\nprofe_crm\t0\tPRIMARY\t1\tid\tA\t0\tNULL\tNULL\t\tBTREE\t\t\tYES\tNULL\nprofe_crm\t0\tidx_user_tag_unique\t1\tuser_id\tA\t0\tNU...
Donna2026-06-03 23:42 UTC
Tool2026-06-03 23:42 UTC
{"output": "", "exit_code": 0, "error": null}
Tool2026-06-03 23:42 UTC
{"output": "Table\tCreate Table\nprofe_crm\tCREATE TABLE `profe_crm` (\\n `id` bigint NOT NULL AUTO_INCREMENT,\\n `user_id` bigint NOT NULL,\\n `tag` varchar(100) NOT NULL,\\n `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\\n `processed` tinyint(1) NOT NULL DEFAULT '0',\\n PRIMARY K...
Donna2026-06-03 23:42 UTC
Now I have all the data needed. Let me verify one final thing — check the `AUTO_INCREMENT` of profe_crm confirms the test row was deleted: The `AUTO_INCREMENT=2` confirms a row was inserted (id=1) and then deleted. That matches the cleanup story: the invalid "test_membership" row is gone. --- ## Final Read-Only Review Report: `profe-sync.php` ### ✅ What Was Fixed — Verified Clean **1. Orphaned COMMITs — ALL REMOVED** Searched the live file on disk via `docker exec`. Zero occurrences of `COMMIT` or `ROLLBACK` in profe-sync.php. The 5 orphaned COMMIT statements (including the crash bugs in `profe_schedule_crons()` and `profe_sync_on_register()`) are gone. Verified by grep against the local repo copy as well — COMMITs only exist in the archived SQL backup, not in the active PHP. **2. Test Row Cleanup — profe_crm TABLE EMPTY** `SELECT COUNT(*) FROM profe_main.profe_crm` returns **0 rows**. The row with invalid tag "test_membership" has been deleted. The AUTO_INCREMENT = 2 confirms id=1 was consumed and removed. ### ✅ What's Correct **3. Transaction Order is Sound** `START TRANSACTION` precedes `SELECT ... FOR UPDATE SKIP LOCKED` in `profe_crm_process_tags()`. This is the correct ordering — the transaction must be started before the locking SELECT. **4. Unique Index on profe_crm** UNIQUE KEY `idx_user_tag_unique` on `(user_id, tag)` exists. The `INSERT IGNORE` + `rows_affected === 0` fallback-to-UPDATE logic in `profe_crm_log_membership()` is correct for resetting `processed=0` on re-apply. **5. End-to-End Flow is Sound** - PMPro checkout → `pmpro_after_change_membership_level` fires - `profe_sync_pmp_level` (priority 10): updates `profe_users.membership_level` - `profe_crm_log_membership` (priority 20): inserts tag row into `profe_crm` - `profe_crm_process_tags` (on `init`, priority 100): reads unprocessed rows, detaches old membership tags, attaches new one **6. No Undefined Variables** All functions properly initialize their variables (`$profe_db` via `profe_get_db()`, `$uuid` via `profe_get_uuid_for_user()` or `profe_ensure_user_row()`). No obvious undefined variable warnings. **7. 14-Level Membership Mapping Complete** `profe_mem_levels` has all 14 rows properly mapped. `profe_map_membership_slug()` covers direct lookup and substring fallback. ### ⚠️ Critical Issue Found: Missing COMMIT in `profe_crm_process_tags()` **Location:** `/var/www/html/wp-content/mu-plugins/profe-sync.php`, function `profe_crm_process_tags()`, lines ~250-280. **Problem:** `START TRANSACTION` is issued but there is **no matching `COMMIT`** (or `ROLLBACK`) anywhere in the function. ```php $profe_db->query("START TRANSACTION"); $rows = $profe_db->get_results("SELECT * FROM profe_crm WHERE processed = 0 ORDER BY id ASC LIMIT 50 FOR UPDATE SKIP LOCKED"); if (empty($rows)) { // <-- returns here without ROLLBACK return; } foreach ($rows as $row) { // ... FluentCRM operations ... $profe_db->query($profe_db->prepare( "UPDATE profe_crm SET processed = 1 WHERE id = %d", $row->id )); } // <-- function ends without COMMIT ``` **Impact:** 1. **No-rows path:** `START TRANSACTION` is opened, `SELECT ... FOR UPDATE` returns empty, function returns. Transaction stays open until PHP script ends — wasted transaction resources on every page load. 2. **Success path:** The `UPDATE profe_crm SET processed = 1` runs inside the transaction, but MySQL **auto-rolls back** uncommitted transactions when the connection closes. Since PHP closes the MySQL connection at script end, the UPDATE is **rolled back**, meaning `processed` stays 0. The same rows would be reprocessed on every page load — FluentCRM tags would be re-applied each time (which is idempotent since it's detach + attach, but wasteful and the `profe_crm` table never makes progress). ### ⚠️ Minor Issue: Test User Still Exists `profe_users` and `wp_users` both contain a test user: - **user_id=2**, login=`testsync`, email=`tester@test.com` - `membership_level = NULL` (no PMP level) This is leftover test data that should be removed before production deploy. The deleted "test_membership" row from profe_crm likely belonged to this user. ### Summary | Check | Status | |---|---| | Orphaned COMMITs removed | ✅ Pass | | profe_crm test data clean | ✅ Pass (0 rows) | | START TRANSACTION before SELECT...FOR UPDATE | ✅ Pass | | No undefined variables | ✅ Pass | | Full flow makes sense | ✅ Pass | | Unique index on (user_id, tag) | ✅ Pass | | 14 membership levels populated | ✅ Pass | | Missing COMMIT after START TRANSACTION | ⚠️ **FAIL — Critical** | | Test user "testsync" still in DB | ⚠️ Needs pre-deploy cleanup | **Recommendation:** Fix the missing COMMIT in `profe_crm_process_tags()` before production deploy. Add `$profe_db->query("COMMIT");` after the foreach loop, and `$profe_db->query("ROLLBACK");` in the empty-rows early return path. Also remove the testsync test user from both `wp_users` and `profe_users`.