fix: postmeta tracking on synchronous AVIF + add reconcile-meta (v0.2.2)
Two improvements after v0.2.1 deploy revealed the avif_status bug wasn't fully fixed: Fix: Format_Generator::make_avif() now calls record_avif_outcome() at the end of the synchronous path. Previously only the cron path recorded outcomes, so wp h4b-img generate-missing-siblings (synchronous) left 4067 stale 'queued' rows even though it successfully generated 603 AVIFs on disk. process_avif_job() simplified to a thin wrapper around make_avif(avif_async=false). Added: wp h4b-img reconcile-meta — walks _h4b_img_optim postmeta, checks for .webp / .avif files on disk, and updates avif_status / webp size fields to match reality. One-shot reconciliation for stale records left by earlier plugin versions. --dry-run supported. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -115,11 +115,15 @@ final class Format_Generator {
|
||||
return $res;
|
||||
}
|
||||
|
||||
return self::encode_avif_now( $source, $settings );
|
||||
// Synchronous path: encode + record outcome in attachment postmeta.
|
||||
$result = self::encode_avif_now( $source, $settings );
|
||||
self::record_avif_outcome( $source, $result );
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cron entry point — encodes one queued path and updates per-attachment meta.
|
||||
* Cron entry point — encodes one queued path. Recording happens inside
|
||||
* make_avif() now, so this is a thin wrapper that forces synchronous mode.
|
||||
*/
|
||||
public static function process_avif_job( string $source ): void {
|
||||
if ( ! is_readable( $source ) ) {
|
||||
@@ -127,8 +131,8 @@ final class Format_Generator {
|
||||
return;
|
||||
}
|
||||
$settings = Settings::all();
|
||||
$result = self::encode_avif_now( $source, $settings );
|
||||
self::record_avif_outcome( $source, $result );
|
||||
$settings['avif_async'] = false; // we ARE the queue handler — never re-queue
|
||||
self::make_avif( $source, $settings );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user