Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/src/Lib/Events/RuleBuilderEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@

class RuleBuilderEventListener Implements EventListenerInterface {
use \App\Lib\Traits\LabeledLogTrait;

/**
* Track which RulesChecker instances we've already modified, to avoid adding
* duplicate rules (which can trigger duplicate rule-name exceptions).
*
* Key format: "<TableAlias>#<spl_object_id(RulesChecker)>"
*
* @var array<string, bool>
*/
private static array $buildRulesRan = [];

/**
* Build rules event listener.
Expand Down Expand Up @@ -69,6 +79,14 @@ public function buildRules(Event $event, RulesChecker $rules) {

}

$onceKey = $subjectTable->getRegistryAlias() . '#' . spl_object_id($rules);
if (isset(self::$buildRulesRan[$onceKey])) {
// Already built rules for this table+rules checker; avoid duplicate rule-name exceptions.
$event->setResult($rules);
return;
}
self::$buildRulesRan[$onceKey] = true;

$schema = $subjectTable->getSchema();

// We need to skip some metadata fields, including changelog and EIS fks
Expand Down