[6.x]: CP nav items resolve to site URLs instead of CP URLs when cached outside CP requests
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
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
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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from craftcms/cms
-
bug repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
craftcms/cms#19828 · 1 comment ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 4/5 3-5 days Newbie friendliness 50/100
craftcms/cms#19829 · 1 comment ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 3/5 1-2 days Newbie friendliness 68/100
craftcms/cms#19809 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 5/5 Over a week Newbie friendliness 25/100
craftcms/cms#19761 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
craftcms/cms#19675 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Lead create/update: a product row without a "product_id" key passes LeadForm validation and fails in the database (500)Possibly taken @Arslan-TR claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
krayin/laravel-crm#2681 ·
Maintainers usually reply within 2 days
-
[CoreBundle] Migrations are silently skipped on MariaDB with DBAL 4 (AbstractMigration::isMySql())OpenPotential Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Sylius/Sylius#19270 · 1 comment · 4 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
invoiceninja/invoiceninja#13320 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day