Skip to content

feat: delete removed sites' records in the background - #366

Merged
justlevine merged 1 commit into
feat/action-scheduler-jobsfrom
feat/background-purge
Oct 29, 2026
Merged

justlevine merged 1 commit into
feat/action-scheduler-jobsfrom
feat/background-purge

Conversation

@justlevine

@justlevine justlevine commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

What

Removing a brand site now deletes its Algolia records in a background job. If the delete fails, it shows on the settings screen.

Why

On main, removing a brand site deleted its records inside the request. If Algolia failed, the error only went to the log, and the removed site's content stayed in search.

Related Issue(s):

How

  • Delete_Site_Records_Job deletes one removed site's records. A failed delete shows on the governing site's row, since the removed site is no longer listed.
  • A re-index on the governing site retries failed deletes.
  • A site that's added back forgets its delete, so a delete that's still waiting stops instead of wiping the site's new records.

AI Disclosure

Opus 5.5. wrote the tests and drafted the PR description

Testing Instructions

  1. Set up a governing site and a brand site, and connect them.
  2. Remove the brand site. Once the job runs, its records are gone from Algolia, and so are its other jobs.
  3. Make Algolia fail (e.g. bad credentials), remove a brand site, and run the jobs. The governing site shows that search may still have the removed site's content. Fix Algolia and re-index, and the delete runs again.
  4. Add the removed brand site back. Its failed delete no longer shows.

Screenshots

Additional Info

  • A brand site that disconnects itself no longer waits for the governing site to delete its records, so its request drops the 15 second timeout it had for that.
  • Switching a governing site to a brand site forgets the deletes along with the index.

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • I have added necessary tests to cover my changes.
  • I have updated the project documentation as needed.
  • My code has detailed inline documentation.
  • My code is tested to the best of my abilities.
  • My code passes all lints, tests, and checks.
Open WordPress Playground Preview

@justlevine
justlevine added this pull request to stack #367 October 26, 2026 20:54
@justlevine
justlevine requested review from Utsav-Ladani and up1512001 and a balanced review from Copilot October 26, 2026 20:54
@codecov-commenter

codecov-commenter commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.81%. Comparing base (a091b67) to head (20041ba).

Files with missing lines Patch % Lines
...nc/Modules/Search/Jobs/Delete_Site_Records_Job.php 83.33% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                        @@
##             feat/action-scheduler-jobs     #366      +/-   ##
================================================================
- Coverage                         88.83%   88.81%   -0.02%     
- Complexity                          838      847       +9     
================================================================
  Files                                48       49       +1     
  Lines                              3270     3291      +21     
  Branches                            181      182       +1     
================================================================
+ Hits                               2905     2923      +18     
- Misses                              308      311       +3     
  Partials                             57       57              
Flag Coverage Δ
unit 89.66% <88.46%> (-0.05%) ⬇️
vitest 85.16% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
assets/src/components/JobStatus.tsx 100.00% <100.00%> (ø)
inc/Modules/Rest/Indexer_Controller.php 99.09% <100.00%> (+<0.01%) ⬆️
inc/Modules/Rest/Remote_Client.php 87.76% <100.00%> (-0.06%) ⬇️
inc/Modules/Search/Jobs/Jobs.php 0.00% <ø> (ø)
inc/Modules/Search/Settings.php 98.32% <100.00%> (ø)
...nc/Modules/Search/Jobs/Delete_Site_Records_Job.php 83.33% <83.33%> (ø)
🚀 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Status polling and the setup gate can prevent administrators from discovering or retrying failed deletions.

2 open issues
What changed in this PR

Moves removed brand sites’ Algolia record deletion into background jobs, with failure reporting and retries through the governing site’s search settings.

Changes:

  • Adds a deletion job and retries failed deletions during re-indexing.
  • Clears deletion records when sites are re-added or the governing site becomes a consumer.
  • Adds failure messaging and integration coverage, and removes the extended deregistration timeout.
File Description
tests/​phpunit/​Integration/​Modules/​Search/​SettingsTest.php Covers background deletion and job cleanup.
tests/​phpunit/​Integration/​Modules/​Search/​Jobs/​Delete_Site_Records_JobTest.php Tests deletion failures, reporting, and retries.
tests/​phpunit/​Integration/​Modules/​Rest/​Remote_ClientTest.php Removes the extended-timeout assertion.
tests/​phpunit/​Integration/​Modules/​Rest/​Indexer_Controller_GoverningSiteTest.php Tests retrying failed deletions during re-indexing.
tests/​phpunit/​Integration/​Modules/​Rest/​Brand_Site_Controller_GoverningSiteTest.php Verifies background cleanup after deregistration.
tests/​js/​IndexStatus.test.tsx Tests deletion failure messaging and hidden progress.
inc/​Modules/​Search/​Settings.php Queues deletions and clears obsolete job records.
inc/​Modules/​Search/​Jobs/​Jobs.php Registers the deletion job.
inc/​Modules/​Search/​Jobs/​Delete_Site_Records_Job.php Implements background deletion, failure reporting, and retries.
inc/​Modules/​Rest/​Remote_Client.php Removes the extended deregistration timeout.
inc/​Modules/​Rest/​Indexer_Controller.php Retries failed deletions during governing-site re-indexing.
assets/​src/​components/​JobStatus.tsx Displays deletion failure and recovery guidance.

Review effort: Balanced

Comment thread assets/src/components/JobStatus.tsx
Comment thread inc/Modules/Search/Jobs/Delete_Site_Records_Job.php
@justlevine
justlevine force-pushed the feat/background-purge branch from 28ae6ea to 462c8db Compare October 28, 2026 13:56
@justlevine
justlevine merged commit 52b16b4 into main Oct 29, 2026
18 checks passed
@justlevine
justlevine deleted the feat/background-purge branch October 29, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants