-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Description
Laravel Version
12.20.0
PHP Version
8.4.1
Database Driver & Version
MongoDB 8.0.11
Description
The method Illuminate\Database\Eloquent\Model::offsetUnset
is not clean up $this->classCastCache[$offset]
it's not affect Laravel DB connection drivers from the box (but reprodused), but it's affected official Laravel MongoDB. When I'm using unset
method method getDirty()
every time returning attribute (which has class cast) which were unset because it's still in classCastCache
.
Steps To Reproduce
Can be reproduced on standard Laravel Eloquient DB driver
- Create Model
- Add class cast on attribute
- Prefetch this attribute value
- unset this attribute
- run (Model)->getAttributes()
Expected result: attribute which were unset must not be in result
Actual result: attribute again appeared in list
This behaviour is changed if change Illuminate\Database\Eloquent\Model::offsetUnset
to:
unset($this->attributes[$offset], $this->relations[$offset], $this->attributeCastCache[$offset], $this->classCastCache[$offset]);
My opened issue in MongoDB repo: mongodb/laravel-mongodb#3431
Metadata
Metadata
Assignees
Labels
No labels