Skip to content

[12.x] Fix infinite recursion when defining model scope with attribute as private#59958

Merged
taylorotwell merged 2 commits intolaravel:12.xfrom
noefleury:fix/infinite-recursion-private-scope
May 1, 2026
Merged

[12.x] Fix infinite recursion when defining model scope with attribute as private#59958
taylorotwell merged 2 commits intolaravel:12.xfrom
noefleury:fix/infinite-recursion-private-scope

Conversation

@noefleury
Copy link
Copy Markdown
Contributor

The following code was crashing due to an infinite recursion :

class DummyModel extends Model
{

    #[Scope]
    private function myScope(Builder $builder)
    {
        return $builder;
    }

}

DummyModel::query()->myScope();

It was recursively going to resolve the scope through the ___call model method.

As the scope is private it was detected through reflection but each time trying to call it we fallback into __call again.

@taylorotwell taylorotwell merged commit e25d8ed into laravel:12.x May 1, 2026
54 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants