Capture node ids read as landmark ids drop a route from the shared footer

Open Beginner friendly
#7,881 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start by locating ArtifactPageCompiler::membersSharingLandmarkStyles() and inspect how it extracts landmark IDs from stylesheet sources. Use the reduced reproduction in the issue to verify that only actual id attributes count, then confirm the compiler produces one footer part for all three routes.

Written by the indexing model from the issue text.

Description

Summary

ArtifactPageCompiler::membersSharingLandmarkStyles() decides which stylesheets are a shared shell's "landmark stylesheets" by looking for the landmark's ids in each style source. The ids come from /\bid="([^"]+)"/. That pattern also matches data-blocks-engine-node-id="n253", because \b sits between - and id. Capture node ids are route-local evidence, so they are not selectors. Short values like n12 also turn up inside minified CSS (--Button1234-color contains n12).

When two routes' node ids happen to occur in a stylesheet every route loads, that stylesheet counts as a landmark stylesheet loaded by the majority. A route whose node ids don't occur in it is then treated as "missing" that stylesheet and dropped from the source-shared group, even though it loads the same <link>. That route's footer is then compared on its page-compiled identity, where route-local placement rules (for example a route-only min-height:0px) keep it apart. The route keeps its footer in post content, and the template the route uses has no footer part.

Seen on

A 3-route import (home + 2 legal pages) of a classic site builder export. Scorecard shared_shell fails with templates_missing_shell:["front-page"] and page_shell_landmarks: {"website/index.html":["footer"]}. Instrumented run: the footer source group held all 3 routes (same source identity), but membersSharingLandmarkStyles reported shared=2 and the home route as missing one capture stylesheet. Only the legal pages' footer node ids (n253, n367) occur in that stylesheet, inside custom-property names like --Button2534820817-…. The home route's node ids (n6xx) don't.

Ruled out: data-id/attribute order and prop: value vs prop:value style spacing differ between routes in the live source too (frozen live reference docs show both). ChromeIdentity/RenderEquivalentMarkup already canonicalize them, so they play no part here.

Reduced reproduction

$page = fn (string $title, int $node, string $placement): string => '<!doctype html><html><head><link rel="stylesheet" href="/assets/site.css"><style>.site-footer{padding:24px;background:#f4f4f4}body :where(.site-footer){' . $placement . '}</style></head><body>'
    . '<header><p class="brand">Brand</p><nav><a href="/">Home</a><a href="/about/">About</a><a href="/terms/">Terms</a></nav></header>'
    . '<main><h1>' . $title . '</h1></main>'
    . '<footer id="site-footer" class="site-footer" data-blocks-engine-node-id="n' . $node . '"><p data-blocks-engine-node-id="n' . ($node + 1) . '">&copy; 2035 by Example.</p><a class="button" href="/terms/" data-blocks-engine-node-id="n' . ($node + 2) . '">Terms</a></footer></body></html>';
$files = array(
    'assets/site.css' => '.button{--Button1234-color:#123456;color:var(--Button1234-color)}',
    'index.html' => $page('Welcome', 40, 'min-height:0px;position:relative'),
    'about/index.html' => $page('About', 12, 'margin-top:0%;position:relative'),
    'terms/index.html' => $page('Terms', 12, 'margin-bottom:0%;position:relative'),
);
$plan = (new ArtifactCompiler())->compile(array('entrypoint' => 'index.html', 'files' => $files))->toArray()['source_reports']['wordpress_site_plan'];

On trunk at 3da2edc724c: two footer parts (footer, footer-0eb547304658), and the home footer stays in post content. Changing the legal pages' node ids from n12 to n50 (so they no longer occur in site.css) makes one footer part serve every route. Node ids alone decide the outcome.

Expected

Only real id attributes name a landmark for this check. Then one footer part serves all three routes.

Loop signature: cdd79cd22c8f

Dominant language
PHP
Stars
31
Forks
7
Avg merge
7h 58m
Merged PRs (30d)
820

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/blocks-engine

All issues in Automattic/blocks-engine

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.