mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
fix: $relationsArray
can end up containing closures (#146)
* fix: `$relationsArray` can end up containing closures Not sure I didn't simply unset the first time around.. * Use a new array instead of modifying one
This commit is contained in:
@@ -33,15 +33,16 @@ class TagRepository
|
||||
*/
|
||||
public function with($relations, User $actor): Builder
|
||||
{
|
||||
$relationsArray = is_string($relations) ? explode(',', $relations) : $relations;
|
||||
|
||||
foreach (self::TAG_RELATIONS as $relation) {
|
||||
if (in_array($relation, $relationsArray, true)) {
|
||||
$relationsArray = array_diff($relationsArray, [$relation]);
|
||||
$relations = is_string($relations) ? explode(',', $relations) : $relations;
|
||||
$relationsArray = [];
|
||||
|
||||
foreach ($relations as $relation) {
|
||||
if (in_array($relation, self::TAG_RELATIONS, true)) {
|
||||
$relationsArray[$relation] = function ($query) use ($actor) {
|
||||
$query->whereVisibleTo($actor);
|
||||
};
|
||||
} else {
|
||||
$relationsArray[] = $relation;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user