Repository navigation
Render min repeater rows when no rows are stored - #138
Merged
Merged
Conversation
Block::transform() fills a repeater without stored rows with min rows of field defaults, but it reads min from the built attribute, and Container_Field_Handler::build_repeater() never copied it there. The old attribute builder in build.php did, until it was removed in 7.5.0. Since then a repeater with min and no stored rows renders false, for example in bs_render_block(), block tags and page sources. The editor adds the rows itself, so the min-rows E2E test still passed. Copy min into the built repeater attribute, with a builder test and a render test (both rows of field defaults, stored rows and default still win).
dnnsjsk
added a commit
that referenced
this pull request
Oct 19, 2026
Port PR #138 and incorporate the render-path corrections from PR #137 into the existing #135 validator. Preserve read-only validation, original stored values, palette strings, dynamic-option exclusions and the CLI. Document repeater initial rows and storage precedence, with unit/render and CI-only HTTP coverage. Co-authored-by: Contributolo <[email protected]>
Contributor
|
Merged and released in 7.7.5 (86a311c1). Repeater Regression tests cover PHP embeds, block tags, the file-page parsing path, and a frontend HTTP request without an editor save. full CI passed. |
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.
A repeater with
minand no stored rows rendersfalseon the frontend instead ofminrows of field defaults.Cause
Block::transform()fills such a repeater from the built attribute:Container_Field_Handler::build_repeater()never copiesmininto that attribute; the built repeater only hasblockstudio,type,field,id,attributes, plusdefault/fallback. The old attribute builder inbuild.phpdid copy it (added in 8af8909, "fix min rows"), and it went away with that builder in 3e1c3da (7.5.0 housekeeping). So since 7.5.0 the branch never runs.It shows wherever a block renders without rows the editor saved:
bs_render_block(), block tags, page sources, content written by scripts. The min-rows E2E test (tests/e2e/types/repeater/default-rows.ts) inserts the block in the editor, which adds the rows itself, so it still passes.Found while building #137: the built repeater carries neither
minnormax, so the validator there leaves row counts out.Fix
Copy
mininto the built repeater attribute inbuild_repeater().maxis not read on the server, so it stays out.Tests
AttributeBuilderTest::test_build_repeater_keeps_min.tests/unit/block/BlockRepeaterMinRowsTest.php: a block with amin: 2repeater renders two rows of field defaults when nothing is stored; stored rows and a repeaterdefaultstill win. The first test fails without the fix (template getsfalse), both pass with it.Run in WordPress Playground (PHP 8.4, WordPress latest, plugin and test theme mounted as in
tests/wp-env): the new tests andattribute-buildergreen;build,register,extensions,wpml,render,populate,field,rest,block-mergerand theblockclasses give the same results as unchangedmain(the failures there are the same tests onmain, environment related).composer csand PHPStan on the changed file clean.