Skip to content

fix(queue): restore background processing refactor lost in Phase 1 merge#1656

Merged
jakejackson1 merged 1 commit into
developmentfrom
chore/restore-queue-refactor
May 18, 2026
Merged

fix(queue): restore background processing refactor lost in Phase 1 merge#1656
jakejackson1 merged 1 commit into
developmentfrom
chore/restore-queue-refactor

Conversation

@jakejackson1

Copy link
Copy Markdown
Member

Summary

Phase 2 of the hot-patch ↔ development reconciliation. Phase 1 (#1655) merged hot-patch's bootstrap-level queue wiring (`GF_Background_Process` loader, queue-toggle cleanup hook, 4-arg `Controller_Pdf_Queue` construction) but the auto-merge took dev's copies of `Controller_Pdf_Queue`, `Queue_Callbacks`, and `Test_Controller_Pdf_Queue` — leaving the controller's constructor silently dropping its `Helper_Form` dependency and discarding the substantive changes from four hot-patch commits.

This commit re-applies those four commits' intent on top of dev's queue baseline:

Commit What it brought back
`dc772da0` GF 2.9.7/2.9.8 background-processing library compatibility (mostly already merged via bootstrap.php; `gfpdf_override_pdf_bypass=false` wrapper restored to `Queue_Callbacks::create_pdf`)
`8a7914dd` Convert mini-queues to individual queue items; drop `'unrecoverable' => true` so one failure doesn't block other PDFs/notifications
`389ae6ce` Queue cleanup on toggle (already landed in Phase 1 via `gfpdf_settings_sanitize` hook in bootstrap.php)
`3fe1c1e7` Use the correct entry on resend; dedupe identical PDFs. Adds `Helper_Form` to `Controller_Pdf_Queue`, groups async notifications by `[formId][entryId]`, fans out resend over each pair, looks up form/entry fresh from the DB

`Helper_Pdf_Queue.php` is identical between dev and hot-patch already (retry budget = 1), so no changes there.

Dev's intent preserved

  • `get_current_user_id()` is carried as an arg to `Queue_Callbacks::create_pdf` / `send_notification` so dev's `{user}` merge-tag masquerade keeps working when queues run later.
  • `queue_cleanup_task()` + `Queue_Callbacks::cleanup_pdfs()` stay deprecated per dev's 6.12 caching-layer + hourly WP-Cron auto-purge direction. The cleanup queue entries hot-patch's controller used to push are no longer scheduled, and the tests assert the reduced queue size.

Test plan

  • `composer phpcs:lint` — clean
  • `yarn lint:js` — clean
  • `yarn test:php` — 1119 tests, 4088 assertions, 8 skipped, 0 failures
  • `yarn test:php --filter Test_Controller_Pdf_Queue` — 9 tests, 34 assertions
  • CI: PHPUnit (`run-tests` label applied)
  • CI: Coding standards
  • CI: Playwright e2e

🤖 Generated with Claude Code

Phase 1 (#1655) carried the bootstrap-level pieces of hot-patch's
queue work (GF_Background_Process loader, gfpdf_settings_sanitize
queue-toggle hook, 4-arg Controller_Pdf_Queue construction) but the
auto-merge took dev's copy of Controller_Pdf_Queue / Queue_Callbacks /
Test_Controller_Pdf_Queue. That left the controller's constructor
silently dropping its $form dependency and discarded the substantive
changes from four hot-patch commits:

  dc772da  Update Background Processing Queue (GF 2.9.7/2.9.8 compat)
  8a7914d  Convert mini-queues to individual queue items; drop
            'unrecoverable' flag; retry from 3 -> 1
  389ae6c  Add queue cleanup when Background Processing toggled
  3fe1c1e  Use the correct entry on resend; dedupe identical PDFs

This commit re-applies those four commits' intent on top of dev's
queue baseline:

* Controller_Pdf_Queue
  - Accept Helper_Form via the 4th constructor arg (matches the call
    site already in bootstrap.php).
  - Group $form_async_notifications by [formId][entryId] so resend
    iteration can re-fetch fresh form/entry data from the DB instead
    of using stale request-time arrays.
  - queue_dispatch_resend_notification_tasks() now ignores legacy
    $form/$entry params, fans out per form+entry pair, and dispatches
    once at the end.
  - dispatch_queue is hooked separately on gform_after_submission
    priority 100 (instead of inline from queue_async_form_submission_tasks),
    so the resend path can reuse the same dispatch hook.
  - queue_async_tasks pushes one task per queue item (forwards compat
    with the new GF library).
  - Drop 'unrecoverable' => true so a single failure doesn't block
    other PDFs/notifications.
  - args carry get_current_user_id() so dev's {user} merge-tag
    masquerade keeps working.

* Queue_Callbacks::create_pdf
  - Wrap GPDFAPI::create_pdf() with gfpdf_override_pdf_bypass=false so
    a queued PDF generates even if the request-time bypass filter
    would normally short-circuit it.

* queue_cleanup_task / Queue_Callbacks::cleanup_pdfs stay deprecated
  per dev's caching-layer + auto-purge direction (6.12). The cleanup
  queue entries that hot-patch's controller used to push are no
  longer scheduled, and the tests assert the reduced queue size.

Helper_Pdf_Queue.php is identical between dev and hot-patch already
(retry budget = 1, etc.) so no changes are needed there.

Verified locally:
* composer phpcs:lint -- clean
* yarn lint:js -- clean
* yarn test:php (1119 tests, 4088 assertions) -- all pass

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.85%. Comparing base (a88359f) to head (46f8500).
⚠️ Report is 3 commits behind head on development.

Additional details and impacted files
@@             Coverage Diff              @@
##           development    #1656   +/-   ##
============================================
  Coverage        92.85%   92.85%           
============================================
  Files               58       58           
  Lines             1511     1511           
  Branches           419      419           
============================================
  Hits              1403     1403           
  Misses             103      103           
  Partials             5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jakejackson1 jakejackson1 merged commit a9d9b5c into development May 18, 2026
22 of 43 checks passed
@jakejackson1 jakejackson1 deleted the chore/restore-queue-refactor branch May 18, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant