From c0929be3ceb7f04529d20f40ab589f7d25c13852 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Fri, 12 Jun 2026 14:05:09 +0000 Subject: [PATCH] fix(assembler): add prompt_version/agent_role to amortize SELECT; fix test mock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The amortize_research_costs() SELECT was missing prompt_version and agent_role — the two fields added in the INSERT as part of the v0.19.4 pv/role fix. PHP 8.x treats accessing an undefined property on stdClass as E_WARNING; PHPUnit converts warnings to exceptions, which the reap() try/catch captures as 'DB error', leaving reaped=0 and breaking ResearchReaperTest on all 3 PHP versions. Fix: extend the SELECT column list to include the two new fields so $research_row has them populated. Update the ResearchReaperTest get_row mock to return prompt_version and agent_role from fixtures (defaults null/''). Agent-Session: engineer-prab-maint-fix-20260612 --- includes/core/class-post-assembler.php | 2 +- tests/unit/Core/ResearchReaperTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/core/class-post-assembler.php b/includes/core/class-post-assembler.php index 4239504..6e299e8 100644 --- a/includes/core/class-post-assembler.php +++ b/includes/core/class-post-assembler.php @@ -111,7 +111,7 @@ class PRAutoBlogger_Post_Assembler { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery $research_row = $wpdb->get_row( $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared - "SELECT id, estimated_cost, provider, model, prompt_tokens, completion_tokens + "SELECT id, estimated_cost, provider, model, prompt_tokens, completion_tokens, prompt_version, agent_role FROM {$table} WHERE run_id = %s AND stage = 'llm_research' AND post_id IS NULL LIMIT 1", diff --git a/tests/unit/Core/ResearchReaperTest.php b/tests/unit/Core/ResearchReaperTest.php index e97a973..0b18299 100644 --- a/tests/unit/Core/ResearchReaperTest.php +++ b/tests/unit/Core/ResearchReaperTest.php @@ -110,6 +110,8 @@ class ResearchReaperTest extends BaseTestCase { 'model' => $o->model ?? 'gemini-flash', 'prompt_tokens' => $o->prompt_tokens ?? 1000, 'completion_tokens' => $o->completion_tokens ?? 500, + 'prompt_version' => $o->prompt_version ?? null, + 'agent_role' => $o->agent_role ?? '', ]; } }