From ff07fa396090c7e5df0161b234a358aec74bd861 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 28 Jun 2025 18:29:41 +0300 Subject: [PATCH] Review comments fixes --- .../OrcidSource/src/Controller/ApiV2Controller.php | 10 ++-------- .../src/Model/Table/OrcidSourcesTable.php | 14 ++++---------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php b/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php index 4d99c4b3c..22ff3307c 100644 --- a/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php +++ b/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php @@ -88,16 +88,10 @@ public function get(string $orcid, int $coId) { $orcidSourcesRecords = $this->OrcidSources ->find() ->contain([ - 'Servers.Oauth2Servers' => function ($q) { - return $q->where(["LOWER(Oauth2Servers.url) LIKE" => '%orcid%']); - }, + 'Servers', 'ExternalIdentitySources', ]) - ->innerJoinWith('Servers.Oauth2Servers', function ($q) { - return $q->where([ - "LOWER(Oauth2Servers.url) LIKE" => '%orcid%' - ]); - }) + ->innerJoinWith('Servers') ->innerJoinWith('ExternalIdentitySources') ->where([ 'Servers.plugin' => 'CoreServer.Oauth2Servers', diff --git a/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php b/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php index a72fa7a08..4bbb0052f 100644 --- a/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php +++ b/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php @@ -517,28 +517,22 @@ protected function orcidConnect( ): \Cake\Http\Client { $this->orcidSource = $this->find() ->contain([ - 'Servers.Oauth2Servers' => function ($q) { - return $q->where(["LOWER(Oauth2Servers.url) LIKE" => '%orcid%']); - }, + 'Servers' => ['Oauth2Servers'], 'ExternalIdentitySources', ]) - ->innerJoinWith('Servers.Oauth2Servers', function ($q) { - return $q->where([ - "LOWER(Oauth2Servers.url) LIKE" => '%orcid%' - ]); - }) + ->innerJoinWith('Servers.Oauth2Servers') ->innerJoinWith('ExternalIdentitySources') ->where([ 'Servers.plugin' => 'CoreServer.Oauth2Servers', 'ExternalIdentitySources.id' => $exterrnalIdentitySource->id, - 'ExternalIdentitySources.plugin' => 'OrcidSource.OrcidSources' + 'ExternalIdentitySources.plugin' => 'OrcidSource.OrcidSources', ]) ->first(); // Set the CO ID $this->setCurCoId($this->orcidSource->server->co_id); - if ( empty($this->orcidSource->id)) { + if (empty($this->orcidSource->id)) { throw new \InvalidArgumentException(__d('error', 'notfound', [__d('core_server', 'controller.Oauth2Servers')])); }