Repository navigation
Conversation
Winter\Pages\Classes\Menu resolves a menu item's URL from its reference for every type but "url", which owns its URL. The localized fields applied on pages.menu.referencesGenerated were overwriting that resolved URL whenever a localized "url" value happened to be stored on the item. The backend form only shows the URL field for the "url" type, so such a value is not visible and cannot be removed there. It is left behind when an item is changed from "url" to a reference type, and from then on the item keeps linking to the old address in that locale while the form shows a reference. Localized titles keep working for every type, and a "url" item keeps its localized URL. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to Reference-based menu items keep their resolved URLs while direct URL items retain localized URLs, with coverage for the changed behavior; no merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ast-grep (0.45.3)Plugin.phpast-grep timed out on this file 🔧 PHPStan (2.2.12)Composer install failed: dependency resolution error. Check composer.json and composer.lock for version constraints. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
In short, I once set my |
Problem
Winter\Pages\Classes\Menuresolves a menu item's URL from its reference for every type buturl, which owns its URL:The
pages.menu.referencesGeneratedlistener added by this plugin then applies every localized field, includingurl, without that distinction — so a stored localizedurlsilently overrides the URL that was just resolved from the reference.EventRegistry::registerMenuItemTranslation()makesurltranslatable for every item type, but the backend form only shows the URL field for theurltype. That makes the stored value invisible and unremovable through the UI: change an item from "URL" to a reference type and the localized URLs stay behind inviewBag.locale.<code>.url, and from then on the item keeps linking to the old address in those locales while the form shows a reference.That is how we ran into it: a footer item was converted from a URL to a blog-detail reference. The form showed the reference, the front-end kept emitting the old path for one locale, and there was no field to clear.
Change
Skip the
urlfield when the item's type is noturl. Localized titles keep working for every type, and aurlitem keeps its localized URL.Tests
tests/unit/MenuItemLocalizationTest.phpcovers the four cases: a localized title is applied, a localized URL is applied to aurlitem, a localized URL is ignored when the URL came from a reference, and nested items are treated the same way. The two reference cases fail without the change.The fixtures stand in for
MenuItemReferencewithstdClass, so the test does not require Winter.Pages to be installed.Summary by CodeRabbit
Bug Fixes
Tests