Skip to content

v4.5.2 — Back-sync reliability, cron hardening, and code audit fixes

Latest

Choose a tag to compare

@jaig-eye jaig-eye released this 11 Mar 14:59

What's changed

Back-sync reliability

  • Batch completeness — has_more was computed from the pre-batch backlog count, so a full batch of N posts always returned has_more: false. It now uses the post-batch recount, so partially-failed batches correctly trigger the next run.
  • Duplicate prevention — before creating a new GHL record, the engine runs a pre-flight dedup check against the cached record list. If a record with the same title already exists (e.g. from a previous partial push where the ID was never saved back), the post is linked to the existing record instead of creating a duplicate.
  • GHL eventual-consistency — if GHL's create response doesn't include the record ID in the expected shape, the fallback title-search now waits 0.8 s before querying, giving GHL time to index the new record. Added records[0].id as an additional fallback ID path to cover more response shapes.
  • Back-sync cron — ghl_scheduled_back_sync now fires automatically on the same user-configured interval as the forward sync (offset +30 s to avoid API contention). Each fire processes one batch; the backlog shrinks naturally over time with no offset tracking needed.
  • Progress bar — manual back-sync runs show a live progress bar that caps at 99% until the final batch completes, then snaps to 100% with a "Done" label and final counts.

Cron self-healing

  • CronManager::maybe_reschedule() is now hooked to init (every request, including frontend) instead of admin_init. The scheduled sync can no longer silently die after a WordPress core update or site migration without any admin visit.

PHP compatibility

  • Removed ini_get('safe_mode') (removed in PHP 7.0). set_time_limit() is now called directly.

Taxonomy slug normalisation

  • GHL slugs use underscores; WordPress uses dashes. A & in a category name produces double-underscores in GHL (e.g. bed_covers__tonneau_toppers). The sync engine now normalises these before lookup so existing WP terms are matched correctly instead of creating duplicates.

Code audit fixes

  • ghl_sync_origin_migrated_v1 was written by the origin-migration routine but never cleaned up on uninstall. Added to GithubUpdater::ALL_OPTIONS and uninstall.php.
  • ghl_sync_taxonomy_slug was removed from plugin settings in v4.5.0 but remained listed in uninstall.php. Removed.
  • update_post_meta( $post_id, 'category', … ) in sync_taxonomy() used the reserved WordPress meta key category and stored a value never read back. Removed.

Other fixes

  • ghl_sync_cron_offset and ghl_scheduled_back_sync were not cleared on uninstall/wipe. Both are now removed by wipe_plugin_data() and uninstall.php.

Full changelog: v4.5.0...v4.5.2