Improved component resolution handling - #4592
Open
girishpanchal30 wants to merge 2 commits into
Open
Conversation
Collaborator
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds safer HFG component resolution to avoid warnings/notices when the render context is missing/stale, and verifies the behavior via unit tests.
Changes:
- Add guard logic to
Abstract_Builder::get_component()to returnnullfor missing/unknown component IDs. - Update component templates to bail out early when
current_component()can’t be resolved. - Add WP unit tests covering unknown/stale component IDs and template rendering behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test-neve-hfg-component-guards.php | Adds unit tests for component resolution guards and template no-output behavior |
| header-footer-grid/Core/Builder/Abstract_Builder.php | Ensures get_component() returns null for null/unknown IDs |
| header-footer-grid/functions-template.php | Updates current_component() return type doc to include null |
| header-footer-grid/templates/components/component-nav.php | Avoids calling methods on an unresolvable component |
| header-footer-grid/templates/components/component-logo.php | Avoids calling methods on an unresolvable component |
| header-footer-grid/templates/components/component-footer-sidebar.php | Avoids calling methods on an unresolvable component; reuses resolved component |
| header-footer-grid/templates/component-wrapper.php | Avoids calling methods on an unresolvable component; reuses resolved component |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (2)
header-footer-grid/templates/components/component-nav.php:22
- This can still emit an
Undefined index: devicenotice when$argsis non-empty but does not contain adevicekey. Use a key-level check (e.g.,isset( $args['device'] )) or null coalescing ($args['device'] ?? '') to avoid notices.
$device_class = isset( $args ) && ! empty( $args ) ? $args['device'] : '';
header-footer-grid/templates/component-wrapper.php:16
- The same component-resolution guard pattern is duplicated across multiple templates in this PR. Consider centralizing the logic in a small helper (e.g., a function that returns
?Abstract_Componentor bails for templates) to reduce repetition and keep future guard behavior consistent.
$_component = current_component();
// Bail when the current component cannot be resolved on the current builder.
if ( ! $_component instanceof Core\Components\Abstract_Component ) {
return;
}
selul
approved these changes
Aug 20, 2026
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
Improves the reliability and safety of component resolution in the header-footer grid system by adding guards to prevent errors when a component cannot be found. It updates several component templates to bail early if the current component is unresolvable and adds comprehensive unit tests to ensure these guards work as intended.
Check before Pull Request is ready:
Closes #4565