Skip to content

v1.2.4 — Non-destructive saves (issue #13)

Choose a tag to compare

@developer2013 developer2013 released this 08 Jul 07:53

Non-destructive saves for existing pages (issue #13)

Saving an existing or cloned page/template through the MCP no longer mutates it. Previously the auto-fixer ran on every write and, when saving content it hadn't generated, could rewrite element types, renumber IDs (orphaning #brxe-<id> CSS and queryId/filterQueryId references), and reject legacy all-letter IDs in bricks_patch_page — forcing a destructive full-page save. Thanks to @Lightning-Std for the precise, well-diagnosed report.

Fixed

  • Element types are preserved on save. div is a valid Bricks layout element (an unstyled div, distinct from block, a full-width flex div) — it is no longer rewritten to block, and the validator no longer rejects it. The block → container promotion now runs only for new/imported content.
  • IDs are preserved. The "must contain a digit" rule is dropped as a gate: all-letter IDs (e.g. wmhqxu) are valid in Bricks and are kept verbatim (6-char length still enforced). When an ID genuinely must be regenerated (missing/malformed), every reference is rewritten in the same pass — brxe-<id> selectors in _cssCustom, queryId/filterQueryId/_cssId, and component properties — so nothing orphans.
  • bricks_patch_page accepts existing (legacy) IDs in its update array, so text-only edits on cloned/legacy sites are fully non-destructive (the patch path only auto-fixes newly added elements).

Behavior

Full saves of existing content default to a preserve mode (element types + IDs verbatim). New/imported/generated content (build/append/import paths) keeps the aggressive normalization. Override per call with the autofix_mode parameter, or site-wide with the bab_autofix_mode option / BAB_AUTOFIX_MODE constant.

Verified

End-to-end on a live Bricks 2.x install: a full save of a page with all-letter IDs, a div, a flex block, and self-referential #brxe- CSS round-trips unchanged; patch_page accepts a digit-less ID; and an API-created name:"div" renders as a real <div> with its #brxe-<id> CSS intact.

Versions

MCP server 1.2.4 · Bricks API Bridge plugin 1.4.1

Install / update: download bricks-api-bridge.zip below and upload it in WordPress → Plugins → Add New → Upload (or re-upload to update in place).