Skip to content

Enhancement: Set posts per page to 1000 in the block editor importer - #564

Closed
juanmaguitar wants to merge 1 commit into
WordPress:trunkfrom
juanma-wp:enhancement/allow-more-handbook-pages-import
Closed

juanmaguitar wants to merge 1 commit into
WordPress:trunkfrom
juanma-wp:enhancement/allow-more-handbook-pages-import

Conversation

@juanmaguitar

@juanmaguitar juanmaguitar commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Increases the posts_per_page limit for the Block Editor Handbook importer from 500 to 1000.

Why

The base Importer class (wporg-markdown/inc/class-importer.php) defaults to querying a maximum of 500 existing handbook posts when running import_manifest(). This limit is used to build a lookup table of existing posts so the importer can decide whether to update or create each manifest entry.

The Block Editor Handbook manifest currently has ~530 entries. With the upcoming addition of per-block reference pages (WordPress/gutenberg#77350), the manifest will grow to ~700+ entries.

When the manifest exceeds the 500-post query limit, each subsequent cron run of devhub_blocks_import_manifest fails to find all existing posts in the lookup table. Posts beyond the limit are treated as new, causing:

  • Duplicate posts with incrementing slugs (how-to-guides-2, how-to-guides-3, etc.)
  • Orphaned children at the top level, because the parent post lookup also fails
  • Snowball effect: each duplicate increases the total post count, pushing more posts beyond the limit on the next run

The yarn setup script triggers devhub_blocks_import_manifest twice across two cron batches, which is enough to reproduce the issue on a fresh environment.

How

Overrides $this->posts_per_page = 1000 in DevHub_Block_Editor_Importer::init() after calling parent::do_init(). This is scoped to the block editor handbook only, leaving other handbooks (which have far fewer entries) unaffected.

Testing

  1. Clone the repo and apply this change
  2. Edit import-block-editor.php to point the manifest at gutenberg#77350:
$manifest = 'https://raw.githubusercontent.com/WordPress/gutenberg/refs/pull/77350/head/docs/manifest.json';
  1. Run wp-env destroy && wp-env start && yarn setup
  2. Visit http://localhost:8888/block-editor/ — the sidebar should have no duplicate entries
  3. Verify with: wp-env run cli wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_type='blocks-handbook' AND post_title='How-to Guides' AND post_status='publish'" — should return 1

Without this fix, the same steps produce 12+ duplicate "How-to Guides" entries and orphaned pages throughout the sidebar.

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.

1 participant