Skip to content

Performance: screen-gate assets, cache hot paths, asset bug fixes#471

Draft
cbravobernal wants to merge 2 commits into
trunkfrom
perf/runtime-asset-safe
Draft

Performance: screen-gate assets, cache hot paths, asset bug fixes#471
cbravobernal wants to merge 2 commits into
trunkfrom
perf/runtime-asset-safe

Conversation

@cbravobernal

@cbravobernal cbravobernal commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Lower-risk half of the performance audit, split out from #466 so it can be reviewed and merged without waiting on multilingual testing. The sibling-field priming (the one change that touches the field-value load path and interacts with WPML/Polylang/ACFML) is in its companion PR. Everything here is behavior-identical or a straight bug fix.

PHP runtime

  • Per-request cache for acf_get_option_meta(), invalidated via core option hooks. Keeps the esc_like() hardening from Use esc_like() when building option-meta LIKE patterns #462 — the cache wraps that query, it does not revert it.
  • Decode each local JSON file once per request instead of 4× (includes/local-json.php): ~44ms → ~16ms at 200 files. The cache lives in a registered store (resettable in tests/long processes), skips missing files, and save_file()/delete_file() call clearstatcache() so same-request re-reads see fresh contents.
  • acf_decode_taxonomy_term(): raw SQL → get_term(), hardened against get_term() returning a truthy WP_Error (ambiguous shared terms / unregistered taxonomies).
  • Blocks save-path early bail when no block types are registered.
  • Enqueue the escaped-html notice assets at render time inside the notice callback (the script is footer-loaded), so the notice and its JS stay paired and the should-show check runs once.

Assets / enqueue

  • scf-bindings moved to enqueue_block_editor_assets (was pulling the wp-editor stack onto classic admin + front-end acf_form pages). The new path keeps trunk's WP 6.7+ guard and now also honors the enable_block_bindings setting (matching Bindings_Editor), so the client never registers the acf/field source when the server doesn't — with a regression test.
  • Command-palette scripts gated on wp-commands being enqueued.
  • Drop wp-polyfill from all handles (webpack injectPolyfill). Compiled assets are gitignored and rebuilt at release (bin/prepare-release.php), so this takes effect on the next release build.
  • Fix pro CSS min suffix (production was shipping unminified CSS).
  • Gate acf-pro-ui-options-page with is_admin().
  • Fix acf-dark stylesheet 404 by registering it through the central asset path patterns (the hand-built path drifting from the build layout is what caused the 404).
  • Trim release zip (exclude assets/src + source maps): −4.2 MB.

Verification

  • Rebased onto trunk (6.9.1).
  • composer test:php: OK (2846 tests, 21612 assertions). npm run test:unit: 951. composer test:phpstan: clean.
  • New code stamped @since SCF 6.9.2; new functions use the scf_ prefix.

See #466 (superseded by this PR + the sibling-priming PR).

Use of AI Tools

Initial implementation by Claude Code (Claude Fable 5) under human direction; split, reviewed and revised by Claude Code (Claude Opus 4.8); multi-agent review findings (bindings gating, WP_Error hardening, notice render-time enqueue, store-backed JSON cache, conventions) addressed by Claude Code (Claude Fable 5). All changes human-reviewed.

cbravobernal and others added 2 commits July 2, 2026 18:25
Lower-risk half of the performance audit (sibling-field priming is split
into its own PR for focused review). Everything here is behavior-identical
or a straight bug fix.

PHP runtime:
- Per-request cache for acf_get_option_meta(), invalidated via core option
  hooks (keeps the esc_like() hardening from #462; the cache wraps it).
- Decode each local JSON file once per request instead of 4x.
- acf_decode_taxonomy_term(): raw SQL -> get_term().
- Early bail in the blocks save path when no block types are registered.
- Gate the escaped-html notice script to when the notice renders.
- Memoize the WP version check in acf_is_using_datastore().

Assets / enqueue:
- Move scf-bindings to enqueue_block_editor_assets (was pulling the
  wp-editor stack onto classic admin + front-end acf_form pages).
- Gate command-palette scripts on wp-commands being enqueued.
- Drop wp-polyfill from all handles (webpack injectPolyfill).
- Fix pro CSS min suffix (production shipped unminified CSS).
- Gate acf-pro-ui-options-page with is_admin().
- Fix acf-dark stylesheet 404.
- Trim release zip (exclude assets/src + source maps): -4.2 MB.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Carry trunk's WP 6.7 guard into the block-editor bindings enqueue and
  also match Bindings_Editor's enable_block_bindings setting gate, so
  the client never registers the acf/field source when the server
  doesn't; add a regression test for the disabled setting.
- Guard acf_decode_taxonomy_term() against get_term() returning a
  truthy WP_Error (ambiguous shared terms, unregistered taxonomies).
- Enqueue the escaped-HTML notice assets at render time inside
  maybe_show_escaped_html_notice() — the script is footer-loaded, so
  this keeps the notice and its JS paired on the one request that shows
  it and drops the duplicate should-show evaluation.
- Back the Local JSON decode cache with a registered store (resettable,
  visible to store tooling), skip missing files without warnings, and
  clearstatcache() after writes/deletes so same-request re-reads see
  fresh contents.
- Register acf-dark through the central asset patterns instead of a
  hand-built path (the pattern drift is what caused the 404 this PR
  fixes).
- Revert the no-op WP-version memoization in acf_is_using_datastore().
- Rename the new option-meta flush helper to the scf_ prefix and stamp
  new symbols @SInCE SCF 6.9.2.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cbravobernal
cbravobernal force-pushed the perf/runtime-asset-safe branch from b6aef22 to 57a545d Compare July 2, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant