fix: sync posts to Elasticsearch when Post Search is disabled#4325
Open
faisalahammad wants to merge 1 commit into
Open
fix: sync posts to Elasticsearch when Post Search is disabled#4325faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Move the post indexable activation out of the Post Search feature setup so posts continue to sync even when that feature is disabled. Previously, disabling Post Search prevented the Post indexable's SyncManager from being instantiated, so wp_insert_post / delete_post / meta / term hooks were never attached. Fixes 10up#4158
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.
Summary
Move the Post indexable activation out of the Post Search feature
setup()so posts continue to sync to Elasticsearch even when the Post Search feature is disabled.Previously, disabling Post Search prevented
Post::setup()from being called, which meant theSyncManagerwas never instantiated andwp_insert_post/delete_post/ meta / term hooks were never attached.Fixes #4158
Changes
includes/classes/Features.php
Before:
After:
Why:
setup_features()runs oninitpriority 0 for every request. Activating the post indexable here ensures it is always set up, independent of whether the Search feature is active.includes/classes/Feature/Search/Search.php
Before:
After:
Why: The Search feature no longer needs to activate the post indexable. Its
setup()still loads weighting, synonyms, and registerssearch_setupfor query integration.Testing
Test 1: Post sync with Post Search disabled
Result: works as expected.
Test 2: Post sync with Post Search enabled (regression)
Result: works as expected.
Test 3: Automated regression test
Added
tests/php/indexables/TestPostSyncWithoutSearch.phpwithtestPostSyncWithSearchDisabled()— disables the Search feature, creates a post, and asserts the sync hook fires and the document exists in Elasticsearch. Passes on single-site and multisite test suites.