Skip to content

Keep classes a generated block's save() writes when publishing class names - #7468

Merged
chubes4 merged 1 commit into
trunkfrom
fix/class-publisher-save-owned-classes
Nov 24, 2026
Merged

chubes4 merged 1 commit into
trunkfrom
fix/class-publisher-save-owned-classes

Conversation

@chubes4

@chubes4 chubes4 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7466

What

ClassPublisher now pins every engine class that a non-core block's saved HTML holds but none of that block's className/class comment attributes supplies. That class is a literal in the block's shipped save(), so it keeps its engine name and the stored markup still round-trips. Classes supplied by attributes are renamed in the comment and the HTML together, so their round trip keeps working.

This is generic. It covers every generated block with a fixed inner class (copy-to-clipboard's blocks-engine-copy-to-clipboard__status, for one) without a per-generator declaration. #7395's runtime_class_names declaration for the carousel keeps working alongside it.

Root cause: php-transformer/src/WordPressSitePlan/ClassPublisher.php, introduced in #7326 and extended in #7347. Before this fix it renamed classes in post content only, while the generated save() JS kept emitting the engine names.

Gate

tests/unit/published-carousel-save-agreement.php is now tests/unit/published-generated-block-save-agreement.php. It compiles a namespaced plan containing a carousel and a copy-to-clipboard control, finds every generated block in the published pages, templates and parts, runs that block's own shipped save() in node, and compares the result to the stored block markup, ignoring insignificant whitespace, attribute order and class-token order.

  • On trunk it fails: the stored span is catalog-copy-to-clipboard, but save() writes blocks-engine-copy-to-clipboard__status.
  • With this fix it passes for both blocks.

Verification

  • tests/unit/published-generated-block-save-agreement.php: passes (fails on trunk)
  • tests/contract/class-publisher.php: passes
  • phpcs and phpstan: clean
  • php tests/run.php: the only failures are Chrome-dependent contracts that also fail on trunk locally (no Chrome)
  • Parity suite: 368 fixtures pass
  • End to end, with this branch alone packaged into Static Site Importer 1.38.26 (build:dev-package) and the Bossa capture subset (home, build-your-drawer, drawer/kitchen) imported into a scratch Studio site, editor validation (wp.blocks.validateBlock across all pages, templates and parts) reports 0 invalid blocks. The stepper copy-to-clipboard blocks are still present (Copy-to-clipboard treats a bare data-copy attribute as clipboard evidence, so quantity steppers become copy buttons #7467 / Require real copy evidence before promoting a control to copy-to-clipboard #7469), but each one now validates.
  • The reference import on 1.38.26 / 0.51.123 had 21 invalid ssi-bossa-r8/copy-to-clipboard blocks across build-your-drawer and the four drawer pages.

AI disclosure: implemented by Claude (Opus) as a Franklin/Pi subagent; Chris Huber directed the work.

…when publishing class names

ClassPublisher renamed every engine class in shipped block content. A
non-core block's save() is code the plan does not carry, so a class its
saved HTML holds that no className/class attribute of that block supplies
is a literal in save(). Renaming or dropping it in content alone left the
stored markup disagreeing with save(), and the editor reported the block
invalid (copy-to-clipboard's status span, for one).

Pin those classes. Generalize the published carousel save agreement test
into a gate that runs every generated block's shipped save() against the
published plan.

Fixes #7466
@chubes4
chubes4 merged commit 4d50651 into trunk Nov 24, 2026
14 of 15 checks passed
@chubes4
chubes4 deleted the fix/class-publisher-save-owned-classes branch November 24, 2026 03:08
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.

Class publishing renames fixed inner classes of generated blocks, so their saved markup no longer matches save()

1 participant