-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Fix: Compare Action route #406
Fix: Compare Action route #406
Conversation
XML needs to explicitly define a null using attributes
Otherwise we get a Column not found sql error
@@ -46,8 +46,7 @@ public function __invoke(Request $request, string $className, string $id, ?int $ | |||
$newRev = $request->query->get('newRev'); | |||
} | |||
|
|||
$ids = explode(',', $id); | |||
$diff = $this->auditReader->diff($className, $ids, $oldRev, $newRev); | |||
$diff = $this->auditReader->diff($className, $id, $oldRev, $newRev); |
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.
Array are supposed to be supported
EntityAuditBundle/src/AuditReader.php
Line 617 in e38bb57
* @param int|string|array $id |
and find support array too
EntityAuditBundle/src/AuditReader.php
Line 220 in e38bb57
public function find($className, $id, $revision, array $options = []) |
I would say we try to support something like 3,4,5
.
Do it mean this case is broken
EntityAuditBundle/src/AuditReader.php
Line 235 in e38bb57
if (\is_array($id) && \count($id) > 0) { |
@wbloszyk @phansys you're using this bundle, do you pass array/multiple ids some times ?
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 we pass $ids
as an array to the find()
function, then inside
EntityAuditBundle/src/AuditReader.php
Lines 235 to 237 in e38bb57
if (\is_array($id) && \count($id) > 0) { | |
$idKeys = array_keys($id); | |
$columnName = $idKeys[0]; |
$idKeys = [0 => 0]
$columnName = 0
...which leads to
EntityAuditBundle/src/AuditReader.php
Line 246 in e38bb57
$whereSQL .= ' AND e.'.$columnName.' = ?'; |
$whereSQL = "e.rev <= ? AND e.0 = ?"
which leads to the sql error.
While I think the type of $id
at
EntityAuditBundle/src/AuditReader.php
Line 220 in e38bb57
public function find($className, $id, $revision, array $options = []) |
diff()
function at EntityAuditBundle/src/AuditReader.php
Line 617 in e38bb57
* @param int|string|array $id |
* @param int|string $id
- because I think a diff is on a single object, by definition.
In that case, the new value becomes:
$whereSQL = "e.rev <= ? AND e.id = ?"
which is correct.
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.
...I've added this change into the PR, as CompareAction
is the only place which calls the diff()
function in the AuditReader
.
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.
Lint errors were found. A patch is also available. Please see the report: https://flintci.io/repositories/8593/analyses/63517 This comment was posted by FlintCI. It can be disabled in the repository settings. |
@BurningDog Can you do the same for others actions like in PR https://github.com/sonata-project/EntityAuditBundle/pull/331/files ? |
@VincentLanglet ok, done - I searched for all calls to the |
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.
Are these changes disallowing the possibility of using entities with composite ids?
If yes, I think we must add validations to prevent these entities to be marked as auditable from the beginning.
Composite ids can be used if you call directly the method of the AuditReader, but cannot be used with these actions. I dont think it's specifically new since you cannot pass composite ids in a url. Can u ? Imho if something should be added it would be better to create an issue about, in order to not delay this bugfix |
Yes, by instance you can use this approach for the ORM manager: "/app/entity/1~42/show".
I agree. |
Subject
This fixes the issue where a revision could not be viewing via the
CompareAction
route.I am targeting the
1.x
branch because it's a bug fix which is backwards compatible.Closes #405.
Changelog