diff --git a/api/v1/_dois/BackendDoiController.php b/api/v1/_dois/BackendDoiController.php index ff4f7c385a1..699c7b885fc 100644 --- a/api/v1/_dois/BackendDoiController.php +++ b/api/v1/_dois/BackendDoiController.php @@ -22,7 +22,6 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\Route; -use Illuminate\Support\LazyCollection; use PKP\db\DAORegistry; use PKP\userGroup\UserGroup; @@ -130,6 +129,7 @@ public function editIssue(Request $illuminateRequest): JsonResponse Repo::issue()->edit($issue, ['doiId' => $doi->getId()]); $issue = Repo::issue()->get($issue->getId()); + $userGroups = UserGroup::withContextIds([$context->getId()])->get(); return response()->json( Repo::issue() @@ -137,18 +137,13 @@ public function editIssue(Request $illuminateRequest): JsonResponse ->map( $issue, $context, - $this->getUserGroups($context->getId()), + $userGroups, $this->getGenres($context->getId()) ), Response::HTTP_OK ); } - protected function getUserGroups(int $contextId): LazyCollection - { - return UserGroup::where('contextId', $contextId)->get(); - } - protected function getGenres(int $contextId): array { /** @var \PKP\submission\GenreDAO $genreDao */ diff --git a/api/v1/issues/IssueController.php b/api/v1/issues/IssueController.php index 2cc29347297..bee6e5284e0 100644 --- a/api/v1/issues/IssueController.php +++ b/api/v1/issues/IssueController.php @@ -25,8 +25,8 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Route; -use Illuminate\Support\LazyCollection; use PKP\core\PKPBaseController; use PKP\core\PKPRequest; use PKP\db\DAORegistry; @@ -267,9 +267,9 @@ public function get(Request $illuminateRequest): JsonResponse return response()->json($data, Response::HTTP_OK); } - protected function getUserGroups(int $contextId): LazyCollection + protected function getUserGroups(int $contextId): Collection { - return UserGroup::where('contextId', $contextId)->get(); + return UserGroup::withContextIds([$contextId])->get(); } protected function getGenres(int $contextId): array diff --git a/classes/issue/maps/Schema.php b/classes/issue/maps/Schema.php index 43d2da6df99..66087192722 100644 --- a/classes/issue/maps/Schema.php +++ b/classes/issue/maps/Schema.php @@ -19,7 +19,6 @@ use APP\issue\IssueGalleyDAO; use APP\journal\Journal; use Illuminate\Support\Enumerable; -use Illuminate\Support\LazyCollection; use PKP\db\DAORegistry; use PKP\services\PKPSchemaService; use PKP\submission\Genre; @@ -33,8 +32,8 @@ class Schema extends \PKP\core\maps\Schema /** @copydoc \PKP\core\maps\Schema::$schema */ public string $schema = PKPSchemaService::SCHEMA_ISSUE; - /** @var LazyCollection The user groups for this context. */ - public LazyCollection $userGroups; + /** @var Enumerable The user groups for this context. */ + public Enumerable $userGroups; /** @var Genre[] The genres for this context. */ public array $genres; @@ -44,10 +43,10 @@ class Schema extends \PKP\core\maps\Schema * * Includes all properties in the Issue schema * - * @param LazyCollection $userGroups The user groups of this content + * @param Enumerable $userGroups The user groups of this content * @param Genre[] $genres The genres of this context */ - public function map(Issue $item, Journal $context, LazyCollection $userGroups, array $genres): array + public function map(Issue $item, Journal $context, Enumerable $userGroups, array $genres): array { $this->userGroups = $userGroups; $this->genres = $genres; @@ -71,10 +70,10 @@ public function summarize(Issue $item, Journal $context): array * * @see self::map * - * @param LazyCollection $userGroups The user groups of this content + * @param Enumerable $userGroups The user groups of this content * @param Genre[] $genres The genres of this context */ - public function mapMany(Enumerable $collection, Journal $context, LazyCollection $userGroups, array $genres): Enumerable + public function mapMany(Enumerable $collection, Journal $context, Enumerable $userGroups, array $genres): Enumerable { $this->collection = $collection; return $collection->map(function ($item) use ($context, $userGroups, $genres) {