Fix Bricks synchronization for empty class sets - #10
Merged
DavidBabinec merged 2 commits intoAug 17, 2026
Conversation
Always run Bricks synchronization after the stylesheet is persisted, including when Core Framework generates no utility classes. Normalize empty selector payloads, prevent blank global classes, and calculate removed CF class IDs before filtering previous classes. Remove stale locked-class references while preserving non-CF classes, settings, variables, and categories. Add regression coverage for empty, non-empty, removal, preservation, and idempotent synchronization. Manual validation against Bricks 2.3.11 covered variables-only synchronization and stress testing up to 5,000 synthetic Bricks documents with 100 elements each. Cleanup remained correct and error-free. Removal time scaled approximately linearly, reaching 19.09 seconds in the largest synthetic case.
Jan-CoreBunch
force-pushed
the
fix/bricks-empty-class-sync
branch
from
August 14, 2026 11:05
65bf3ad to
1eb2c30
Compare
DavidBabinec
marked this pull request as ready for review
August 17, 2026 18:05
Review fixes on top of the empty-class-set change. - Prime the meta cache per batch of 50. 'fields' => 'ids' stops WP_Query from priming it, so the sweep cost five queries per post, roughly 25k on a 5k-post site, which is what produced the 13.5s and 19.1s timings in the PR description. - Sweep references after the class options are written, not before. An interrupted sweep used to leave elements stripped of their references while the classes still existed, with nothing to recover from it. - Report a failed push. Gating the toast on persistence removed the false confirmation but left silence in its place. handlePushDb no longer toasts on its own so the two do not double up. - Gate colors on persistence as well, ahead of classes, which is the order the batch already gave them. - Skip a selector whose sanitized id collides with one already emitted. Bricks keys elements by id, so two classes sharing one is ambiguous. 28 tests pass with 52 assertions, up from 26 and 47. The ordering test was checked against the previous placement and fails there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Bricks synchronization when Core Framework generates variables but no utility classes, and removes stale CF-owned classes immediately when the final generated class is disabled.
Root cause
update-classeswas never called and Bricks variables were not refreshed.Changes
_cclass._cssGlobalClassesreferences.StylesheetStorage.Automated validation
bun run php-test:wp— 26 tests and 47 assertions passed.bun run test:www— 23 suites and 147 tests passed.bun run build:wp— passed.git diff --checkpassed.Manual functional validation
Using Bricks 2.3.11:
Manual performance validation
All
update-classesrequests returned HTTP 200 and completed without errors.Class addition remained effectively constant. Removal scaled approximately linearly because stale CF references must be removed from Bricks post metadata. The 5,000-document cases are considered an extreme-site caveat rather than a blocker for this focused fix. Further optimization can be considered separately if real-world usage demonstrates a need.