943 seo data optimization error reporting refactoring#23402
Open
pls78 wants to merge 12 commits into
Open
Conversation
Coverage Report for CI Build 908Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Warning No base build found for commit Coverage: 45.965%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
Added the getAlreadyIndexedStateName function because the Tools page and the FTC use a different string. All the rest is 100% untouched
Nothing changed, I just moved out the re-used code
… id and type to be consumed by the fronted
…rminal which indexable cannot be created
600e5a2 to
3ecba73
Compare
|
A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch. |
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.
Context
When an unexpected error occurred while building an indexable during SEO data optimization, the failure surfaced as an opaque error: the user had no indication of which object could not be optimized. This PR carries the failing object's identity (type + ID) from the indexable builder all the way through to the WP-CLI output and the REST/React error UI, and gives third parties a hook to react to the failure.
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Indexing_Failed_Exception(extendingIndexable_Exception) wraps the underlying throwable and carries the object'sobject_id,object_type, andobject_sub_type.wpseo_indexable_indexing_failedaction so third parties can react to a failed indexable build.AbstractIndexationcomponent so the Tools page and the first-time configuration share a single code path, with the render layer kept in thin subclasses.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR changes what the user sees when an indexable cannot be built during SEO data optimization. To test it you need to (a) make sure indexing actually runs, (b) force a build failure, then (c) check the CLI output and the React error UI. Finally, confirm the normal (happy-path) optimization still works once the forced failure is removed.
Setup
Force a build failure (temporary code change)
src/builders/indexable-post-builder.phpand, as the very first line ofpublic function build( $post_id, $indexable )(around line 115), add:Indexable_Builder::build()catches, logs, fireswpseo_indexable_indexing_failedfor, and re-throws asIndexing_Failed_Exception— exactly the path this PR adds, with object typepostand a real post ID.Check the React error UI (Tools page)
post #{id}(the ID of the post that failed). The Request URL, Request method, Status code, Error message, and a collapsible "Error stack trace" should also be present.Check the WP-CLI output
wp yoast index(in this worktree-based Docker setup, run it inside the cli container or viawp-env run cli wp yoast index).Could not optimize post #{id} while indexing posts: Simulated indexing failureand stops with an error, instead of an opaque failure.(Optional) Third-party hook + log
WP_DEBUG_LOGenabled, the builder's own logger also writes the failure todebug.log.Confirm the happy path still works (no regression)
throw(and the optional hook).AbstractIndexation) as the Tools page.Relevant test scenarios
{object_type} #{object_id}for whichever indexable fails — to see a non-post type, move the temporarythrowinto the matching builder (e.g.indexable-term-builder.phpforterm #{id}).Test instructions for QA when the code is in the RC
Forcing a build failure requires a temporary code change, so QA can focus on the happy path plus a visual check of the error UI:
wp yoast indexWP-CLI command still indexes content normally and reports completion.throwinindexable-post-builder.php), confirm the Tools-page error alert's "Error details" shows a "Failing object" line aspost #{id}, and thatwp yoast indexprintsCould not optimize post #{id} while indexing posts: …. Remove the temporary change afterward.Impact check
This PR affects the following parts of the plugin, which may require extra testing:
Indexable_Builder) — now logs, fireswpseo_indexable_indexing_failed, and re-throws asIndexing_Failed_Exceptionon unexpected errors.wp yoast indexWP-CLI command and the indexing REST route — both now handle the new exception.AbstractIndexationengine, so the happy-path indexing flow should be regression-tested in both places.Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
innovationlabel.Fixes #943