Closed
Description
Laravel Version
12.10.0+ from quick testing
PHP Version
8.4
Database Driver & Version
irrelevant
Description
As part of the recent changes to relations, it seems there's a regression in handling polymorphic pivots.
We're seeing $this->morphClass
being set to null on a class extending MorphPivot
(being used for the relation).
Stack trace (maybe not very relevant):
... my code referencing $this->morphClass inside a deleting() listener
5 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:461
6 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:288
7 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:268
8 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:234
9 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php:224
10 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1473
11 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php:133
12 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php:59
13 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php:476
14 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php:433
This seems to be specifically when detaching.
Haven't had a chance to look into this in depth, but it seems to be caused by #55490, reverting InteractsWithPivotTable
to the previous commit (99e1ceb) fixes this.
Steps To Reproduce
Don't have a confirmed minimal repro, this is part of more complex logic, however using a custom MorphPivot
(using()
on a relation), inside that doing:
public static function booted()
{
static::deleting(function (self $pivot) {
dd($pivot->morphClass);
});
}
should produce null on the latest commit but a class string on 99e1ceb.
Metadata
Metadata
Assignees
Labels
No labels