Skip to content

Commit

Permalink
Changelog Behavior technical debt (CFM-24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Sep 20, 2025
1 parent 3a7a27e commit 47c3f25
Show file tree
Hide file tree
Showing 91 changed files with 400 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class ApiSource extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class ApiSourceEndpoint extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class ApiSourceRecord extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class FileProvisioner extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class FileSource extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class Password extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PasswordAuthenticator extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class IdentifierMapper extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
// use \App\Model\Entity\ExternalIdentityRole;

class LoginIdentifierType extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PersonRoleMapper extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
use \App\Model\Entity\ExternalIdentityRole;

class PersonRoleMapping extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class SqlProvisioner extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class SqlSource extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreApi/src/Model/Entity/MatchCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class MatchCallback extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreAssigner/src/Model/Entity/FormatAssigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class FormatAssigner extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class FormatAssignerSequence extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreAssigner/src/Model/Entity/SqlAssigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class SqlAssigner extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class EnrollmentAttribute extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PetitionAcceptance extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PetitionApproval extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PetitionAttribute extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PetitionBasicAttributeSet extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PetitionIdentifier extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class PetitionVerification extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreServer/src/Model/Entity/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class HttpServer extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreServer/src/Model/Entity/MatchServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class MatchServer extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class MatchServerAttribute extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreServer/src/Model/Entity/Oauth2Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class Oauth2Server extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreServer/src/Model/Entity/SmtpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class SmtpServer extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
2 changes: 2 additions & 0 deletions app/plugins/CoreServer/src/Model/Entity/SqlServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Cake\ORM\Entity;

class SqlServer extends Entity {
use \App\Lib\Traits\EntityMetaTrait;

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
12 changes: 12 additions & 0 deletions app/resources/locales/en_US/field.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ msgstr "Area Code"
msgid "attribute"
msgstr "Attribute"

msgid "changelog.actor_identifier"
msgstr "Actor Identifier"

msgid "changelog.deleted"
msgstr "Deleted"

msgid "changelog.parent"
msgstr "Parent Record ID"

msgid "changelog.revision"
msgstr "Revision"

msgid "code"
msgstr "Code"

Expand Down
9 changes: 9 additions & 0 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ msgstr "API Users created in the COmanage CO are given full privileges to all Re
msgid "api.key"
msgstr "This newly generated API Key cannot be recovered. If it is lost a new key must be generated."

msgid "changelog"
msgstr "Change Log"

msgid "changelog.archived"
msgstr "This is an archive record"

msgid "changelog.deleted"
msgstr "This record has been deleted"

msgid "cos.none"
msgstr "You are not an active member in any collaboration. If your request for enrollment is still being processed, you will not be able to login until it is approved. Please contact an administrator for assistance."

Expand Down
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/operation.po
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ msgstr "Bulk add"
msgid "cancel"
msgstr "Cancel"

msgid "changelog.view"
msgstr "View Change Log"

msgid "clear"
msgstr "Clear"

Expand Down
2 changes: 1 addition & 1 deletion app/src/Command/ResetMfaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
}*/

/**
* Execute the Database Command.
* Execute the Reset MFA Command.
*
* @since COmanage Registry v5.2.0
* @param Arguments $args Command Arguments
Expand Down
8 changes: 7 additions & 1 deletion app/src/Controller/ApiV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,18 @@ public function view($id = null) {
$table = $this->getCurrentTable();
// $tableName = models
$tableName = $table->getTable();
$request = $this->getRequest();

if(empty($id)) {
throw new InvalidArgumentException(__d('error', 'notprov', ['id']));
}

$obj = $table->findById($id)->firstOrFail();
// We allow archived records to be retrieved via the API, but only if
// explicitly requested

$archived = $request->getQuery('archived') === 'yes';

$obj = $table->findById($id)->applyOptions(['archived' => $archived])->firstOrFail();

$this->set($tableName, [$obj]);

Expand Down
8 changes: 7 additions & 1 deletion app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ public function getCurrentTable(): \Cake\ORM\Table

protected function primaryLinkOnGet(string $potentialPrimaryLink): Object|bool
{
/** @var string $modelsName */
$modelsName = $this->getName();

// If this action allows unkeyed, asserted primary link IDs, check the query
// string (e.g.: 'add' or 'index' allow matchgrid_id to be passed in)
$actionParam = $this->request->getParam('action');
Expand All @@ -311,7 +314,10 @@ protected function primaryLinkOnGet(string $potentialPrimaryLink): Object|bool
return false;
}

return $this->getCurrentTable()->findPrimaryLink($param);
// For a GET with a param (ie: a record id) we allow archived records to be
// retrieved via ChangelogBehavior. Note because $param must be an integer
// we don't need to check it further.
return $this->$modelsName->findPrimaryLink(id: $param, archived: true);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,12 @@ protected function calculatePermissions(?int $id=null): array {

// Pull the record so we can interrogate it

// XXX Get the record along with the contains
// Get the record along with the contains
// We use findById() rather than get() so we can apply subsequent
// query modifications via traits
$query = $table->findById($id);
// query modifications via traits. We set archived to true so we can
// retrieve archived records via ChangelogBehavior.
$query = $table->findById($id)
->applyOptions(['archived' => true]);

// QueryModificationTrait
$getActionMethod = "get{$reqAction}Contains";
Expand Down Expand Up @@ -1060,7 +1062,8 @@ public function isSelf(?int $coId, ?int $id): bool {

if ($request->getParam('action') == 'view' && $id !== null) {
$modelTable = TableRegistry::getTableLocator()->get($controllerName);
$modelEntity = $modelTable->get($id);
// We need to allow archived gets for viewing archived records
$modelEntity = $modelTable->get($id, ['archived' => true]);
// Associated Models, e.g. MVEAs
$primaryLinks = $modelTable->getPrimaryLinks();

Expand Down
Loading

0 comments on commit 47c3f25

Please sign in to comment.