Three bugs in test_sync_success_caches_and_returns_models:
1. Mock data lacked taskType=imageInference so normalize_models() filtered
everything out → sync() returned false (empty result).
2. wp_remote_retrieve_response_code and wp_remote_retrieve_body not mocked
→ Brain\Monkey MissingFunctionExpectations.
3. is_wp_error not mocked.
4. get_option/update_option used separate static stores so update_option
write was invisible to the subsequent get_option in get_models().
RunwareModelCatalogTest mocks time() via Patchwork/Brain\Monkey. Without
declaring it in redefinable-internals, Patchwork throws NotUserDefined
on every test in that suite (18 failures).
get_models() now delegates to PRAutoBlogger_Runware_Model_Catalog which
calls get_option() to check WP cache. Brain\Monkey threw MissingFunction
Expectations on all registry tests. Added setUp() stub: get_option returns
false (no cache) so catalog falls back to hardcoded list; update_option
stubbed to prevent side-effect errors.
Orphaned array entry for runware_catalog_sync field was placed after the
closing ); of the fields array instead of inside it. PHP parse error on
line 268. Moved entry to correct position inside the array.
Replace hardcoded model registry with live-sync system.
New PRAutoBlogger_Runware_Model_Catalog class fetches the Runware model
catalog daily, caches in WP options (24h TTL), and falls back to the
hardcoded 15-model list if the API is unavailable. Sync Now button
in PRAdmin for on-demand refresh. Eliminates the drift that caused
silent model fallback bugs (v0.13.8, v0.14.0).
All Runware model selections except schnell and dev were silently falling
back to runware:100@1 because COST_PER_IMAGE only had 2 entries while the
image model registry was expanded to 15 models in v0.13.8.
Fix: add all 15 model IDs to COST_PER_IMAGE and DEFAULT_STEPS.
applySort() always read input_price_per_m for price sorting, but image
models carry cost_per_image instead — input_price_per_m is undefined on
them, so every image model got an effective price of 0 and the sort was a
no-op.
Fix: detect image models via cost_per_image !== undefined and use that
field when present; fall back to input_price_per_m for text models.
Files changed:
- assets/js/model-picker.js — applySort price branch
- prautoblogger.php — version bump 0.13.8 → 0.13.9
- CHANGELOG.md — release notes
35% title + 255px fixed PRAB cols left ~50px per auto column.
Replace with a balanced budget across all columns so Author,
Categories, Tags, and Date all get enough room to render horizontally:
title 22%, author 6%, categories 7%, tags 9%, date 8%,
writing_model/image_model 85px each, cost 50px, peptide_topics 75px
table-layout: fixed ignores min-width — the WP posts list table uses
fixed layout so min-width: 80px had no effect. Changed to width: 80px
which is honoured under fixed-layout tables.
Two bugs in class-post-list-columns.php:
1. Cost always showed $0.00: a PHP '// phpcs:ignore' comment was
placed inside the SQL string literal, causing MariaDB syntax error
on every render_cost_cell() query. Moved comment to the line above
wpdb->prepare() where it belongs.
2. Peptide Topics column header compressed to near-zero width by the
three fixed-width PRAB columns (Writing Model + Image Model + Cost =
255px). Added min-width: 80px to .column-taxonomy-peptide_topic so
the header renders horizontally.
Root cause: .ab-mp-price and .ab-mp-ctx were siblings in .ab-mp-row-meta
with price first. Description text is variable-length, so the meta div
grew/shrank per row, shifting the price left/right.
Fix:
- Move price to last child in .ab-mp-row-meta so its right edge is
always pinned to the row's fixed right edge
- Add flex-shrink: 0 to .ab-mp-price so it never compresses
- Cap .ab-mp-ctx at max-width 200px with text-overflow: ellipsis
- Swap column header order (Context, then Price) to match new DOM order
.ab-mp-col-price was missing min-width and right-alignment even though
.ab-mp-price had both. The header sat left while values sat right,
so they didn't track the same column edge. Added min-width: 90px and
justify-content: flex-end to match.
- Add .ab-mp-col-headers bar between search and list with three
clickable column headers: Model (sorts by name), Price in/out
(sorts by input_price_per_m), Context (sorts by context_length)
- Track sortState at module level so preference persists across
open/close; clicking same column toggles asc/desc
- Deprecated models always sink to bottom regardless of sort column
- Add CSS for .ab-mp-col-headers, .ab-mp-col-header, .ab-mp-sort-arrow,
.ab-mp-col-active; widths mirror existing row flex layout so columns
visually align with data
Bumps version 0.13.1 → 0.13.2
Add min-width: 90px and text-align: right to .ab-mp-price so prices
like $0.0006/image and $0.0800/image stack on a consistent right edge
instead of floating at uneven offsets.
class-autoloader.php listed services/ but not services/opik/. All four Opik classes live in that subdirectory. Composer classmap covered it (tests passed); WP runtime autoloader would fatal in production on first Opik class reference. Adds services/opik/ to the scan list. Bumps to v0.12.3.
Opik requires version 7 UUIDs. wp_generate_uuid4() was producing v4
which the API rejected with 422. Replaced both call sites in
class-opik-trace-context.php with generate_uuid7(), a private static
method implementing RFC 9562 §5.7.
Fixes: smoke test 422 {"errors":["Trace id must be a version 7 UUID"]}
Dynamic table names ({}, {}) are used in
database queries and cannot be parameterized with $wpdb->prepare() which only
supports value placeholders, not table-name placeholders.
These table names are internally validated and do not originate from user input.
Excluding WordPress.DB.PreparedSQL.InterpolatedNotPrepared from the ruleset.
Created phpcs.xml ruleset that inherits from WordPress-Core but excludes
WordPress.Files.FileName.InvalidClassFileName sniff. This is an architectural
choice: PRAutoBlogger uses short class names (class-logger.php) instead of
fully-qualified names (class-prautoblogger-logger.php) for better readability.
Updated CI workflow to use phpcs.xml instead of --standard=WordPress-Core.
Remaining violations (56 wpdb + 2 docblock) are still addressed with inline
phpcs:ignore pragmas with documented reasons.
File-level sniffs like WordPress.Files.FileName are evaluated at the file level,
not at code level. They require phpcs:ignore directives to be placed within the
file-level docblock (/** ... */), not in code comments.
Moved all 81 phpcs:ignore pragmas from code comments to the file-level docblocks.
This applies to:
- 79 class files with class-naming convention ignores
- prautoblogger.php with strict-types docblock ignore
- uninstall.php with strict-types docblock ignore
- PRAUTOBLOGGER_VERSION constant now matches header (0.10.1)
- CHANGELOG.md updated to accurately reflect Round 3 work:
* OpenRouter test encryption fix (real class round-trip)
* 137 PHPCS violations resolved with targeted ignores + reasons
* Clear accounting of which categories of violations and why ignored
- Added phpcs:ignore for class file naming convention (79 violations)
WordPress.Files.FileName.InvalidClassFileName is a known architectural
issue — class files use short names without prautoblogger- prefix
- Added phpcs:ignore for ->prepare() table interpolation (56 violations)
WordPress.DB.PreparedSQL.InterpolatedNotPrepared: dynamic table names
(prab_generation_logs, prab_cost_logs) require interpolation; ->prepare()
does not support table name placeholders, only column values
- Fixed file-level docblock positioning (2 violations)
prautoblogger.php and uninstall.php: moved declare(strict_types=1) before
file docblock per PHP best practices
Adds missing wp_salt() and wp_generate_uuid4() stubs to BaseTestCase::setUp()
so tests that call PRAutoBlogger_Encryption (for API key decryption) don't fail.
Fixes PublisherTest::test_publish_links_generation_logs_by_run_id() which was
capturing the wrong database query (SELECT from SourceCollector) due to test
fixture including source_ids. Now creates a fixture override without source_ids
to isolate the run_id linking assertion.
Related: Failures #1 and #2 from PR #109.
Bump version: 0.10.0 → 0.10.1
Updated CHANGELOG.md with Fixed/Changed entries:
- Missing post_type_exists() stub in BaseTestCase
- PHPCS autofix of 1,362 violations across 75 files
- CI gate flipped to strict mode
Updated ARCHITECTURE.md with ADR #20 documenting the test infra
and PHPCS compliance improvements.
Change continue-on-error from true to false for the PHPCS check.
Now that all 1,362 violations are fixed via phpcbf, PHPCS failures
will block CI. This prevents regression of style standards.
Run phpcbf --standard=WordPress-Core across includes/, prautoblogger.php,
and uninstall.php. Fixed 1,362 formatting violations in 75 files:
- Short array syntax: [] → array()
- Line breaking for long function calls
- Consistent indentation
- Function call parameter alignment
No logic changes; purely mechanical formatting.
When PR Core is not active, PeptideLinker guards calls with post_type_exists().
This stub was missing from base setup, causing 8 PublisherTest errors.
Adds Functions\when('post_type_exists')->justReturn(false) to setUp().
When a PR modifies the admin settings surface, file/class structure, or data flow, the QA reviewer now flags the PR as a MAJOR concern unless the PR description references an accompanying update to the CTO app-map at `Peptide Repo CTO/app-maps/<repo-slug>.md`.
The CTO workspace is a separate repo, so CI cannot verify the doc update mechanically — the reviewer inspects the PR description for an explicit mention.
Why: the CTO-level app-maps are the single-pane-of-glass reference that lets the CTO answer questions like 'which settings does this plugin expose?' without grepping the repo each time. Without a merge-gate prompt, these maps drift out of sync with the code.
Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
On v0.9.0 this constant was implicitly defined by CloudflareImageProviderTest::setUp()
— deleted in this PR. OpenRouterImagePricingTest relied on PHPUnit's alphabetical
file order (C before O) to have the constant defined before its assertion.
Deleting the CF test broke that chain; OR pricing test errored with 'Undefined
constant "PRAutoBlogger\\Tests\\Providers\\PRAUTOBLOGGER_DEFAULT_IMAGE_MODEL"'.
Fix: hoist the define into tests/bootstrap.php alongside the other
PRAUTOBLOGGER_DEFAULT_* constants. No test ordering dependency remains.
The set_default_options() block was still seeding the dead CF Workers AI gateway
toggle on fresh activations. Removed alongside its settings field + migration
delete-sweep so uninstall → install cycles stop re-adding the option.
Residual from commit 21430ce. Caught in local verification before PR open.
- prautoblogger.php: plugin header Version + PRAUTOBLOGGER_VERSION
- CHANGELOG.md: Removed/Changed/Note/Cost impact/Migration sections
- ARCHITECTURE.md:
- drop 4 CF provider files from the file tree
- drop 2 CF credential options from the wp_options table
- drop CF Workers AI row from the External API Integrations table
- flip Phase 3 placeholder from CF Workers AI registry to Runware
- supersede ADR #16 with a one-line history note pointing at v0.10.0
- update ADR #17 tail to mention the removal
readme.txt stable tag is stale (0.2.2) and clearly not maintained
inline with real releases — leaving alone in this PR; fix belongs in
a dedicated release-process cleanup.
New class PRAutoBlogger_Migrate_Remove_Cloudflare_V0100 (own file so
class-activator.php stays under 300 lines). Runs from
PRAutoBlogger::maybe_run_db_migrations() right after the v0.9.0
migration. Idempotent via prautoblogger_migrated_remove_cloudflare_v0100
flag option (picked up by the uninstall prefix sweep).
Migrates any user on a Cloudflare image provider to Runware FLUX.1
schnell (closest equivalent, ~bash.0006/image). Detects the three
shapes a legacy user can be in: registry-derived provider ===
'cloudflare', image_provider option === 'cloudflare', or the legacy
slug 'flux-1-schnell'.
Cleans up three now-dead options: prautoblogger_cloudflare_ai_token,
prautoblogger_cloudflare_account_id, prautoblogger_cf_image_via_gateway.
Does NOT touch prautoblogger_ai_gateway_base_url — that option is
shared with the OpenRouter AI Gateway route and must stay (live-
verified test).
Tests (tests/unit/Core/ActivatorRemoveCloudflareTest.php):
- cloudflare user → runware schnell
- non-cloudflare user preserved
- runware user preserved
- legacy 'flux-1-schnell' slug triggers migration
- second run is a no-op (does not clobber admin manual changes)
- AI Gateway URL preserved across every path
ImageModelRegistryTest updated: allowed-provider set is now
['runware','openrouter']; new test_cloudflare_entries_removed_v0100
test pins the scope boundary.
Wires out the Cloudflare Workers AI image provider across the plugin:
- class-image-pipeline.php: drop 'cloudflare' dispatch branch; Runware
becomes the unrecognised-provider fallback
- class-image-model-registry.php: remove flux-1-schnell/cloudflare row;
update provider-enum docblocks (runware|openrouter only)
- class-settings-fields-extended.php: remove three CF fields
(cloudflare_ai_token, cloudflare_account_id, cf_image_via_gateway);
drop Cloudflare mention from model-picker + NSFW retry descriptions
- class-admin-page.php: remove prautoblogger_cloudflare_ai_token from
the encrypted-options list
- interface-image-provider.php: retarget preamble @see at Runware +
OpenRouter; update get_provider_name() example
- class-image-nsfw-blocked.php: generalise preamble (Runware +
OpenRouter can raise this)
Also cleans stale CF Workers AI mentions in:
class-ajax-handlers.php, interface-model-registry.php,
class-image-nsfw-retry.php, class-open-router-image-pricing.php,
prautoblogger.php.
The Cloudflare AI Gateway path (in class-open-router-config.php,
class-settings-fields.php 'prautoblogger_ai_gateway_base_url',
class-open-router-request-builder.php cache headers) is intentionally
untouched — it fronts OpenRouter and is unrelated to the CF Workers AI
image provider.