Repository navigation
Enhancement: Set posts per page to 1000 in the block editor importer - #564
Closed
juanmaguitar wants to merge 1 commit into
Closed
juanmaguitar wants to merge 1 commit into
juanmaguitar wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Increases the
posts_per_pagelimit for the Block Editor Handbook importer from 500 to 1000.Why
The base
Importerclass (wporg-markdown/inc/class-importer.php) defaults to querying a maximum of 500 existing handbook posts when runningimport_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_manifestfails to find all existing posts in the lookup table. Posts beyond the limit are treated as new, causing:how-to-guides-2,how-to-guides-3, etc.)The
yarn setupscript triggersdevhub_blocks_import_manifesttwice across two cron batches, which is enough to reproduce the issue on a fresh environment.How
Overrides
$this->posts_per_page = 1000inDevHub_Block_Editor_Importer::init()after callingparent::do_init(). This is scoped to the block editor handbook only, leaving other handbooks (which have far fewer entries) unaffected.Testing
import-block-editor.phpto point the manifest at gutenberg#77350:wp-env destroy && wp-env start && yarn setuphttp://localhost:8888/block-editor/— the sidebar should have no duplicate entrieswp-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 return1Without this fix, the same steps produce 12+ duplicate "How-to Guides" entries and orphaned pages throughout the sidebar.