Skip to content

fix: Nested MorphTo relationship path caching - #20255

Merged
danharrin merged 1 commit into
4.xfrom
fix/nested-morphto-relationship-path-caching
Jul 22, 2026
Merged

fix: Nested MorphTo relationship path caching#20255
danharrin merged 1 commit into
4.xfrom
fix/nested-morphto-relationship-path-caching

Conversation

@danharrin

Copy link
Copy Markdown
Member

No description provided.

@danharrin danharrin added this to the v4 milestone Jul 22, 2026
Copilot AI review requested due to automatic review settings July 22, 2026 19:33
@danharrin danharrin added the bug Something isn't working label Jul 22, 2026
@danharrin
danharrin merged commit dec0ce3 into 4.x Jul 22, 2026
50 checks passed
@danharrin
danharrin deleted the fix/nested-morphto-relationship-path-caching branch July 22, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes incorrect caching of relationship/attribute path resolution when a table cell’s name traverses a MorphTo relationship and then continues into nested relationships, where the concrete related model can differ per record. It updates the shared caches in HasCellState to avoid reusing derived relationship metadata across records in that scenario, and adds regression tests to validate correct state output with mixed morph types.

Changes:

  • Add detection for “nested MorphTo relationship paths” and bypass relationship/attribute name caching when present.
  • Adjust HasCellState caching behavior for relationship resolution, attribute name resolution, and “multiple relationship” detection under nested MorphTo.
  • Add a dedicated Livewire table fixture and new tests covering nested MorphTo paths and mixed related model types.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/src/Tables/ColumnTest.php Adds regression tests for nested relationship state resolution through MorphTo, including mixed morph types.
tests/src/Fixtures/Livewire/ImagesTable.php Introduces a test-only table fixture with nested MorphTo-based columns used by the new tests.
packages/support/src/Concerns/HasCellState.php Prevents caching of relationship/attribute path metadata when the column name includes a nested MorphTo traversal.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants