Skip to content

Existing posts with buggy embed className stay invalid in the standard editor #131

Description

@kraftbj

PR #129 fixed Press This so newly authored posts no longer emit a <figure> className that fails Gutenberg's core/embed block validation. But posts authored before that fix still have the buggy class list stored in their content:

<!-- wp:embed {"url":"...","type":"video","providerNameSlug":"youtube"} -->
<figure class="wp-block-embed is-type-video is-provider-youtube">
  <div class="wp-block-embed__wrapper">https://www.youtube.com/watch?v=…</div>
</figure>
<!-- /wp:embed -->

The save() output for those attributes adds a fourth class (wp-block-embed-youtube) that the stored figure is missing. When such a post is opened in the standard Gutenberg editor (wp-admin/post.php), block validation fails and the block shows "Block contains unexpected or invalid content / Attempt recovery" instead of the embed.

Confirmed:

  • core/embed's deprecated array doesn't cover this exact mismatch (it expects extra classes, not missing ones).
  • fix-custom-classname only repairs extra unknown classes, not missing standard ones.
  • Press This users typically don't reopen drafts in Press This — they continue work in the standard editor — so the fix needs to live in (or before) the standard editor's parse path.

Possible directions

  1. Migration command. A WP-CLI command (or one-shot admin notice with a "Repair" button) that scans posts for the broken pattern and rewrites the className to match save() output. Targeted, explicit, no surprise.
  2. Server-side filter on the_post / pre-render. Detect the buggy shape on read and fix it transparently. Lower friction, but rewrites without a clear log.
  3. Document and rely on Attempt Recovery. Tell users to click the recovery button when they see the banner. Zero engineering, lots of toil.

I'm leaning toward option 1. Open to other ideas before deciding.

Reference: original validation bug fixed in #129.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions