-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Updated #622] Added configuration option to disable auditing for object associations #644
base: 1.x
Are you sure you want to change the base?
Conversation
# Conflicts: # src/AuditReader.php # src/EventListener/LogRevisionsListener.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As recommended by @phansys in #622 (review)
This PR would need tests for audit results as proof it works without unexpected exceptions.
@@ -216,7 +216,7 @@ public function find($className, $id, $revision, array $options = []) | |||
$columnName = $idKeys[0]; | |||
} elseif (isset($classMetadata->fieldMappings[$idField])) { | |||
$columnName = self::getMappingColumnNameValue($classMetadata->fieldMappings[$idField]); | |||
} elseif (isset($classMetadata->associationMappings[$idField]['joinColumns'])) { | |||
} elseif (!$this->config->areAssociationsDisabled() && isset($classMetadata->associationMappings[$idField]['joinColumns'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
isset($classMetadata->associationMappings[$idField]['joinColumns'])
but the associations are disabled you now won't enter in this elseif, so you will go in the else
throw new \RuntimeException('column name not found for'.$idField);
- Is it an expected behavior to get an exception ?
- I would expect a better error message
So I think the logic should be
elseif (isset($classMetadata->associationMappings[$idField]['joinColumns'])) {
if ($this->config->areAssociationsDisabled()) {
// custom behavior or error message
} else {
$columnName = $classMetadata->associationMappings[$idField]['joinColumns'][0]['name'];
}
} else {
...
}
@@ -113,6 +113,14 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs) | |||
$revIndexName = $this->config->getRevisionFieldName().'_'.md5($revisionTable->getName()).'_idx'; | |||
$revisionTable->addIndex([$this->config->getRevisionFieldName()], $revIndexName); | |||
|
|||
if (!$this->config->areForeignKeysDisabled()) { | |||
$this->createForeignKeys($revisionTable, $revisionsTable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You now create ForeignKey before association.
I think it's better to move the foreach ($cm->associationMappings as $associationMapping) {
inside a
if (!$this->config->areAssociationsDisabled()) {
to avoid impacts.
Subject
Pull request allows you to globally disable building a database scheme, and attempt to audit object relationships.
I am targeting this branch, because it is a new feature.
This is the updated PR #622.
Closes #601.
Changelog