Endless loop in __call of HasSettings.php when using V2 User model.
Closed this issue · 2 comments
Describe the bug
When using a User V2 class, which inherits from the UserV1 class and utilizes the HasSettingsField trait, an unexpected behavior occurs. Certain method calls result in an endless loop, causing the program to become unresponsive.
To Reproduce
Steps to reproduce the behavior:
- Create a V2 user model which inherits from V1 user model.
- Call Endpoint that uses V2 User model
- Socket hang up error
My user models:
// App\Models\Base\User
class UserV1 extends Authenticatable
{
use HasSettingsField;
// Other class implementation
}
// App\Models\V2\Base\User
class UserV2 extends UserV1
{
// Other class implementation
}
Expected behavior
Endpoints returns data (just like when using v1 User model.
Additional context
I investigated this bug and found, that this function in HasSettings.php causes the issue:
public function __call($name, $args)
{
if (isset($this->invokeSettingsBy) && $name === $this->invokeSettingsBy) {
return $this->settings();
}
return call_user_func(get_parent_class($this) . '::__call', $name, $args);
}
which was updated in v5.0.1 - everything works fine when I use 5.0.0. This is the PR: https://github.com/glorand/laravel-model-settings/pull/105/files
I want to update to v6 to use Laravel 10. But this issue blocks the update for me.