fix: add missing cost tracker methods + guard logger against null wpdb
- Add `would_exceed_budget(float)` to pre-check budget before API calls - Add `log_image_generation()` for image pipeline cost logging - Guard Logger::log() against null $wpdb in unit test environments - Both methods called by image pipeline (commit 1b) but were missing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -126,6 +126,11 @@ class PRAutoBlogger_Logger {
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
if ( null === $wpdb ) {
|
||||
// No database available (unit test environment). PHP error_log
|
||||
// was already called above for warnings/errors; silently skip DB write.
|
||||
return;
|
||||
}
|
||||
$table = $wpdb->prefix . 'prautoblogger_event_log';
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||
|
||||
Reference in New Issue
Block a user