Repository navigation
Delete plan-11 Phase D legacy site-editor code (#434) - #455
Conversation
Rewire EntitySearchController and MenuLocationsController against cms-framework's resolvers + assignment models under class_exists guards. Both return empty data when cms-framework isn't installed (Phase H install gate is the user-facing surface for that condition). Drops the legacy Gate::authorize(VisualEditorNavigation::class) — route middleware already enforces auth. Tests rewritten to cover the no-cms-framework branch; the populated path is exercised by consuming-app tests where a real cms-framework env is wired.
Delete GlobalStylesCssProvider + GlobalStylesCacheInvalidator (parent package). Renderer-blade's <x-ve-blocks> / <x-ve-template> now use a new GlobalStylesEmissionResolver that delegates to cms-framework's GlobalStylesEmitter under a class_exists guard — Phase H install gate is the user-facing surface for the no-cms-framework case; the resolver returns '' so the renderer doesn't emit a <style> block. Cache busting is event-driven inside cms-framework, no more per-request invalidator. GlobalStylesCompiler was the deleted provider's last consumer, so it goes too along with its test.
Rewrite TemplatePartInliner + PatternInliner to consume cms-framework's TemplatePartResolver + BlockPattern under class_exists guards. Legacy visual-editor TemplateResolver (src/Resources/TemplateResolver.php) deleted entirely; TemplateComponent now walks the WP-style fallback chain itself and calls cms-framework's TemplateResolver per candidate. Tests that exercised the legacy model-backed inliner internals are deleted — the cycle/depth coverage moves with the inliner logic, which now sits behind cms-framework's resolvers and is covered by their tests + consuming-app integration tests.
Delete the 6 plan-11 Phase D models (VisualEditorTemplate, VisualEditorTemplatePart, VisualEditorPattern, VisualEditorPatternCategory, VisualEditorGlobalStyles, VisualEditorNavigation) + their 5 policies + the orphaned MenuLocationResolver service. Remove their imports, container bindings, and Gate::policy registrations from VisualEditorServiceProvider. Drop the 8 plan-11 visual_editor_* migrations and ship a single drop-migration (2026_05_15_000000_drop_legacy_visual_editor_tables.php) so existing installs cleanly retire the orphan tables. Delete the model + service unit/feature tests that exercised the deleted code (VisualEditorTemplateTest, MenuLocationResolverTest). 505 pest tests pass.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR removes Phase D visual-editor models, policies, creation migrations and related services; it reworks renderers and controllers to delegate template/template-part/pattern/global-styles/navigation resolution to cms-framework under runtime guards, registers a GlobalStylesEmissionResolver, and adds a migration to drop orphaned visual_editor_* tables. ChangesPlan 11 Phase D Legacy Cleanup and cms-framework Migration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Http/Controllers/EntitySearchController.php`:
- Around line 106-132: The loop in EntitySearchController collects matches and
stops once count($matches) >= self::MAX_RESULTS, which causes the selection to
depend on resolver->all() iteration order; instead gather all candidate matches
into the $matches array, then sort them using the existing usort (static fn
(array $a, array $b): int => strcasecmp(...)), and only after sorting slice the
array to self::MAX_RESULTS (mirroring searchResourceModel() behavior) so the
returned set is the alphabetically-first results regardless of iteration order.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4a9b0b4d-c4a5-47bf-a7a2-96a1f2f452ee
📒 Files selected for processing (49)
database/migrations/2026_04_23_000000_create_visual_editor_templates_table.phpdatabase/migrations/2026_04_23_100000_create_visual_editor_template_parts_table.phpdatabase/migrations/2026_04_23_200000_create_visual_editor_global_styles_table.phpdatabase/migrations/2026_04_23_300000_create_visual_editor_navigations_table.phpdatabase/migrations/2026_04_23_400000_create_visual_editor_patterns_table.phpdatabase/migrations/2026_04_23_500000_create_visual_editor_pattern_categories_table.phpdatabase/migrations/2026_04_23_600000_create_visual_editor_pattern_category_table.phpdatabase/migrations/2026_04_24_000000_add_location_to_visual_editor_navigations_table.phpdatabase/migrations/2026_05_15_000000_drop_legacy_visual_editor_tables.phpdocs/plans/14-cms-framework-site-editor-integration.mdpackages/visual-editor-renderer-blade/src/Services/GlobalStylesEmissionResolver.phppackages/visual-editor-renderer-blade/src/View/Components/BlocksComponent.phppackages/visual-editor-renderer-blade/src/View/Components/TemplateComponent.phppackages/visual-editor-renderer-blade/src/VisualEditorRendererBladeServiceProvider.phppackages/visual-editor-renderer-blade/tests/Feature/BlocksComponentTest.phppackages/visual-editor-renderer-blade/tests/Feature/GlobalStylesEmissionTest.phppackages/visual-editor-renderer-blade/tests/Feature/SyncedPatternRenderingTest.phppackages/visual-editor-renderer-blade/tests/Feature/TemplateComponentTest.phppackages/visual-editor-renderer-blade/tests/Feature/TemplatePartRenderingTest.phpsrc/Http/Controllers/EntitySearchController.phpsrc/Http/Controllers/MenuLocationsController.phpsrc/Models/VisualEditorGlobalStyles.phpsrc/Models/VisualEditorNavigation.phpsrc/Models/VisualEditorPattern.phpsrc/Models/VisualEditorPatternCategory.phpsrc/Models/VisualEditorTemplate.phpsrc/Models/VisualEditorTemplatePart.phpsrc/Policies/VisualEditorGlobalStylesPolicy.phpsrc/Policies/VisualEditorNavigationPolicy.phpsrc/Policies/VisualEditorPatternPolicy.phpsrc/Policies/VisualEditorTemplatePartPolicy.phpsrc/Policies/VisualEditorTemplatePolicy.phpsrc/Resources/PatternInliner.phpsrc/Resources/TemplatePartInliner.phpsrc/Resources/TemplateResolver.phpsrc/Services/GlobalStylesCacheInvalidator.phpsrc/Services/GlobalStylesCompiler.phpsrc/Services/GlobalStylesCssProvider.phpsrc/Services/MenuLocationResolver.phpsrc/VisualEditorServiceProvider.phptests/Feature/VisualEditor/EntitySearchControllerTest.phptests/Feature/VisualEditor/GlobalStylesCssProviderTest.phptests/Feature/VisualEditor/MenuLocationResolverTest.phptests/Feature/VisualEditor/MenuLocationsControllerTest.phptests/Unit/VisualEditor/GlobalStylesCompilerTest.phptests/Unit/VisualEditor/PatternInlinerTest.phptests/Unit/VisualEditor/TemplatePartInlinerTest.phptests/Unit/VisualEditor/TemplateResolverTest.phptests/Unit/VisualEditor/VisualEditorTemplateTest.php
💤 Files with no reviewable changes (34)
- database/migrations/2026_04_23_500000_create_visual_editor_pattern_categories_table.php
- src/Models/VisualEditorPatternCategory.php
- database/migrations/2026_04_23_200000_create_visual_editor_global_styles_table.php
- database/migrations/2026_04_23_300000_create_visual_editor_navigations_table.php
- src/Policies/VisualEditorGlobalStylesPolicy.php
- src/Models/VisualEditorGlobalStyles.php
- tests/Unit/VisualEditor/TemplateResolverTest.php
- database/migrations/2026_04_23_400000_create_visual_editor_patterns_table.php
- tests/Unit/VisualEditor/GlobalStylesCompilerTest.php
- packages/visual-editor-renderer-blade/tests/Feature/TemplatePartRenderingTest.php
- src/Policies/VisualEditorTemplatePartPolicy.php
- src/Models/VisualEditorTemplate.php
- database/migrations/2026_04_23_100000_create_visual_editor_template_parts_table.php
- tests/Unit/VisualEditor/TemplatePartInlinerTest.php
- src/Policies/VisualEditorTemplatePolicy.php
- src/Services/GlobalStylesCompiler.php
- src/Policies/VisualEditorNavigationPolicy.php
- tests/Unit/VisualEditor/VisualEditorTemplateTest.php
- database/migrations/2026_04_23_600000_create_visual_editor_pattern_category_table.php
- src/Policies/VisualEditorPatternPolicy.php
- database/migrations/2026_04_24_000000_add_location_to_visual_editor_navigations_table.php
- src/Services/GlobalStylesCssProvider.php
- src/Services/GlobalStylesCacheInvalidator.php
- src/Models/VisualEditorTemplatePart.php
- tests/Feature/VisualEditor/GlobalStylesCssProviderTest.php
- database/migrations/2026_04_23_000000_create_visual_editor_templates_table.php
- src/Resources/TemplateResolver.php
- src/Models/VisualEditorNavigation.php
- src/Models/VisualEditorPattern.php
- tests/Unit/VisualEditor/PatternInlinerTest.php
- src/Services/MenuLocationResolver.php
- tests/Feature/VisualEditor/MenuLocationResolverTest.php
- packages/visual-editor-renderer-blade/tests/Feature/TemplateComponentTest.php
- packages/visual-editor-renderer-blade/tests/Feature/SyncedPatternRenderingTest.php
CR flagged that the template / template-part search branch in EntitySearchController short-circuited the gather loop at MAX_RESULTS, then sorted what it had — meaning the returned 20 depended on the resolver's iteration order rather than being the alphabetically-first matches. Gather all candidates, sort, then slice — mirrors searchResourceModel()'s orderBy + limit semantics.
Summary
Closes #434. Final Phase H deliverable before umbrella #406 can close.
Walks through the per-system cutover described in the issue, with each step landing in its own commit inside this PR for chronological review. Net result: the plan-11 Phase D legacy is gone — six models, five policies, eight migrations, three resolver/inliner classes, two services, plus a drop-migration to retire orphan tables on existing installs.
Commit-by-commit walkthrough
2d51d51EntitySearchController+MenuLocationsControllerrewired against cms-framework resolvers /MenuLocationAssignmentunderclass_existsguards. Both return empty data without cms-framework (Phase H install gate is the user-facing surface). Tests rewritten to cover the no-cms-framework branch.GlobalStylesCssProvider+GlobalStylesCacheInvalidator+ the orphanedGlobalStylesCompiler. Renderer-blade's<x-ve-blocks>/<x-ve-template>now use a newGlobalStylesEmissionResolverthat delegates to cms-framework'sGlobalStylesEmitterunderclass_exists.TemplatePartInliner+PatternInlinerto consume cms-framework'sTemplatePartResolver+BlockPattern. Delete legacy visual-editorTemplateResolver;TemplateComponentwalks the WP-style fallback chain itself and calls cms-framework'sTemplateResolverper candidate.MenuLocationResolver. Remove imports, container bindings, andGate::policyregistrations fromVisualEditorServiceProvider. Drop the 8 plan-11visual_editor_*migrations. Add a drop-migration that retires the orphan tables on existing installs.289a235plan-14§4.5.1 shipped.What's gone
src/Models/):VisualEditorTemplate,VisualEditorTemplatePart,VisualEditorPattern,VisualEditorPatternCategory,VisualEditorGlobalStyles,VisualEditorNavigationsrc/Policies/): all 5 corresponding policiessrc/Resources/): legacyTemplateResolver(the new H5-awareSiteEditor\Resolution\TemplateResolverstays)src/Services/):GlobalStylesCssProvider,GlobalStylesCacheInvalidator,GlobalStylesCompiler(orphan),MenuLocationResolverdatabase/migrations/): 8create_visual_editor_*filesVisualEditorTemplateTest,MenuLocationResolverTest,GlobalStylesCssProviderTest,GlobalStylesCompilerTest,TemplateResolverTest,TemplatePartInlinerTest,PatternInlinerTest, and three renderer-blade feature tests (TemplateComponentTest,TemplatePartRenderingTest,SyncedPatternRenderingTest) — all exercised legacy DB-fixture behavior that no longer applies.What's new
packages/visual-editor-renderer-blade/src/Services/GlobalStylesEmissionResolver.php— thin facade over cms-framework'sGlobalStylesEmitter, with aclass_existsshort-circuit.database/migrations/2026_05_15_000000_drop_legacy_visual_editor_tables.php— drops all 8 legacy tables.dropIfExistsso fresh installs and partially-cleaned envs both run cleanly. Irreversible by design.What changed in place
TemplatePartInliner+PatternInliner— same public API, same cycle / depth guards. ThefindPart/findPatternlookup methods now resolve through cms-framework. Block-markupthemeattributes are preserved on output but no longer drive the lookup (cms-framework scopes by active theme implicitly).EntitySearchController— template / template-part search hits cms-framework's resolvers; resources-config sources (pages, posts) still use direct Eloquent query.MenuLocationsController— reads theme.jsonmenus.locationsviaThemeManager+ assignments viaMenuLocationAssignment.is_fallbackalwaysfalsein the response (cms-framework has no config fallback chain — that was a Phase D concept).TemplateComponent— walks the WP fallback chain itself, calls cms-framework'sTemplateResolverper candidate. Thethemeprop is preserved but no longer drives the resolver (same reasoning as the inliners).BlocksComponent+TemplateComponent— swapGlobalStylesCssProviderforGlobalStylesEmissionResolver. ThedefaultThemeprop on<x-ve-blocks>is preserved but no longer drives global-styles theme selection (cms-framework's emitter uses the active theme).Behavioral notes
MenuLocation.is_fallbackfield stays in the response shape for backwards compatibility with the existing JS contract, but it's alwaysfalse. The JS-sideMenuLocationtype comment mentions the fallback hint; that hint is now decorative — the renderer should treat unassigned locations as plainly empty.Gate::authorizecalls left inEntitySearchController/MenuLocationsController. Route middleware (['api', 'auth']perconfig/visual-editor.php) still gates access.Test plan
./vendor/bin/pest --compact— 505 passed (down from 576; the deletions removed legacy-model-backed tests, replaced with smaller no-cms-framework-branch tests)npm test— 1031 passed across 110 test filessrc/VisualEditorServiceProvider.phpparses cleanly, no leftover imports for deleted classesDrop-migration deployment notes
The new migration
2026_05_15_000000_drop_legacy_visual_editor_tables.phpdrops the 8visual_editor_*tables on existing installs. Fresh v1.x installs never create them. The migration is irreversible by design — Phase H replaced the schema, there's no migration path back. Apps that need the old tables should pin to a pre-v1 release.Closes the Phase H umbrella
After this lands, #406 (Phase H umbrella) has no open deliverables. visual-editor v1.0.0 can tag from
release/1.0.🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Bug Fixes
Documentation
Tests