Commit 77e34d3
committed
Fix: Skip Attribute accessor invocation for non-arrayable attributes (#55067)
This change ensures that Attribute-based get mutators are only invoked
during serialization when the attribute is actually arrayable. Hidden and non-visible Attribute accessors are no longer invoked during serialization. `attributesToArray()` now only processes mutators for attributes that are actually arrayable (visible and not hidden).
This resolves an issue where hidden Attribute accessors could run
unexpectedly during serialization, potentially causing unnecessary work
or exceptions when accessing unloaded relationships.
Key changes:
- Added `getArrayableMutatedAttributes()` to filter mutated attributes
based on arrayable keys
- Reverted to original `getAttributeMarkedMutatorMethods()` to avoid
breaking changes
- Added regression test verifying hidden Attribute accessors are not
invoked during serialization
Resolves #550671 parent 1527353 commit 77e34d3
File tree
2 files changed
+47
-33
lines changed- src/Illuminate/Database/Eloquent/Concerns
- tests/Database
2 files changed
+47
-33
lines changedLines changed: 26 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
| 685 | + | |
| 686 | + | |
689 | 687 | | |
690 | 688 | | |
691 | | - | |
692 | 689 | | |
693 | | - | |
| 690 | + | |
694 | 691 | | |
695 | 692 | | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
| 693 | + | |
704 | 694 | | |
705 | 695 | | |
706 | 696 | | |
| |||
765 | 755 | | |
766 | 756 | | |
767 | 757 | | |
768 | | - | |
769 | | - | |
| 758 | + | |
| 759 | + | |
770 | 760 | | |
771 | 761 | | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
776 | 766 | | |
777 | 767 | | |
778 | 768 | | |
| |||
2476 | 2466 | | |
2477 | 2467 | | |
2478 | 2468 | | |
2479 | | - | |
2480 | | - | |
2481 | | - | |
2482 | | - | |
2483 | | - | |
2484 | | - | |
2485 | | - | |
2486 | | - | |
| 2469 | + | |
2487 | 2470 | | |
2488 | | - | |
| 2471 | + | |
2489 | 2472 | | |
2490 | 2473 | | |
2491 | 2474 | | |
| |||
2518 | 2501 | | |
2519 | 2502 | | |
2520 | 2503 | | |
2521 | | - | |
2522 | | - | |
2523 | | - | |
2524 | | - | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
2525 | 2516 | | |
| 2517 | + | |
| 2518 | + | |
2526 | 2519 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3663 | 3663 | | |
3664 | 3664 | | |
3665 | 3665 | | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
3666 | 3687 | | |
3667 | 3688 | | |
3668 | 3689 | | |
| |||
0 commit comments