Skip to content

fix: Suppressed the warning for breadcrumbOnly items#25

Merged
shavonn merged 1 commit into
mainfrom
fix/suppress-breadcrumb-warnings-not-current
Apr 8, 2026
Merged

fix: Suppressed the warning for breadcrumbOnly items#25
shavonn merged 1 commit into
mainfrom
fix/suppress-breadcrumb-warnings-not-current

Conversation

@shavonn
Copy link
Copy Markdown
Contributor

@shavonn shavonn commented Apr 8, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 02:35
@shavonn shavonn merged commit 355e09b into main Apr 8, 2026
22 checks passed
@shavonn shavonn deleted the fix/suppress-breadcrumb-warnings-not-current branch April 8, 2026 02:35
@github-actions github-actions Bot mentioned this pull request Apr 8, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the navigation breadcrumb URL generation to avoid emitting debug warnings when generating URLs for breadcrumbOnly items that may not have resolvable route parameters in the current request context.

Changes:

  • Extended Navigation::resolveRoute() with a $silent flag to optionally suppress debug logging on route generation failures.
  • Updated breadcrumb URL building to call resolveRoute(..., silent: true) for breadcrumbOnly items (especially those using wildcard params), falling back to '#' without logging.
  • Added clarifying inline comments explaining why failures are expected for certain ancestor breadcrumb items.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Navigation.php
@@ -358,17 +358,21 @@ private function routeMatches(
*
* @param array<string, mixed> $params
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resolveRoute() docblock only documents $params, but the method now accepts a $silent flag that changes behavior (suppresses debug logging on route resolution failures). Please update the PHPDoc to include and describe the $silent parameter so static analysis and IDE hints stay accurate.

Suggested change
* @param array<string, mixed> $params
* @param array<string, mixed> $params
* @param bool $silent Whether to suppress debug logging when route resolution fails.

Copilot uses AI. Check for mistakes.
Comment thread src/Navigation.php
Comment on lines +464 to +472
// For breadcrumb-only items with wildcards, use current route params.
// Silently fall back to '#' when params can't be resolved — these are ancestor
// items in a breadcrumb chain whose required params aren't present in the
// current route, which is expected and not a real error.
if ($item->breadcrumbOnly && $item->params !== null) {
$resolvedParams = $this->resolveWildcardParams($item->params, $routeParams);
$breadcrumbItem['url'] = $this->resolveRoute($item->route, $resolvedParams);
$breadcrumbItem['url'] = $this->resolveRoute($item->route, $resolvedParams, silent: true);
} else {
$breadcrumbItem['url'] = $this->resolveRoute($item->route, $routeParams);
$breadcrumbItem['url'] = $this->resolveRoute($item->route, $routeParams, silent: $item->breadcrumbOnly);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change intentionally suppresses route error logging for breadcrumbOnly breadcrumb URLs (via silent: true / silent: $item->breadcrumbOnly), but there’s no automated test asserting that Log::warning is not emitted in debug mode for breadcrumbOnly items when URL generation fails (e.g., missing required params causing UrlGenerationException). Add a unit test that mocks Log and verifies breadcrumb generation returns '#' without logging for breadcrumbOnly items.

Copilot uses AI. Check for mistakes.
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.

2 participants