You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.
Database Driver & Version: MySQL driver, MySQL 5.7.12
Description:
I have discovered that if you do a whereHas() statement to a relationship and that relationship's model has a global scope that also does a whereHas(), then a loop is formed and you run out of memory and get a 500 error.
Steps To Reproduce:
I have tried to remove as much cruft as possible and get you the general idea:
class Post extends CrossDatabaseModel
{
protected $connection = 'mysql';
protected $table = 'posts';
/**
* Get the thread which the post belongs to.
*/
public function thread()
{
return $this->belongsTo(Thread::class);
}
}
class Thread extends CrossDatabaseModel
{
protected $connection = 'mysql';
protected $table = 'threads';
protected static function boot()
{
parent::boot();
static::addGlobalScope(function ($builder) {
$builder->whereHas('category', function ($query) {
$query->whereNull('deleted_at');
});
});
}
public function category()
{
return $this->belongsTo(Category::class);
}
}
Description:
I have discovered that if you do a whereHas() statement to a relationship and that relationship's model has a global scope that also does a whereHas(), then a loop is formed and you run out of memory and get a 500 error.
Steps To Reproduce:
I have tried to remove as much cruft as possible and get you the general idea:
The text was updated successfully, but these errors were encountered: