Skip to content

Page sync creates a child page at the top level when its parent page file fails to reconcile #212

Closed

Description

@WebUppAdmin

When a parent page file fails to reconcile, its child page file is still created. The child is made as a new top level page (post_parent 0) at the wrong public address. Any older child page is left alone beside it.

What happens. A parent page file can fail with reconcile_failed. One cause is a page that Blockstudio does not manage already holding the parent's slug. The sync then moves on to the child page file. The child has no page of its own yet, so it is created. Because the parent made no post, the child gets no parent. It lands at /child-page/ and not at /parent-page/child-page/. The failed list names only the parent. The child is not reported.

Affected versions. I read the code on 7.7.14, the latest tag, and on main. page-sync.php is identical in both. I also diffed 7.7.13 against 7.7.14 and page-sync.php and page-discovery.php do not differ. I saw the effect on a real run on 7.7.14.

Steps to reproduce

  1. In a theme, make two page folders. The child folder sits inside the parent folder.
pages/parent-page/page.json
pages/parent-page/index.php
pages/parent-page/child-page/page.json
pages/parent-page/child-page/index.php

pages/parent-page/page.json:

{ "name": "parent-page", "title": "Parent page", "postStatus": "publish" }

pages/parent-page/child-page/page.json:

{ "name": "child-page", "title": "Child page", "postStatus": "publish" }

Each index.php holds one line of block markup, for example <!-- wp:paragraph --><p>Hello</p><!-- /wp:paragraph -->.

  1. Make an ordinary page that Blockstudio does not manage, with the parent's slug:
wp post create --post_type=page --post_title="Old parent" --post_name=parent-page --post_status=publish
  1. Run the sync:
wp bs pages sync
  1. List the pages:
wp post list --post_type=page --fields=ID,post_name,post_parent --format=table

Expected. The parent fails, as it does today. The child is refused or held while its parent has no post. No page is created for the child.

Actual. The parent is reported as reconcile_failed. The child is created with post_parent 0 and the slug child-page, so it is public at /child-page/. If an older page already sat at /parent-page/child-page/, it stays untouched and there are now two.

Cause. Three functions in includes/classes/page-sync.php (7.7.14 line numbers):

  • resolve_parent_id(), lines 1453 to 1484, returns 0 when the parent's page file has made no post. The registry has no post_id for it, and the fallback lookup by _blockstudio_page_key or _blockstudio_page_name finds nothing.
  • create_post(), lines 849 to 853, sets post_parent only when resolve_parent_id() is above 0. With 0 it leaves post_parent out, so wp_insert_post() makes a top level page.
  • has_slug_conflict(), lines 796 to 823, passes the same 0 as post_parent at line 805. It looks for the child's slug at the top level, finds nothing, and lets the create go ahead.

reconcile() calls these at lines 176 to 181. Nothing there checks that a page with a parent_key has a parent post.

Suggested fix. In reconcile(), before the slug check and the create, return a failed result when the page has a parent_key, its post type is hierarchical, and resolve_parent_id() returns 0. Name the parent in the error. The sync already runs parents first, so the child is simply held until the parent is fixed.

Activity

  1. added a commit that references this issue on Nov 16, 2026
    3b4486a
  2. dnnsjsk commented on Nov 23, 2026

    @dnnsjsk
    Contributor

    Released in Blockstudio 7.7.15, via #209. Page sync now reports the unavailable parent and skips the child instead of creating it at the top level or moving an existing child. After resolving the parent conflict, run wp bs pages sync again.

  3. WebUppAdmin commented on Nov 23, 2026

    @WebUppAdmin
    Author

    Thanks for the fix in 7.7.15. Confirmed on a clean install: the orphan child is now reported and skipped, and syncing after fixing the parent places it correctly. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions