Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[6.x]: CP nav items resolve to site URLs instead of CP URLs when cached outside CP requests

Closed
#19,807 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start in CraftCms\Cms\Cp\Navigation::getTree() and trace its DependencyCache handling, then compare the use of Url::url() with Url::cpUrl(). Verify that relative CP navigation paths generated outside CP requests are cached with CP URLs rather than site URLs, while existing absolute URLs continue to work.

Written by the indexing model from the issue text.

Description

bug repo:cms
What happened?
Description

The latest alpha changed the behavior of my nav. I'm able to resolve it on my side but it may be a symptom of a behavior change worth sharing. I was previously passing in relative paths to NavItem and have updated to pass absolute URLs which don't get rendered with the wrong base path.

Per AI tooling:

It appears in CraftCms\Cms\Cp\Navigation, CP navigation items are cached server-side via DependencyCache for 1 hour in getTree(). During tree building, each item's URL is normalized using Url::url() instead of Url::cpUrl().

Because Url::url() checks request()->isCpRequest(), any process that triggers CP navigation generation outside of an active CP browser request (e.g. CLI Artisan commands, queue jobs, test suites, or front-end Twig calls) normalizes relative CP paths into site URLs instead of CP URLs, and bakes them into the 1-hour cache.

Craft CMS version

6.0.0-alpha.19

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
15h 41m
Merged PRs (30d)
211

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from craftcms/cms

All issues in craftcms/cms

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.