Footer layout with a form and two images becomes one raw-HTML "Custom Gallery" block (generated_component_non_native_items)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start with GeneratedComponentLowering.php and SubtreeClassifier.php, especially nativeOrGeneratedBlock(), isEntirelyNativeComponent(), repeatableChildCount(), and the media gallery signal. Reproduce through ArtifactCompiler::compileFragment() with the reduced page described in the issue, then inspect the generated blocks and diagnostics. Done means the form remains available to provider materialization, native siblings stay native, and the reduced footer produces no generated gallery or collection raw HTML block; add the described regression assertions and check the related fixtures.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
A site footer laid out as two rows in a column container (a link row, then a row holding a newsletter <form> and two payment-method <img> icons) is turned into one generated raw-HTML block, <ns>/gallery-<sha256> ("Custom Gallery", block.json blocksEngine.editingSurface: raw_html). It is not lowered to core/group + core/paragraph/core/image and the form path. The diagnostic reason is generated_component_non_native_items. On the real import, this is the entire site footer in parts/footer.html (logo, social icons, <hr>, "Stay in the Loop" form, reCAPTCHA notice, 8 payment icons, copyright). The owner can only edit it as an HTML textarea. Because the form is frozen inside the raw HTML string, the form provider never sees it, so no Jetpack form is materialized either.
Two decisions combine to cause this:
- The candidate gate misreads a layout as a repeated gallery.
GeneratedComponentCandidates::collectGeneratedComponentCandidates()marks thediv.container.colonce it is at leastGENERATED_COMPONENT_MIN_SOURCE_DEPTH(14) levels below<body>, has repeated direct-child tags, andFallbackEmitter::isRepeatableContentComponent()is true.SubtreeClassifierscores the container ascustom_block(score 4 vscustom_application2, confidence 0.78), from two signals:repeatable_children = 2: the two layout rows share the classcell rowand both "carry text" (a link label in one, the button label in the other). They are not repeated content items.media_gallery = true: any 2<img>anywhere in the subtree count as a gallery, here two 24 px payment icons. This signal also gives the generated block itsgallery-stem and the "Custom Gallery" title.
- One non-native item freezes the whole container.
GeneratedComponentLowering::nativeOrGeneratedBlock()does tryauthorLayoutBlockFromElement(). Inside it, the<form>lowers to aform_requires_runtimepreserved runtime island (core/htmlplus a fallback entry), which at shallow depth is later materialized asjetpack/contact-form. Because$nativeFallbacksis not empty andisEntirelyNativeComponent()rejectscore/html, the native result is thrown away and the entire container, including its native-expressible siblings, goes toFallbackEmitter::maybeGenerateCustomBlock(..., preserveRoot: true, confirmedComponent: true).
Seen on a Square Online site import (dandiandidesigns.com; Studio 2.1.0-dev276 / Static Site Importer 1.33.507 / Data Liberation Agent 0.33.201). Also reproduces on Blocks Engine trunk 316ce5d41c (php-transformer 0.45.436) through ArtifactCompiler::compileFragment(). Similar gallery-* raw-HTML blocks appear in the page content of the same site.
Reduced page
index.html, plus a media/ folder holding any two small SVG/PNG files named visa.svg and mastercard.svg:
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><title>Acme</title>
<style>
.row{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.col{display:flex;flex-direction:column;gap:16px}
.pay{width:38px;height:24px}
</style></head>
<body>
<div class="wrap"><div class="wrap"><div class="wrap"><div class="wrap"><div class="wrap"><div class="wrap">
<main><h1>Acme</h1><p>Welcome to Acme.</p></main>
<footer class="site-footer"><div class="wrap"><div class="wrap"><div class="wrap"><div class="wrap"><div class="wrap"><div class="wrap">
<div class="container col">
<div class="cell row"><a href="mailto:[email protected]">Email</a></div>
<div class="cell row">
<form action="/subscribe" method="post"><input type="email" name="email" placeholder="Email"> <button type="submit">Sign Up</button></form>
<img class="pay" src="media/visa.svg" alt="Visa"> <img class="pay" src="media/mastercard.svg" alt="Mastercard">
</div>
</div>
</div></div></div></div></div></div></footer>
</div></div></div></div></div></div>
</body></html>
(The 12 .wrap divs only put .container.col at source depth 14, which matches the real Square Online DOM: body > div.app-container > … > footer > … > div.w-container.col.)
Steps
studio create --from ./reduced --path ./site --name footer-gallery --skip-browser
(reduced/ holds index.html + media/.) Or call (new ArtifactCompiler())->compileFragment(file_get_contents('reduced/index.html'), 'index.html') on trunk.
Observed
parts/footer.htmliscore/group(footer) > core/group > <ns>/gallery-a9a3a25f…and nothing else. The block'scontentattribute is the whole.container.colsubtree as an HTML string, including the<form>and both<img>tags.ssi-runtime/blocks/gallery-a9a3a25f…/block.json:"title": "Custom Gallery","blocksEngine": {"editingSurface": "raw_html"}.- Diagnostics:
preserved_runtime_island / form_requires_runtime, thengenerated_component_non_native_items("Repeated content retained as generated raw HTML"), thenraw_html_companion_block / generated_document_contains_raw_html_companionat selectordiv.container.col.raw_html_companion_block_count: 1.quality_pass: true, so the gate does not flag it. SubtreeClassifier::classify(div.container.col):bucket=custom_block, confidence=0.78, repeatable_children=2, media_gallery=true, form_controls=1, scores={custom_block:4, custom_application:2}.
Controls, each from the same page with one change (Studio import + classifier):
| Change | Classifier | Result |
|---|---|---|
| none (reduced page) | custom_block 4 / app 2 → candidate | 1 × gallery-<sha> raw HTML |
<form> replaced by <span>Sign up below</span> |
custom_block 4 / 0 → candidate (same as above) | native: group ×5, image ×2, paragraph ×2 |
<form> removed |
repeatable_children=1 → not a candidate |
native: gallery + image ×2 |
second <img> removed |
media_gallery=false, tie 2/2 → unknown |
native groups + image + form → jetpack/contact-form, jetpack/field-email |
Full-footer bisection on the real capture showed the same pattern. Removing the social-icon row, the form, or the payment-icon row each gave a native footer. Removing only the logo still gave the raw-HTML gallery. In the original markup, the social <svg><title>Email</title><use …> icons are what make the first row "carry text".
Expected
- A container whose children are a few dissimilar layout rows is not a "repeatable" component. A row of small payment or icon images is not a
media_gallerythat turns a footer into a "Custom Gallery". - When a candidate's native lowering contains a runtime island (here the form), the island stays a bounded island (
core/html/ provider-materialized form →jetpack/contact-form). Its native siblings (core/group,core/paragraph,core/image,core/separator, social links) stay native, rather than the whole container becoming one raw-HTML block. - For the reduced page:
parts/footer.htmlcontainscore/group>core/paragraph/link + the form (Jetpack form after provider materialization) + 2 ×core/image, with nogallery-*/collection-*raw_html block.
Likely owner
php-transformer/src/HtmlToBlocks/Elements/GeneratedComponentLowering.php,nativeOrGeneratedBlock()/isEntirelyNativeComponent(): this is all-or-nothing. A singleform_requires_runtimeisland (core/html+$nativeFallbacksentry) discards the native lowering of the whole component.php-transformer/src/HtmlToBlocks/Classification/SubtreeClassifier.php:repeatableChildCount()counts two layout rows with a shared class as repeated items, andmedia_galleryis "≥ 2img|picture|figure|videoanywhere in the subtree". AlsoFallbackEmitter::isRepeatableContentComponent()(thresholdrepeatable_children >= 2) andSupport/GeneratedComponentCandidates.php.- Related: #4153 (depth-gated candidates freeze native-expressible repeats; open), #4232 and #4357 (earlier causes of
generated_component_non_native_itemsfreezing whole lists; closed).
Measurement
- Regression test through
ArtifactCompiler::compileFragment()with the reduced page: assert no block whose name matches/\/(gallery|collection)-[0-9a-f]{64}$/, assert acore/imageper payment icon, and assert the form is still exposed to the form provider (aform_requires_runtimeisland or form metadata, not text inside a generated block'scontent). The test fails on trunk316ce5d41cand passes with the fix. - Studio import of the reduced page:
raw_html_companion_block_count: 0and nogenerated_component_non_native_itemsdiagnostic. - The
<form>→<span>control keeps lowering natively, and the existing #4153/#4357 fixtures keep their current results.
Secondary findings (separate causes of the visual losses on the real footer)
These are not caused by the classification above, but they are why the frozen footer also renders badly. Both live in the companion-block render boundary that Static Site Importer generates (includes/class-static-site-importer-companion-plugin.php → ssi-runtime/blocks/*/render.php), so they probably belong in Automattic/static-site-importer:
- Two empty comments
<!---->(Vue placeholders) corrupt the rest of the block.render.phpcallswp_kses(). Itspre_ksesfilterwp_pre_kses_block_attributes()→filter_block_content()runspreg_replace_callback('%<!--(.*?)--->%', …). That regex spans from the first<!---->to the--->of the next one, soa <!----> b <!----> cbecomesa <!----> b <!--> c. KSES then outputsa b <!--> c-->, and everything after the second empty comment becomes comment text. Measured on the real footer block: 16<!---->in thecontentattribute became 7<!-->comment openers inrender_block()output. They hide 7 of 8 payment icons, the reCAPTCHA notice, and several closing</div>tags, which collapses the form layout (Sign Up wraps under a narrow input).wp_kses_post('a <!----> b <!----> c')alone reproduces it on WordPress 7.1.4. Stripping HTML comments from generatedcontentbefore the KSES boundary would avoid it. - Sprite icons lose their
<use>. The render boundary's SVG pass keepshref/xlink:hrefonly for fragments whoseidis inside the same<svg>.<use xlink:href="#email-icon">points at a page-level<symbol>sprite, so the<use>is removed and the Email/Facebook/Instagram icons render as empty 24×24 boxes (the frontend also has no#email-iconsymbol). Related: #4984 and #4797 (sprite sheets).
Reduced and filed by Claude (Anthropic) via the Franklin import-loop orchestrator; reduction verified with studio create --from.
- Ngôn ngữ chính
- PHP
- Star
- 28
- Fork
- 5
- Merge trung bình
- 2 giờ 59 phút
- Pull request đã merge (30 ngày)
- 942
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Automattic/blocks-engine
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Automattic/blocks-engine#6318 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/blocks-engine#4943 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/blocks-engine#4942 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Automattic/blocks-engine#4921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Automattic/blocks-engine#775 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Automattic/blocks-engine
Issue tương tự
-
15.0
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
PHP 8.6: is_integer() deprecation in Decorator\StyleCó thể đã có người làm @ElGigi đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
thephpleague/climate#220 ·
-
[BUG] Add asset to project adds all assets of $type instead of the ones in the search result.Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 73/100
ppy/osu-web#13514 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
stable/10 Publish fails: semantic-release requires Node >= 22.14, workflow sets up Node 20Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug needs-triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
camunda/orchestration-cluster-api-php#162 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày