fix: wire Image B source data — was hardcoded null, never generated
Root cause: both attach_generated_images() in post-assembler and the retroactive handler in executor passed null as source_data to the image pipeline. The pipeline's Image B branch requires non-null source_data to fire, so Image B was silently skipped on every article since the feature was built. Fix: added get_source_data_for_image() to Source_Collector to retrieve the original Reddit post title/content by source_ids. Post-assembler now pulls source_ids from the Article_Idea; executor pulls them from the _prautoblogger_source_ids post meta saved by the publisher. Also added a regression test proving Image B is skipped when source_data is null, so this handoff gap will be caught if re-introduced. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -135,13 +135,26 @@ class PRAutoBlogger_Executor {
|
||||
'post_content' => $post->post_content,
|
||||
];
|
||||
|
||||
$result = $pipeline->generate_and_attach_images( $post_id, $article_data, null );
|
||||
// Retrieve original source IDs from post meta so Image B can generate
|
||||
// a source-driven prompt even on retroactive regeneration.
|
||||
$source_ids_json = get_post_meta( $post_id, '_prautoblogger_source_ids', true );
|
||||
$source_ids = is_string( $source_ids_json ) ? json_decode( $source_ids_json, true ) : [];
|
||||
$source_data = ( new PRAutoBlogger_Source_Collector() )->get_source_data_for_image(
|
||||
is_array( $source_ids ) ? array_map( 'absint', $source_ids ) : []
|
||||
);
|
||||
|
||||
$result = $pipeline->generate_and_attach_images( $post_id, $article_data, $source_data );
|
||||
|
||||
// Set featured image if Image A was generated.
|
||||
if ( ! empty( $result['image_a_id'] ) ) {
|
||||
set_post_thumbnail( $post_id, $result['image_a_id'] );
|
||||
}
|
||||
|
||||
// Store Image B in post meta if generated.
|
||||
if ( ! empty( $result['image_b_id'] ) ) {
|
||||
update_post_meta( $post_id, '_prautoblogger_image_b_id', $result['image_b_id'] );
|
||||
}
|
||||
|
||||
wp_send_json_success( $result );
|
||||
} catch ( \Exception $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error(
|
||||
|
||||
Reference in New Issue
Block a user