Skip to content

fix(acf): a flexible content row is read with its own layout; a key and name for one sub-field is reported - #61

Merged
ABB65 merged 2 commits into
mainfrom
fix/acf-row-layout-45
Oct 10, 2026
Merged

ABB65 merged 2 commits into
mainfrom
fix/acf-row-layout-45

Conversation

@ABB65

@ABB65 ABB65 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Closes #45.

Label: GENERIC. This is ACF/SCF flexible content and keyed-row handling in Source::acf_value, used by every site whose flexible layouts reuse a sub-field name. It is not tied to one builder or theme.

What changes (includes/class-contentrain-bridge-source.php)

  1. Layout from acf_fc_layout. Before, the sub-fields of every layout were merged into one lookup by name, so a name that two layouts share resolved to the last layout's definition for every row. That could mean the wrong type, or a field judged secret, or one that wasn't. Now a row whose acf_fc_layout names a known layout looks its cells up in that layout first. Any cell that layout does not define (for example another layout's field key), and every cell of a row with no or an unknown layout, falls back to the all-layouts lookup main uses, so it is still typed and a secret type is still removed (fail-closed; 5515861, review follow-up).
  2. Key + name collision. A row holding one sub-field under both its key (field_…) and its name kept the later cell silently. It still keeps the later cell, so output is unchanged, and it now reports {source: <path>/<name>, reason: 'acf-key-name-collision: kept <cell>, dropped <cell>'} in the excluded list, next to acf-key-unmapped, using the existing reason: detail convention.

Tests (tests/integration.php, 2 new checks)

  • Two layouts both define media, one as image and one as password. The hero row keeps media: 42 and the note row's media is removed as sensitive. With the old union lookup the hero value was dropped too, so this check fails on main.
  • A repeater row with field_soc_label and label keeps the later cell and reports exactly one acf-key-name-collision: kept label, dropped field_soc_label.
  • A hero row carrying field_note_media (the note layout's password key) with the value hunter2: the cell is removed as sensitive-field, the value appears nowhere in the output, and no acf-key-unmapped is reported. This check fails against the layout-only lookup of the first commit (verified by running the suite on that code).

Checks (local, clean stack: down -v, then KEEP=1)

  • npm run test:wordpress: 397 checks passed (main has 394, plus these 3)
  • npm test: 13/13
  • npm run test:reader: pass
  • npm run test:plugin: Plugin Check 0 errors, 4 warnings (the four known WPML hook names)
  • php -l on all 59 PHP files: no errors

No version bump or changelog entry here. Add them at the next release.

ABB65 added 2 commits October 9, 2026 21:24
…nd name for one sub-field is reported

Source::acf_value merged every layout's sub-fields into one lookup, so a
sub-field name two layouts share (each with its own type) resolved to the
last layout's definition for every row. A row now uses the layout its
acf_fc_layout names; only a row whose layout is unknown falls back to the
union, as before.

A row holding a sub-field under both its key and its name kept the later
cell silently. It still keeps the later cell, and the overwrite is now
reported as acf-key-name-collision.

Closes #45
… layout's fields; the collision report names the kept and dropped cell

With the row's own layout as the only lookup, a cell keyed by another
layout's field key matched nothing and passed through untyped as
acf-key-unmapped, so a password sub-field from another layout could leak.
The row's layout is now looked up first and every other cell falls back to
the all-layouts lookup main always used, so a secret type is still removed.

acf-key-name-collision now says which cell was kept and which dropped.

Refs #45
@ABB65

ABB65 commented Oct 10, 2026

Copy link
Copy Markdown
Member Author

ONAY (t8) @ 5515861 — lean review, per the founder's "product first" order.

  • Code read: Source::acf_value looks up the row's own layout (acf_fc_layout) first, then falls back to the lookup across every layout, so a cell from another layout is still typed and a secret type is still removed (fail-closed). The key+name collision is reported with the existing reason: detail convention, and output is unchanged.
  • The 3 new tests cover the shared name, the collision and the planted key from another layout.
  • CI green at this head: acceptance (test:wordpress), small, small (10), plugin metadata. merge-tree vs origin/main: clean. php is not installed here, so CI is the lint/test evidence.
  • Non-blocking note: when a cell from another layout resolves to the same name, as in the planted test (media + field_note_media in a hero row), the report says kept field_note_media, dropped media. In reality media: 42 is kept and field_note_media is removed as sensitive. The "later cell wins" wording is also wrong when the later cell is cleaned to null. A message that names the cell actually kept could come in a later PR.

@ABB65
ABB65 merged commit 4559e4f into main Oct 10, 2026
8 checks passed
@ABB65
ABB65 deleted the fix/acf-row-layout-45 branch October 10, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACF row naming: pick flexible layout from acf_fc_layout; key+name collision

1 participant