fix: avif tracking + new generate-missing-siblings command (v0.2.1)

Two related fixes to the AVIF pipeline:

Fix #1 — postmeta tracking
  Format_Generator::process_avif_job() now updates _h4b_img_optim's
  avif_status from 'queued' → 'done' (with byte size) or 'error' (with
  reason) after the cron job runs. Previously the postmeta said
  'queued' forever even when AVIF files existed on disk.

Fix #2 — root cause of missing AVIFs on rds.ink bulk run
  wp_schedule_single_event(time()+30, …) coalesces identical args at
  the same timestamp, so bulk-queueing hundreds of AVIF jobs in the
  same second silently dropped many. Added wp h4b-img generate-missing-siblings
  that walks attachment metadata, finds files missing .webp/.avif, and
  generates them SYNCHRONOUSLY (no queue, no coalescing). Only processes
  registered sizes by default; --include-orphans flag for disk-walk mode.

Verified on prod rds.ink: 1,134 of 1,737 registered images >=20KB have
AVIF, 603 are missing. Of 389 orphan files >=20KB missing AVIF, those
aren't referenced from any post/postmeta — correctly excluded.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Henk
2026-05-19 14:52:50 +10:00
parent 4cd1390a94
commit 868dbe0ff4
5 changed files with 282 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ final class CLI {
\WP_CLI::add_command( 'h4b-img bulk', CLI_Bulk::class );
\WP_CLI::add_command( 'h4b-img rescue', CLI_Rescue::class );
\WP_CLI::add_command( 'h4b-img migrate-from-smush', CLI_Migrate::class );
\WP_CLI::add_command( 'h4b-img generate-missing-siblings', CLI_Siblings::class );
}
/**