From 8bac2efe7a1186f4ff9bf9ba76d84fd99efc3e4d Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 12 Sep 2025 19:17:44 +0300 Subject: [PATCH] cakephp5 deprecation fixes --- .../src/Controller/EnvSourceCollectorsController.php | 2 +- .../src/Model/Table/EnvSourceCollectorsTable.php | 4 ++-- app/src/Controller/PetitionsController.php | 2 +- app/src/Controller/StandardEnrollerController.php | 5 +++-- app/src/Model/Table/ExternalIdentitiesTable.php | 2 +- app/src/Model/Table/ExternalIdentityRolesTable.php | 4 ++-- app/src/Model/Table/ExternalIdentitySourcesTable.php | 2 +- app/src/Model/Table/GroupMembersTable.php | 6 +++--- app/src/Model/Table/GroupsTable.php | 2 +- app/src/Model/Table/NamesTable.php | 2 +- app/src/Model/Table/PeopleTable.php | 12 ++++++------ app/src/Model/Table/PetitionsTable.php | 12 ++++++------ app/src/Model/Table/PipelinesTable.php | 4 ++-- 13 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/plugins/EnvSource/src/Controller/EnvSourceCollectorsController.php b/app/plugins/EnvSource/src/Controller/EnvSourceCollectorsController.php index 1cbae03a8..4df18edaf 100644 --- a/app/plugins/EnvSource/src/Controller/EnvSourceCollectorsController.php +++ b/app/plugins/EnvSource/src/Controller/EnvSourceCollectorsController.php @@ -78,7 +78,7 @@ public function dispatch(string $id) { // Pull our configuration - $envSource = $this->EnvSourceCollectors->get((int)$id, ['contain' => ['ExternalIdentitySources' => 'EnvSources']]); + $envSource = $this->EnvSourceCollectors->get((int)$id, contain: ['ExternalIdentitySources' => 'EnvSources']); try { $vars = $this->EnvSourceCollectors->parse($envSource->external_identity_source->env_source); diff --git a/app/plugins/EnvSource/src/Model/Table/EnvSourceCollectorsTable.php b/app/plugins/EnvSource/src/Model/Table/EnvSourceCollectorsTable.php index c4c23051c..af57c539e 100644 --- a/app/plugins/EnvSource/src/Model/Table/EnvSourceCollectorsTable.php +++ b/app/plugins/EnvSource/src/Model/Table/EnvSourceCollectorsTable.php @@ -232,7 +232,7 @@ public function hydrate(int $id, \App\Model\Entity\Petition $petition) { $eis = $ExtIdentitySources->get( $cfg->external_identity_source_id, - ['contain' => 'EnvSources'] + contain: 'EnvSources' ); $eisrecord = $EnvSources->retrieve($eis, $pei->env_source_identity->source_key); @@ -514,7 +514,7 @@ public function verifiableEmailAddresses( $eis = $this->ExternalIdentitySources->get( $config->external_identity_source_id, - ['contain' => 'Pipelines'] + contain: 'Pipelines' ); $defaultVerified = isset($eis->pipeline->sync_verify_email_addresses) diff --git a/app/src/Controller/PetitionsController.php b/app/src/Controller/PetitionsController.php index 5ee3b571f..6950925eb 100644 --- a/app/src/Controller/PetitionsController.php +++ b/app/src/Controller/PetitionsController.php @@ -209,7 +209,7 @@ public function finalize(string $id) { // We only use the Redirect on Finalize URL (if specified) on success, // since otherwise the Flash error won't render - $petition = $this->Petitions->get((int)$id, ['contain' => ['EnrollmentFlows']]); + $petition = $this->Petitions->get((int)$id, contain: ['EnrollmentFlows']); if(!empty($petition->enrollment_flow->redirect_on_finalize)) { return $this->redirect($petition->enrollment_flow->redirect_on_finalize); diff --git a/app/src/Controller/StandardEnrollerController.php b/app/src/Controller/StandardEnrollerController.php index 1335d3d38..ea70e6982 100644 --- a/app/src/Controller/StandardEnrollerController.php +++ b/app/src/Controller/StandardEnrollerController.php @@ -104,7 +104,8 @@ public function calculatePermission(): bool { return false; } - $stepConfig = $this->getCurrentTable()->get($modelId, ['contain' => ['EnrollmentFlowSteps' => ['EnrollmentFlows']]]); + $stepConfig = $this->getCurrentTable() + ->get($modelId, contain: ['EnrollmentFlowSteps' => ['EnrollmentFlows']]); $this->set('vv_step_config', $stepConfig); $this->set('vv_title', $stepConfig['enrollment_flow_step']['enrollment_flow']['name']); @@ -229,7 +230,7 @@ public function willHandleAuth(\Cake\Event\EventInterface $event): string { return 'notauth'; } - $stepConfig = $this->getCurrentTable()->get($modelId, ['contain' => 'EnrollmentFlowSteps']); + $stepConfig = $this->getCurrentTable()->get($modelId, contain: 'EnrollmentFlowSteps'); // Determine if the requested step is past the current/next step. // We don't allow steps that haven't run yet to be run out of order. diff --git a/app/src/Model/Table/ExternalIdentitiesTable.php b/app/src/Model/Table/ExternalIdentitiesTable.php index c3f91fad0..d21208ffb 100644 --- a/app/src/Model/Table/ExternalIdentitiesTable.php +++ b/app/src/Model/Table/ExternalIdentitiesTable.php @@ -453,7 +453,7 @@ public function beforeDelete(\Cake\Event\Event $event, $entity, \ArrayObject $op $this->Names->delete($n, ['checkRules' => false]); } - return true; + $event->setResult(true); } /** diff --git a/app/src/Model/Table/ExternalIdentityRolesTable.php b/app/src/Model/Table/ExternalIdentityRolesTable.php index 88c012386..541e465c5 100644 --- a/app/src/Model/Table/ExternalIdentityRolesTable.php +++ b/app/src/Model/Table/ExternalIdentityRolesTable.php @@ -238,8 +238,8 @@ public function beforeDelete(\Cake\Event\Event $event, $entity, \ArrayObject $op } $this->recordHistory(entity: $entity, action: ActionEnum::MVEADeleted); - - return true; + + $event->setResult(true); } /** diff --git a/app/src/Model/Table/ExternalIdentitySourcesTable.php b/app/src/Model/Table/ExternalIdentitySourcesTable.php index 1e0937b7f..76a1b0089 100644 --- a/app/src/Model/Table/ExternalIdentitySourcesTable.php +++ b/app/src/Model/Table/ExternalIdentitySourcesTable.php @@ -231,7 +231,7 @@ protected function getEIS(int $id) { // the query simpler we contain all possible relations, which will // usually only be a small number. if(empty($this->eisCache[$id])) { - $this->eisCache[$id] = $this->get($id, ['contain' => $this->getPluginRelations()]); + $this->eisCache[$id] = $this->get($id, contain: $this->getPluginRelations()); } return $this->eisCache[$id]; diff --git a/app/src/Model/Table/GroupMembersTable.php b/app/src/Model/Table/GroupMembersTable.php index 98c0a2a2d..a9c03d114 100644 --- a/app/src/Model/Table/GroupMembersTable.php +++ b/app/src/Model/Table/GroupMembersTable.php @@ -244,7 +244,7 @@ public function isMember(int $groupId, public function localAfterSave(\Cake\Event\EventInterface $event, \Cake\Datasource\EntityInterface $entity, \ArrayObject $options): bool { // Pull the related entities for HistoryRecord comment creation. - $person = $this->People->get($entity->person_id, ['contain' => ['PrimaryName']]); + $person = $this->People->get($entity->person_id, contain: ['PrimaryName']); $group = $this->Groups->get($entity->group_id); $action = null; @@ -259,8 +259,8 @@ public function localAfterSave(\Cake\Event\EventInterface $event, \Cake\Datasour // We need to allow retrieval of archived records since we might be called // after the GroupNesting was deleted $nesting = $this->GroupNestings->get($entity->group_nesting_id, - ['contain' => ['Groups'], - 'archived' => true]); + contain: ['Groups'], + archived: true); $langKeySuffix = '.nesting'; $commentParams[] = $nesting->group->name; diff --git a/app/src/Model/Table/GroupsTable.php b/app/src/Model/Table/GroupsTable.php index 42f4c48a1..69a4df40b 100644 --- a/app/src/Model/Table/GroupsTable.php +++ b/app/src/Model/Table/GroupsTable.php @@ -389,7 +389,7 @@ public function beforeDelete(EventInterface $event, $entity, \ArrayObject $optio // to look at the archived data. } - return true; + $event->setResult(true); } /** diff --git a/app/src/Model/Table/NamesTable.php b/app/src/Model/Table/NamesTable.php index 1d07a8e09..6fa842643 100644 --- a/app/src/Model/Table/NamesTable.php +++ b/app/src/Model/Table/NamesTable.php @@ -242,7 +242,7 @@ public function localAfterSave(\Cake\Event\EventInterface $event, \Cake\Datasour */ public function primaryName(int $id, string $recordType='person', array $options = []) { - $query = empty($options) ? $this->find() : $this->find('all', $options); + $query = empty($options) ? $this->find() : $this->find('all', ...$options); if($recordType == 'person') { // Return the Primary Name diff --git a/app/src/Model/Table/PeopleTable.php b/app/src/Model/Table/PeopleTable.php index 92e8ec0fc..af25f5a44 100644 --- a/app/src/Model/Table/PeopleTable.php +++ b/app/src/Model/Table/PeopleTable.php @@ -358,7 +358,7 @@ public function beforeDelete(\Cake\Event\Event $event, $entity, \ArrayObject $op } } - return true; + $event->setResult(true); } /** @@ -469,10 +469,10 @@ public function localAfterSave(\Cake\Event\EventInterface $event, \Cake\Datasour public function marshalProvisioningData(int $id): array { $ret = []; - $ret['data'] = $this->get($id, [ + $ret['data'] = $this->get($id, // We need archives for handling deleted records - 'archived' => 'true', - 'contain' => [ + archived: 'true', + contain: [ 'PrimaryName' => [ 'Types' ], 'Addresses' => [ 'Types' ], 'AdHocAttributes', @@ -510,7 +510,7 @@ public function marshalProvisioningData(int $id): array { 'TelephoneNumbers' => [ 'Types' ], 'Urls' => [ 'Types' ] ] - ]); + ); // Provisioning Eligibility is // - Deleted if the changelog deleted flag is true OR status is Archived @@ -620,7 +620,7 @@ public function recalculateStatus(int $id): ?string { // Start by pulling the roles for this person, along with the Person record - $person = $this->get($id, ['contain' => 'PersonRoles']); + $person = $this->get($id, contain: 'PersonRoles'); if(!empty($person->person_roles)) { foreach($person->person_roles as $role) { diff --git a/app/src/Model/Table/PetitionsTable.php b/app/src/Model/Table/PetitionsTable.php index 595718082..7bf9c2ad1 100644 --- a/app/src/Model/Table/PetitionsTable.php +++ b/app/src/Model/Table/PetitionsTable.php @@ -331,13 +331,13 @@ public function buildRules(RulesChecker $rules): RulesChecker { */ public function derive(int $id) { - $petition = $this->get($id, ['contain' => [ + $petition = $this->get($id, contain: [ 'EnrollmentFlows' => [ 'EnrollmentFlowSteps' => array_merge( $this->EnrollmentFlows->EnrollmentFlowSteps->getPluginRelations(), ['sort' => ['EnrollmentFlowSteps.ordr' => 'ASC']] ) - ]]]); + ]]); if($petition->isComplete()) { throw new \InvalidArgumentException(__d('error', 'Petitions.completed', [$id])); @@ -380,7 +380,7 @@ public function derive(int $id) { */ public function finalize(int $id) { - $petition = $this->get($id, ['contain' => 'EnrollmentFlows']); + $petition = $this->get($id, contain: 'EnrollmentFlows'); if($petition->isComplete()) { throw new \InvalidArgumentException(__d('error', 'Petitions.completed', [$id])); @@ -421,7 +421,7 @@ public function finalize(int $id) { $template->generateMessage(); if(!DeliveryUtilities::sendEmailToAddress( - coId: $coId, + coId: $petition->enrollment_flow->co_id, recipient: $petition->enrollee_email, subject: $template->getMessagePart('subject'), body_text: $template->getMessagePart('body_text'), @@ -574,13 +574,13 @@ public function hydrate(int $id) { // This is intended to be the first part of finalization, so we set the Petition status // to Finalizing. - $petition = $this->get($id, ['contain' => [ + $petition = $this->get($id, contain: [ 'EnrollmentFlows' => [ 'EnrollmentFlowSteps' => array_merge( $this->EnrollmentFlows->EnrollmentFlowSteps->getPluginRelations(), ['sort' => ['EnrollmentFlowSteps.ordr' => 'ASC']] ) - ]]]); + ]]); if($petition->isComplete()) { throw new \InvalidArgumentException(__d('error', 'Petitions.completed', [$id])); diff --git a/app/src/Model/Table/PipelinesTable.php b/app/src/Model/Table/PipelinesTable.php index 68224a858..3836a2e9f 100644 --- a/app/src/Model/Table/PipelinesTable.php +++ b/app/src/Model/Table/PipelinesTable.php @@ -1941,7 +1941,7 @@ protected function syncPerson( if($externalIdentityId) { $externalIdentity = $this->Cos->People->ExternalIdentities->get( $externalIdentityId, - ['contain' => [ + contain: [ 'Addresses', 'AdHocAttributes', 'EmailAddresses', @@ -1955,7 +1955,7 @@ protected function syncPerson( 'Addresses', 'TelephoneNumbers' ] - ]] + ] ); } else { $externalIdentity = null;